Skip to content

feat: allow templateDebugUrl to be customized via output.publicPath or beforeEncode hook#2274

Merged
colinaaa merged 1 commit intomainfrom
feat/templateDebugUrl-hook
Mar 2, 2026
Merged

feat: allow templateDebugUrl to be customized via output.publicPath or beforeEncode hook#2274
colinaaa merged 1 commit intomainfrom
feat/templateDebugUrl-hook

Conversation

@upupming
Copy link
Copy Markdown
Collaborator

@upupming upupming commented Feb 27, 2026

Summary

This PR allows the templateDebugUrl (used for debugging Lynx templates) to be customized via:

  1. The output.publicPath configuration in Webpack/Rspack.
  2. The beforeEncode hook provided by LynxTemplatePlugin.

When a string-based publicPath (other than '/' or 'auto') is provided, or when modified manually via the hook, the plugin will use it as the base for the templateDebugUrl. The hook takes precedence over the publicPath configuration.

Proposed Changes

@lynx-js/template-webpack-plugin

  • Modified LynxTemplatePluginImpl to generate templateDebugUrl using output.publicPath if it's a valid string.
  • Added support for manually overriding templateDebugUrl in the beforeEncode hook.
  • Added new test cases:
    • debug-info-public-path-custom: Verifies customization via output.publicPath.
    • debug-info-before-encode: Verifies customization via beforeEncode hook and ensures it overrides output.publicPath.

Test Plan

Added and verified the following test cases in packages/webpack/template-webpack-plugin/test/cases/assets/:

  1. Custom publicPath:
npx vitest packages/webpack/template-webpack-plugin/test/cases.test.ts -t "assets debug-info-public-path-custom" --run
  1. beforeEncode hook override (Precedence Test):
npx vitest packages/webpack/template-webpack-plugin/test/cases.test.ts -t "assets debug-info-before-encode" --run

This test case sets both publicPath and a hook, verifying that the hook's value is the one that ends up in the final output.

Checklist

  • Added test cases
  • Added changeset

Summary by CodeRabbit

  • New Features

    • templateDebugUrl can now be customized via output.publicPath or the beforeEncode hook.
  • Tests

    • Added test coverage for custom templateDebugUrl configuration scenarios.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 27, 2026

🦋 Changeset detected

Latest commit: 817c386

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@lynx-js/template-webpack-plugin Patch
@lynx-js/react-rsbuild-plugin Patch
@lynx-js/react-alias-rsbuild-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09231ac and 817c386.

📒 Files selected for processing (8)
  • .changeset/allow-debug-url-customize.md
  • packages/webpack/template-webpack-plugin/src/LynxTemplatePlugin.ts
  • packages/webpack/template-webpack-plugin/test/cases/assets/debug-info-before-encode/index.js
  • packages/webpack/template-webpack-plugin/test/cases/assets/debug-info-before-encode/rspack.config.js
  • packages/webpack/template-webpack-plugin/test/cases/assets/debug-info-before-encode/webpack.config.js
  • packages/webpack/template-webpack-plugin/test/cases/assets/debug-info-public-path-custom/index.js
  • packages/webpack/template-webpack-plugin/test/cases/assets/debug-info-public-path-custom/rspack.config.js
  • packages/webpack/template-webpack-plugin/test/cases/assets/debug-info-public-path-custom/webpack.config.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/webpack/template-webpack-plugin/src/LynxTemplatePlugin.ts
  • packages/webpack/template-webpack-plugin/test/cases/assets/debug-info-public-path-custom/webpack.config.js

📝 Walkthrough

Walkthrough

Computes templateDebugUrl during encode (using intermediate/debug-info.json when output.publicPath is a non-default string), removes duplicated post-encode computation, and adds tests covering publicPath and beforeEncode hook customization.

Changes

Cohort / File(s) Summary
Changeset
​.changeset/allow-debug-url-customize.md
Adds a patch changeset documenting that templateDebugUrl can be customized via output.publicPath or the beforeEncode hook.
Plugin core
packages/webpack/template-webpack-plugin/src/LynxTemplatePlugin.ts
Moves templateDebugUrl computation into the encode path, guards on publicPath (not 'auto' or '/’), writes value into EncodeRawData.compilerOptions.templateDebugUrl, and removes duplicated post-encode logic.
Tests — publicPath case
packages/webpack/template-webpack-plugin/test/cases/assets/debug-info-public-path-custom/index.js, .../webpack.config.js, .../rspack.config.js
Adds test case with output.publicPath: "https://example.com/"; asserts .rspeedy/main/debug-info.json is emitted and tasm.json.compilerOptions.templateDebugUrl equals the expected URL.
Tests — beforeEncode hook case
packages/webpack/template-webpack-plugin/test/cases/assets/debug-info-before-encode/index.js, .../webpack.config.js, .../rspack.config.js
Adds test case using a beforeEncode hook that injects a custom compilerOptions.templateDebugUrl, and asserts the encoder payload contains the overridden URL.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • colinaaa

Poem

🐇 I nibbled code paths, hopped through the queue,
Found debug-info and stitched a URL new.
publicPath guided my jaunty little trot,
beforeEncode helped—now the debug link's got! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and specifically summarizes the main change: allowing templateDebugUrl customization via two concrete mechanisms (output.publicPath and beforeEncode hook), which is directly reflected in the changeset and implementation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/templateDebugUrl-hook

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Feb 27, 2026

Merging this PR will degrade performance by 6.25%

⚡ 2 improved benchmarks
❌ 2 regressed benchmarks
✅ 59 untouched benchmarks
⏩ 3 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
basic-performance-div-10000 484.2 ms 457.4 ms +5.85%
transform 1000 view elements 40.5 ms 43.2 ms -6.25%
basic-performance-small-css 8.2 ms 7.5 ms +8.55%
basic-performance-nest-level-100 6.7 ms 7.2 ms -5.67%

Comparing feat/templateDebugUrl-hook (817c386) with main (09929fb)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@relativeci
Copy link
Copy Markdown

relativeci bot commented Feb 27, 2026

Web Explorer

#7832 Bundle Size — 383.74KiB (0%).

817c386(current) vs 09929fb main#7815(baseline)

Bundle metrics  Change 1 change
                 Current
#7832
     Baseline
#7815
No change  Initial JS 154.88KiB 154.88KiB
No change  Initial CSS 35.06KiB 35.06KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 8 8
No change  Assets 8 8
Change  Modules 237(+0.42%) 236
No change  Duplicate Modules 16 16
No change  Duplicate Code 2.99% 2.99%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#7832
     Baseline
#7815
No change  JS 252.83KiB 252.83KiB
No change  Other 95.85KiB 95.85KiB
No change  CSS 35.06KiB 35.06KiB

Bundle analysis reportBranch feat/templateDebugUrl-hookProject dashboard


Generated by RelativeCIDocumentationReport issue

@upupming upupming changed the title feat: allow templateDebugUrl to be customized via output.publicPath feat: allow templateDebugUrl to be customized via output.publicPath or beforeEncode hook Feb 27, 2026
@upupming upupming force-pushed the feat/templateDebugUrl-hook branch from 97858df to 4450b22 Compare February 27, 2026 08:48
@upupming upupming force-pushed the feat/templateDebugUrl-hook branch from 4450b22 to 817c386 Compare February 27, 2026 08:50
@lybvinci
Copy link
Copy Markdown
Collaborator

LGTM

@colinaaa colinaaa merged commit 59f2933 into main Mar 2, 2026
78 of 81 checks passed
@colinaaa colinaaa deleted the feat/templateDebugUrl-hook branch March 2, 2026 03:40
colinaaa pushed a commit that referenced this pull request Mar 9, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @lynx-js/devtool-mcp-server@0.5.0

### Minor Changes

- Use `@lynx-js/devtool-connector` instead of
`@lynx-js/debug-router-connector`.
([#2284](#2284))

The new connector avoids using keep-alive connections, which makes the
connection much more reliable.

- **BREAKING CHANGE**: Remove the `./debug-router-connector` exports.
([#2284](#2284))

## @lynx-js/web-elements@0.12.0

### Minor Changes

- feat: add `willchange` event to `x-viewpager-ng`
([#2305](#2305))

### Patch Changes

- fix: firefox `@supports(width:1rex)`
([#2288](#2288))

- fix: check computed overflow style in `getTheMostScrollableKid` to
avoid treating `overflow: visible` elements as scroll containers
([#2309](#2309))

- fix: the inline-truncation should only work as a direct child of
x-text ([#2287](#2287))

- fix: getVisibleCells cannot work in firefox due to
contentvisibilityautostatechange not propagate list-item
([#2308](#2308))

- fix: foldview stuck issue
([#2304](#2304))

## @lynx-js/gesture-runtime@2.1.3

### Patch Changes

- Optimize gesture callbacks and relationships to prevent unnecessary
gesture registration and rerenders.
([#2277](#2277))

## @lynx-js/react@0.116.5

### Patch Changes

- Improve React runtime hook profiling.
([#2235](#2235))
Enable Profiling recording first, then enter the target page so the
trace includes full render/hydrate phases.

- Record trace events for `useEffect` / `useLayoutEffect` hook entry,
callback, and cleanup phases.
    -   Log trace events for `useState` setter calls.
- Wire `profileFlowId` support in debug profile utilities and attach
flow IDs to related hook traces.
- Instrument hydrate/background snapshot profiling around patch
operations with richer args (e.g. snapshot id/type, dynamic part index,
value type, and source when available).
- Capture vnode source mapping in dev and use it in profiling args to
improve trace attribution.
- Expand debug test coverage for profile utilities, hook profiling
behavior, vnode source mapping, and hydrate profiling branches.

- refactor: call loadWorkletRuntime once in each module
([#2315](#2315))

## @lynx-js/rspeedy@0.13.5

### Patch Changes

- feat: opt-in the web platform's new binary output format
([#2281](#2281))

    Introduce a new flag to enable the new binary output format.

Currently it's an internal-use-only flag that will be removed in the
future; set the corresponding environment variable to 'true' to enable
it.

- Avoid generating `Rsbuild vundefined` in greeting message.
([#2275](#2275))

-   Updated dependencies \[]:
    -   @lynx-js/web-rsbuild-server-middleware@0.19.8

## @lynx-js/lynx-bundle-rslib-config@0.2.2

### Patch Changes

- Support bundle and load css in external bundle
([#2143](#2143))

## @lynx-js/external-bundle-rsbuild-plugin@0.0.3

### Patch Changes

- Updated dependencies
\[[`c28b051`](c28b051),
[`4cbf809`](4cbf809)]:
    -   @lynx-js/externals-loading-webpack-plugin@0.0.4

## @lynx-js/react-rsbuild-plugin@0.12.10

### Patch Changes

- Support bundle and load css in external bundle
([#2143](#2143))

- Updated dependencies
\[[`59f2933`](59f2933),
[`453e006`](453e006)]:
    -   @lynx-js/template-webpack-plugin@0.10.5
    -   @lynx-js/css-extract-webpack-plugin@0.7.0
    -   @lynx-js/react-webpack-plugin@0.7.4
    -   @lynx-js/react-alias-rsbuild-plugin@0.12.10
    -   @lynx-js/use-sync-external-store@1.5.0
    -   @lynx-js/react-refresh-webpack-plugin@0.3.4

## @lynx-js/web-core-wasm@0.0.5

### Patch Changes

- Updated dependencies
\[[`4963907`](4963907),
[`8fd936a`](8fd936a),
[`0d41253`](0d41253),
[`d32c4c6`](d32c4c6),
[`7518b72`](7518b72),
[`fca9d4a`](fca9d4a)]:
    -   @lynx-js/web-elements@0.12.0

## @lynx-js/externals-loading-webpack-plugin@0.0.4

### Patch Changes

- perf: optimize external bundle loading by merging multiple
`fetchBundle` calls for the same URL into a single request.
([#2307](#2307))

- Support bundle and load css in external bundle
([#2143](#2143))

## @lynx-js/template-webpack-plugin@0.10.5

### Patch Changes

- feat: allow `templateDebugUrl` to be customized via
`output.publicPath` or the `beforeEncode` hook.
([#2274](#2274))

- feat: opt-in the web platform's new binary output format
([#2281](#2281))

    Introduce a new flag to enable the new binary output format.

Currently it's an internal-use-only flag that will be removed in the
future; set the corresponding environment variable to 'true' to enable
it.

-   Updated dependencies \[]:
    -   @lynx-js/web-core-wasm@0.0.5

## create-rspeedy@0.13.5



## @lynx-js/react-alias-rsbuild-plugin@0.12.10



## upgrade-rspeedy@0.13.5

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants