Skip to content

👷 Fix @effectionx/inline wasm plugin build#219

Merged
taras merged 1 commit into
mainfrom
fix/inline-swc-wasm-build
Jun 10, 2026
Merged

👷 Fix @effectionx/inline wasm plugin build#219
taras merged 1 commit into
mainfrom
fix/inline-swc-wasm-build

Conversation

@taras

@taras taras commented Jun 10, 2026

Copy link
Copy Markdown
Member

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): compiling swc-plugin-inline
to wasm32-wasip1 fails to link under current Rust:

rust-lld: error: undefined symbol: __emit_diagnostics
rust-lld: error: undefined symbol: __set_transform_result
rust-lld: error: undefined symbol: __add_leading_comment_proxy
…

Those __* / *_proxy symbols are the SWC host ABI functions an SWC wasm
plugin imports from its runtime host — they are meant to stay as undefined
imports in the .wasm. Newer rust-lld/wasm-ld no longer leaves undefined
symbols as imports by default, so the release link errors.

There were actually two problems:

  1. The link needs -C link-arg=--allow-undefined to keep the host-ABI symbols
    as imports.
  2. The crate's cargo config (inline/swc/.cargo/config.toml) was never being
    applied. build:bundle runs cargo from inline/
    (cargo build --manifest-path swc/Cargo.toml …), and cargo discovers
    .cargo/config.toml relative 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 is
discovered from the directory build:bundle runs in, and add the
--allow-undefined link arg:

[target.'cfg(target_arch = "wasm32")']
rustflags = ["--cfg=swc_ast_unknown", "-C", "link-arg=--allow-undefined"]

This makes both the existing swc_ast_unknown cfg and the new link arg take
effect. A comment documents why the file must live at inline/.cargo rather than
next to the crate.

Verification (local)

  • rustup stable 1.96.0 (newer than CI's toolchain) + wasm32-wasip1:
    • pnpm --filter @effectionx/inline run build:bundle — links cleanly, emits
      swc_plugin_inline.wasm. Reproduced the original failure first, then
      confirmed the fix via the exact CI invocation.
    • pnpm build — full tsc --build + turbo run build:bundle green.
    • node --env-file=.env --test "inline/*.test.ts"32/32 pass, including
      swc.test.ts, which loads and runs the built wasm plugin.

Scoped entirely to inline/; no workflow or other-package changes. Unblocks the
Build step on #218.

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.
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@taras, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 956d804d-dbed-4b80-bde5-eaade67880e2

📥 Commits

Reviewing files that changed from the base of the PR and between 6982b1c and 22f4162.

📒 Files selected for processing (2)
  • inline/.cargo/config.toml
  • inline/swc/.cargo/config.toml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/inline-swc-wasm-build

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.

@pkg-pr-new

pkg-pr-new Bot commented Jun 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@effectionx/inline@219

commit: 22f4162

@taras taras merged commit 2449c08 into main Jun 10, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants