Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/moody-snakes-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@lynx-js/rspeedy": patch
Comment thread
PupilTong marked this conversation as resolved.
Comment thread
PupilTong marked this conversation as resolved.
"@lynx-js/template-webpack-plugin": patch
---

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

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.
2 changes: 1 addition & 1 deletion packages/webpack/template-webpack-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"dependencies": {
"@lynx-js/css-serializer": "workspace:*",
"@lynx-js/tasm": "0.0.20",
"@lynx-js/web-core-wasm": "workspace:*",
"@lynx-js/webpack-runtime-globals": "workspace:^",
"@rspack/lite-tapable": "1.1.0",
"css-tree": "^3.1.0",
Expand All @@ -46,7 +47,6 @@
"devDependencies": {
"@lynx-js/test-tools": "workspace:*",
"@lynx-js/vitest-setup": "workspace:*",
"@lynx-js/web-core-wasm": "workspace:*",
"@microsoft/api-extractor": "catalog:",
"@types/css-tree": "^2.3.11",
"@types/object.groupby": "^1.0.4",
Expand Down
20 changes: 9 additions & 11 deletions packages/webpack/template-webpack-plugin/src/WebEncodePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,15 @@ export class WebEncodePlugin {
customSections: encodeOptions.customSections ?? {},
elementTemplates: encodeOptions['elementTemplates'] ?? {},
};
const isExperimentalWebBinary = !!process
const isExperimentalWebBinary = process
.env['EXPERIMENTAL_USE_WEB_BINARY_TEMPLATE'];
if (isExperimentalWebBinary) {
const { encode } = await import('@lynx-js/web-core-wasm/encode')
.catch(
() => {
throw new Error(
`FLAG EXPERIMENTAL_USE_WEB_BINARY_TEMPLATE IS INTERNAL USED ONLY`,
);
},
);
if (isExperimentalWebBinary === 'true') {
Comment thread
PupilTong marked this conversation as resolved.
const { encode } = await import('@lynx-js/web-core-wasm/encode');
return {
buffer: Buffer.from(encode(tasmJSONInfo as TasmJSONInfo)),
debugInfo: '',
};
} else {
} else if (isExperimentalWebBinary == null /*undefined or null */) {
return {
buffer: Buffer.from(
JSON.stringify({
Expand All @@ -133,6 +126,11 @@ export class WebEncodePlugin {
),
debugInfo: '',
};
} else {
// only allow 'true' or undefined/null
throw new Error(
`Unknown value of EXPERIMENTAL_USE_WEB_BINARY_TEMPLATE: ${isExperimentalWebBinary}. Expecting "true" or undefined.`,
);
}
});
},
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading