👷 Fix @effectionx/inline wasm plugin build#219
Conversation
The swc-plugin-inline release build failed to link on current Rust: `rust-lld: undefined symbol: __emit_diagnostics` (and the other SWC host-ABI `__*_proxy` imports). Newer wasm-ld no longer leaves these undefined symbols as imports by default, so the link needs `-C link-arg=--allow-undefined`. The cargo config that carries the plugin's rustflags lived at inline/swc/.cargo/config.toml, but `build:bundle` runs cargo from inline/ (`--manifest-path swc/Cargo.toml`) and cargo discovers config relative to the working directory — so those rustflags (including the pre-existing `--cfg=swc_ast_unknown`) were silently ignored in CI. Move the config to inline/.cargo/config.toml so it is actually applied, and add the `--allow-undefined` link arg. Unblocks CI on PR #218.
|
Warning Review limit reached
More reviews will be available in 48 minutes and 19 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
commit: |
Motivation
CI is red at the Build step on PRs (e.g. #218) — not in tests. The failure
is
@effectionx/inline#build:bundle(exit 101): compilingswc-plugin-inlineto
wasm32-wasip1fails to link under current Rust:Those
__*/*_proxysymbols are the SWC host ABI functions an SWC wasmplugin imports from its runtime host — they are meant to stay as undefined
imports in the
.wasm. Newerrust-lld/wasm-ldno longer leaves undefinedsymbols as imports by default, so the release link errors.
There were actually two problems:
-C link-arg=--allow-undefinedto keep the host-ABI symbolsas imports.
inline/swc/.cargo/config.toml) was never beingapplied.
build:bundleruns cargo frominline/(
cargo build --manifest-path swc/Cargo.toml …), and cargo discovers.cargo/config.tomlrelative to the working directory, not the manifest.So the rustflags there — including the pre-existing
--cfg=swc_ast_unknown—were silently ignored in CI.
Approach
Move the cargo config to the package root,
inline/.cargo/config.toml, so it isdiscovered from the directory
build:bundleruns in, and add the--allow-undefinedlink arg:This makes both the existing
swc_ast_unknowncfg and the new link arg takeeffect. A comment documents why the file must live at
inline/.cargorather thannext to the crate.
Verification (local)
rustupstable 1.96.0 (newer than CI's toolchain) +wasm32-wasip1:pnpm --filter @effectionx/inline run build:bundle— links cleanly, emitsswc_plugin_inline.wasm. Reproduced the original failure first, thenconfirmed the fix via the exact CI invocation.
pnpm build— fulltsc --build+turbo run build:bundlegreen.node --env-file=.env --test "inline/*.test.ts"— 32/32 pass, includingswc.test.ts, which loads and runs the built wasm plugin.Scoped entirely to
inline/; no workflow or other-package changes. Unblocks theBuild step on #218.