Skip to content

fix(nodejs): complete Amaro REPL support APIs - #12395

Merged
Donny/강동윤 (kdy1) merged 3 commits into
mainfrom
kdy1/fix-nodejs-support-12378
Sep 21, 2026
Merged

Donny/강동윤 (kdy1) merged 3 commits into
mainfrom
kdy1/fix-nodejs-support-12378

Conversation

@kdy1

Copy link
Copy Markdown
Member

Description:

Complete the four Node.js/Amaro support requests in @swc/nodejs-support-wasm. An input such as import fs from "node:fs" now declares fs, so later REPL inputs can use it. Static imports use local declarations instead of rewriting references within a single input; existing import hoisting, export validation, and import attributes are preserved.

Add tokenize for compact highlighting tokens and findTopLevelAwaits for module-scope await locations, including for await and await using. Both support strings and UTF-8 Uint8Array inputs, with JavaScript UTF-16 coordinates. Also recognize SyntaxError::Unexpected with <eof> as recoverable. Include TypeScript declarations, documentation, shared Rust/WASM fixtures, and executable REPL coverage.

BREAKING CHANGE:

In @swc/nodejs-support-wasm, transformed default and named imports now capture initial export values in local const bindings rather than rewriting reads into live namespace property accesses. Namespace imports retain the module namespace object. This matches the requested REPL behavior.

Validation:

  • cargo fmt --all
  • cargo clippy --all --all-targets -- -D warnings
  • cargo test -p binding_nodejs_support_wasm: 20 passed
  • Node.js support WASM test script: 57 passed in both default and nightly feature builds
  • Core, minifier, TypeScript, and AST viewer WASM test scripts: all passed
  • packages/core: pnpm build:dev and pnpm test; 119 passed, 3 skipped by the existing configuration
  • Checked 525 incremental REPL input prefixes for valid, non-overlapping token ranges

Rust commands ran with RUSTC_WRAPPER= because the configured sccache executable is unavailable locally.

Related issue (if exists):

Closes #12378.

@kdy1
Donny/강동윤 (kdy1) requested a review from a team as a code owner September 20, 2026 01:26
kodiakhq[bot]
kodiakhq Bot previously approved these changes Sep 20, 2026
@changeset-bot

changeset-bot Bot commented Sep 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2aa0242

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

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-20T05:59:18.606574Z 3807725 New commits
🔒 Security Review ✅ Completed 2026-09-20T06:01:32.318854Z 3807725 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2aa02422b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment on lines +469 to +472
Some(format!(
"const {{ {} }} = await {import};",
bindings.join(", ")
))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid shadowing the dynamic-import helper

When a valid import binds the name __nodeREPLDynamicImport, such as import { x as __nodeREPLDynamicImport } from "m", this emits const { x: __nodeREPLDynamicImport } = await __nodeREPLDynamicImport(...). The newly declared lexical binding shadows the caller-supplied helper while its initializer is evaluated, so the transformed input fails instead of importing the value. Preserve access to the helper through a collision-free temporary before declaring user bindings.

Useful? React with 👍 / 👎.

Comment thread bindings/binding_nodejs_support_wasm/src/nodejs/awaits.rs Outdated
@codspeed

codspeed Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 200 untouched benchmarks
⏩ 67 skipped benchmarks1


Comparing kdy1/fix-nodejs-support-12378 (3807725) with main (3c381f4)

Open in CodSpeed

Footnotes

  1. 67 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. ↩

@kdy1
Donny/강동윤 (kdy1) merged commit 4b42cd5 into main Sep 21, 2026
200 checks passed
@kdy1
Donny/강동윤 (kdy1) deleted the kdy1/fix-nodejs-support-12378 branch September 21, 2026 01:33
@github-actions github-actions Bot added this to the Planned milestone Sep 21, 2026
@github-actions github-actions Bot modified the milestones: Planned, v1.16.12 Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Node.js Amaro Features

1 participant