Skip to content

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

Merged
PupilTong merged 8 commits intolynx-family:mainfrom
PupilTong:p/hw/opt-in-wasm
Mar 3, 2026
Merged

feat: opt-in the web platform's new binary output format#2281
PupilTong merged 8 commits intolynx-family:mainfrom
PupilTong:p/hw/opt-in-wasm

Conversation

@PupilTong
Copy link
Copy Markdown
Collaborator

@PupilTong PupilTong commented Mar 2, 2026

Summary by CodeRabbit

  • New Features

    • Added an opt-in feature flag for the web platform's new binary output format (internal-use-only; may be removed later). Enable by setting the environment variable to the string "true".
  • Behavior Changes

    • The flag activates the binary format only when set exactly to "true"; leaving it unset returns the regular JSON payload.
  • Bug Fixes

    • Improved user-facing error message for invalid flag values.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
  • Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 2, 2026

🦋 Changeset detected

Latest commit: 9b9e4d4

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

This PR includes changesets to release 6 packages
Name Type
@lynx-js/rspeedy Patch
@lynx-js/template-webpack-plugin Patch
create-rspeedy Patch
@lynx-js/react-rsbuild-plugin Patch
upgrade-rspeedy 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

@PupilTong PupilTong marked this pull request as ready for review March 2, 2026 05:39
Copilot AI review requested due to automatic review settings March 2, 2026 05:39
@PupilTong PupilTong requested a review from luhc228 as a code owner March 2, 2026 05:39
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 2, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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 110a027 and 9b9e4d4.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • .changeset/moody-snakes-study.md
  • packages/webpack/template-webpack-plugin/package.json
  • packages/webpack/template-webpack-plugin/src/WebEncodePlugin.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/moody-snakes-study.md

📝 Walkthrough

Walkthrough

Adds a changeset for an opt-in web binary output flag, moves @lynx-js/web-core-wasm to runtime dependencies in the webpack plugin, and tightens EXPERIMENTAL_USE_WEB_BINARY_TEMPLATE handling and error messages in WebEncodePlugin.

Changes

Cohort / File(s) Summary
Changeset Documentation
\.changeset/moody-snakes-study.md
Adds a new changeset documenting an opt-in feature flag (EXPERIMENTAL_USE_WEB_BINARY_TEMPLATE) for the web binary output format and patch bumps for affected packages.
Dependency Management
packages/webpack/template-webpack-plugin/package.json
Moves @lynx-js/web-core-wasm from devDependencies to dependencies (runtime dependency).
Binary Output Logic
packages/webpack/template-webpack-plugin/src/WebEncodePlugin.ts
Changes flag handling to accept only the string 'true' for binary output (dynamic import of @lynx-js/web-core-wasm/encode), return JSON when unset, and throw on any other value; removes previous catch-based import handling and updates error text.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • upupming
  • luhc228
  • Sherry-hue

Poem

🐇 I nibble flags beneath the glowing screen,
A tiny opt-in path where binary dreams preen,
Wasm hops to runtime on a careful cue,
Only "true" may lead the tunnel through,
Templates hum softly — a rabbit's tidy scene.

🚥 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 title accurately summarizes the main change: introducing an opt-in feature for the web platform's new binary output format, which is directly reflected in the changeset, package.json dependency reorganization, and WebEncodePlugin modifications.
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 unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 Mar 2, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ack/template-webpack-plugin/src/WebEncodePlugin.ts 50.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-in path for generating the web platform’s new binary template output by gating a WASM-based encoder behind an environment flag, and updates packaging/release metadata to ship the capability.

Changes:

  • Gate WebEncodePlugin output format selection behind EXPERIMENTAL_USE_WEB_BINARY_TEMPLATE === 'true' and encode via @lynx-js/web-core-wasm/encode when enabled.
  • Move @lynx-js/web-core-wasm from devDependencies to dependencies for runtime/type availability.
  • Add a Changesets entry describing the feature flag.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
packages/webpack/template-webpack-plugin/src/WebEncodePlugin.ts Adds env-flag-controlled binary encoding path using WASM encoder and updates error text.
packages/webpack/template-webpack-plugin/package.json Promotes @lynx-js/web-core-wasm to a runtime dependency.
.changeset/moody-snakes-study.md Adds release note describing the new opt-in binary output flag.
Comments suppressed due to low confidence (1)

packages/webpack/template-webpack-plugin/src/WebEncodePlugin.ts:120

  • This introduces/changes behavior behind EXPERIMENTAL_USE_WEB_BINARY_TEMPLATE, but there is no test exercising the binary-encode path. Add a test case that sets the env var and asserts the emitted template payload is binary (and/or that wasm encode is invoked).
          const isExperimentalWebBinary = process
            .env['EXPERIMENTAL_USE_WEB_BINARY_TEMPLATE'];
          if (isExperimentalWebBinary === 'true') {
            const { encode } = await import('@lynx-js/web-core-wasm/encode')
              .catch(
                () => {
                  throw new Error(
                    `cannot enable the flat EXPERIMENTAL_USE_WEB_BINARY_TEMPLATE, please contact developers`,
                  );
                },
              );
            return {
              buffer: Buffer.from(encode(tasmJSONInfo as TasmJSONInfo)),
              debugInfo: '',
            };
          } else {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/moody-snakes-study.md:
- Line 9: Replace the incorrect phrase "a internal use only flag" with the
corrected, hyphenated form "an internal-use-only flag" in the
.changeset/moody-snakes-study.md content (search for the exact string "a
internal use only flag" to locate the sentence), ensuring the surrounding
sentence remains grammatically correct and unchanged otherwise.

In `@packages/webpack/template-webpack-plugin/src/WebEncodePlugin.ts`:
- Line 112: The error message string in WebEncodePlugin referencing
"EXPERIMENTAL_USE_WEB_BINARY_TEMPLATE" contains a typo: replace the word "flat"
with "flag" in the message string (the literal that currently reads `cannot
enable the flat EXPERIMENTAL_USE_WEB_BINARY_TEMPLATE, please contact
developers`) inside the WebEncodePlugin implementation so the message reads
`cannot enable the flag EXPERIMENTAL_USE_WEB_BINARY_TEMPLATE, please contact
developers`.

ℹ️ 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 6caf9e0 and 7f57ac9.

📒 Files selected for processing (3)
  • .changeset/moody-snakes-study.md
  • packages/webpack/template-webpack-plugin/package.json
  • packages/webpack/template-webpack-plugin/src/WebEncodePlugin.ts

@PupilTong PupilTong self-assigned this Mar 2, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 2, 2026

Merging this PR will degrade performance by 8.46%

❌ 1 regressed benchmark
✅ 71 untouched benchmarks
⏩ 3 skipped benchmarks1

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

Performance Changes

Benchmark BASE HEAD Efficiency
basic-performance-div-100 6.8 ms 7.4 ms -8.46%

Comparing PupilTong:p/hw/opt-in-wasm (9b9e4d4) with main (d32c4c6)

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 Mar 2, 2026

Web Explorer

#7918 Bundle Size — 383.53KiB (0%).

9b9e4d4(current) vs d32c4c6 main#7915(baseline)

Bundle metrics  Change 1 change
                 Current
#7918
     Baseline
#7915
No change  Initial JS 154.63KiB 154.63KiB
No change  Initial CSS 35.1KiB 35.1KiB
Change  Cache Invalidation 0% 49.49%
No change  Chunks 8 8
No change  Assets 8 8
Change  Modules 238(-0.42%) 239
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
#7918
     Baseline
#7915
No change  JS 252.58KiB 252.58KiB
No change  Other 95.85KiB 95.85KiB
No change  CSS 35.1KiB 35.1KiB

Bundle analysis reportBranch PupilTong:p/hw/opt-in-wasmProject dashboard


Generated by RelativeCIDocumentationReport issue

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/webpack/template-webpack-plugin/src/WebEncodePlugin.ts (1)

113-133: ⚠️ Potential issue | 🟡 Minor

Align accepted-value wording with the actual condition.

Line 113 treats both null and undefined as fallback, but Line 132 says only undefined is accepted. Please make the condition/comment/error text consistent to avoid config confusion.

Suggested consistency patch
-          } else if (isExperimentalWebBinary == null /*undefined or null */) {
+          } else if (isExperimentalWebBinary == null /* undefined or null */) {
@@
-            // only allow 'true' or undefined/null
+            // only allow 'true' or undefined/null
             throw new Error(
-              `Unknown value of EXPERIMENTAL_USE_WEB_BINARY_TEMPLATE: ${isExperimentalWebBinary}. Expecting "true" or undefined.`,
+              `Unknown value of EXPERIMENTAL_USE_WEB_BINARY_TEMPLATE: ${isExperimentalWebBinary}. Expecting "true", undefined, or null.`,
             );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/webpack/template-webpack-plugin/src/WebEncodePlugin.ts` around lines
113 - 133, The code treats both null and undefined as the fallback
(isExperimentalWebBinary == null) but the thrown error only mentions undefined;
update the messaging to match the condition: in the block that throws the Error
referencing isExperimentalWebBinary (and related comment above the branch), make
the wording consistently state that only 'true' or null/undefined are allowed
(e.g., "Expecting 'true' or undefined/null"), or alternatively change the
condition to only accept undefined if you prefer that policy; update the comment
and the Error text so both reflect the same allowed values for
isExperimentalWebBinary (refer to isExperimentalWebBinary, genStyleInfo, and
tasmJSONInfo in WebEncodePlugin.ts).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/webpack/template-webpack-plugin/src/WebEncodePlugin.ts`:
- Around line 113-133: The code treats both null and undefined as the fallback
(isExperimentalWebBinary == null) but the thrown error only mentions undefined;
update the messaging to match the condition: in the block that throws the Error
referencing isExperimentalWebBinary (and related comment above the branch), make
the wording consistently state that only 'true' or null/undefined are allowed
(e.g., "Expecting 'true' or undefined/null"), or alternatively change the
condition to only accept undefined if you prefer that policy; update the comment
and the Error text so both reflect the same allowed values for
isExperimentalWebBinary (refer to isExperimentalWebBinary, genStyleInfo, and
tasmJSONInfo in WebEncodePlugin.ts).

ℹ️ 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 e79fd99 and 110a027.

📒 Files selected for processing (1)
  • packages/webpack/template-webpack-plugin/src/WebEncodePlugin.ts

PupilTong and others added 8 commits March 3, 2026 15:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Haoyang Wang <12288479+PupilTong@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Haoyang Wang <12288479+PupilTong@users.noreply.github.com>
…codePlugin` to ensure it is `true` or `null`/`undefined`.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Haoyang Wang <12288479+PupilTong@users.noreply.github.com>
Co-authored-by: Qingyu Wang <40660121+colinaaa@users.noreply.github.com>
Signed-off-by: Haoyang Wang <12288479+PupilTong@users.noreply.github.com>
@PupilTong PupilTong merged commit 453e006 into lynx-family:main Mar 3, 2026
45 of 48 checks passed
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