Open
Conversation
7d45153 to
3cb114a
Compare
…world loads Compile the existing Rust SWC transforms into a standalone browser WASM module that replaces Babel for in-browser module transpilation. Falls back to Babel automatically if WASM loading fails. Cargo workspace with 3 crates sharing transform code: - lively-swc-transforms: shared library (7 AST visitors) - lively-swc-plugin: existing server-side plugin (wasm32-wasip1) - lively-swc-browser: new browser WASM entry (wasm32-unknown-unknown) JS integration layer (lively.source-transform/swc/): - browser-transform.js: WASM loader + transform wrapper - transpiler-setup.js: SystemJS registration, config mapping, Babel fallback Key post-processing passes for Babel-compatible System.register output: - Hoist recorder init, rewrite setters with defVar/default params - Fix system_js bugs: async execute, shadowed export calls, nested fn export leaking (let/const shadowing exported names) - Export alias desugaring (__export_X__ prefix) to prevent system_js hoisting Performance (176 modules, 0 Babel fallbacks, 0 errors): - SWC: 34s total load, 3.1s transpile - Babel: 46s total load - ~1.3x faster overall, ~5x faster transpilation
3cb114a to
4cb17d3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fastLoad=falseworld loadsPerformance
Architecture
Cargo workspace (3 crates sharing transform code):
lively-swc-transforms/— shared library (7 AST visitors, ~4000 lines)lively-swc-plugin/— existing server-side SWC plugin (wasm32-wasip1)lively-swc-browser/— new browser WASM entry point (wasm32-unknown-unknown)JS integration (
lively.source-transform/swc/):browser-transform.js— WASM loader + transform wrappertranspiler-setup.js— SystemJS transpiler registration, config mapping, Babel fallbackKey post-processing passes (Phase 3 in
lib.rs):fix_async_execute— strips spuriousasyncfromexecute()hoist_recorder_init— moves recorder init fromexecute()to factory bodyrewrite_setters— addsdefVarwrapper + default params to SystemJS settersfix_nested_fn_export_calls— strips_export()inside nested functions where the export name is shadowed by a locallet/const(SWC system_js scoping bug workaround)strip/restore_export_aliases—export { Y as a }→__export_a__desugaring to prevent system_js hoistingTest plan
cargo build --target wasm32-unknown-unknown -p lively-swc-browsercompilescargo build --target wasm32-wasip1 -p lively-swc-pluginstill workshttp://localhost:9011/projects/load?name=__newProject__&fastLoad=falsewith 0 errors?babelOnlyflag falls back to Babel correctly🤖 Generated with Claude Code