Skip to content

Comments

fix: rename __export to __exportAll to be compatible with cjs-module-lexer#7640

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-24-fix_module-lexer
Dec 24, 2025
Merged

fix: rename __export to __exportAll to be compatible with cjs-module-lexer#7640
graphite-app[bot] merged 1 commit intomainfrom
12-24-fix_module-lexer

Conversation

@IWANABETHATGUY
Copy link
Member

@IWANABETHATGUY IWANABETHATGUY commented Dec 24, 2025

Closes #7634

Rename __export to __exportAll to ensure compatibility with cjs-module-lexer versions older than 2.1.1 (which covers most Node.js versions).

cjs-module-lexer has special handling for __export (a pattern used by TypeScript). Since it uses pattern matching to detect exports, it fails to parse __export when there is only one argument (e.g., __export({ ... })), expecting the form __export(exports, { ... }) instead.

By using a different name, we avoid triggering this faulty heuristic entirely.

Background:
why we change the __export runtime helper

  1. refactor: simplify __export runtime helper to create target object internally #6114
  2. feat: mark __export runtime helper as pure #5926

Copy link
Member Author

IWANABETHATGUY commented Dec 24, 2025


How to use the Graphite Merge Queue

Add the label graphite: merge-when-ready to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@IWANABETHATGUY IWANABETHATGUY changed the title fix: module-lexer fix: rename __export to __exportAll to be compatible with cjs-module-lexer Dec 24, 2025
@netlify
Copy link

netlify bot commented Dec 24, 2025

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 271bba4
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/694b7ffcc23e000007d2165b

@IWANABETHATGUY IWANABETHATGUY marked this pull request as ready for review December 24, 2025 05:20
Copilot AI review requested due to automatic review settings December 24, 2025 05:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR renames the runtime helper function __export to __exportAll to be compatible with cjs-module-lexer, which is used by Node.js to analyze CommonJS modules.

Key Changes

  • Runtime helper __export renamed to __exportAll in runtime-base.js and runtime-extra-dev-common.js
  • Rust enum RuntimeHelper::Export renamed to RuntimeHelper::ExportAll in generated runtime_helper.rs
  • All Rust code references updated to use the new __exportAll name
  • Test snapshots regenerated to reflect the renamed function

Reviewed changes

Copilot reviewed 129 out of 131 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/rolldown_plugin_hmr/src/runtime/runtime-extra-dev-common.js Updated import and property assignment from __export to __exportAll
crates/rolldown_common/src/generated/runtime_helper.rs Renamed enum variant and constant from Export to ExportAll
crates/rolldown/src/runtime/runtime-base.js Renamed function from __export to __exportAll
crates/rolldown/src/stages/link_stage/create_exports_for_ecma_modules.rs Updated runtime symbol resolution call
crates/rolldown/src/stages/generate_stage/chunk_optimizer.rs Updated comments and helper references
crates/rolldown/src/module_finalizers/mod.rs Updated comments and symbol resolution calls
crates/rolldown/src/hmr/hmr_ast_finalizer.rs Updated runtime property access and comments
test snapshots (126 files) Regenerated snapshots showing __exportAll instead of __export in generated code
Files not reviewed (1)
  • crates/rolldown/tests/rolldown/function/advanced_chunks/split_node_modules/artifacts.snap: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 24, 2025

Benchmarks Rust

group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     63.1±1.56ms        ? ?/sec    1.01     63.9±2.09ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     69.6±2.55ms        ? ?/sec    1.00     69.8±1.91ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    106.4±1.88ms        ? ?/sec    1.01    107.7±1.93ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    119.2±2.58ms        ? ?/sec    1.00    119.7±2.19ms        ? ?/sec
bundle/bundle@threejs                                        1.00     39.4±2.25ms        ? ?/sec    1.00     39.5±1.04ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     43.1±1.06ms        ? ?/sec    1.00     43.0±1.17ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    389.5±5.31ms        ? ?/sec    1.00    388.9±6.22ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    449.5±4.97ms        ? ?/sec    1.00    448.4±4.96ms        ? ?/sec
scan/scan@rome_ts                                            1.00     84.6±2.35ms        ? ?/sec    1.00     84.6±1.72ms        ? ?/sec
scan/scan@threejs                                            1.02     28.9±1.85ms        ? ?/sec    1.00     28.4±0.47ms        ? ?/sec
scan/scan@threejs10x                                         1.00    293.4±4.52ms        ? ?/sec    1.00    292.4±4.07ms        ? ?/sec

@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 24, 2025

Merge activity

…dule-lexer` (#7640)

Closes #7634

Rename `__export` to `__exportAll` to ensure compatibility with `cjs-module-lexer` versions older than 2.1.1 (which covers most Node.js versions).

`cjs-module-lexer` has special handling for `__export` (a pattern used by TypeScript). Since it uses pattern matching to detect exports, it fails to parse `__export` when there is only one argument (e.g., `__export({ ... })`), expecting the form `__export(exports, { ... })` instead.

By using a different name, we avoid triggering this faulty heuristic entirely.

Background:
why we change the `__export` runtime helper
1. #6114
2. #5926
@graphite-app graphite-app bot force-pushed the 12-24-fix_module-lexer branch from 60d105e to 271bba4 Compare December 24, 2025 05:54
@graphite-app graphite-app bot merged commit 271bba4 into main Dec 24, 2025
33 checks passed
@graphite-app graphite-app bot deleted the 12-24-fix_module-lexer branch December 24, 2025 06:03
shulaoda added a commit that referenced this pull request Dec 24, 2025
## [1.0.0-beta.57] - 2025-12-24

✨ TypeScript Project References Support
- Rolldown now supports TypeScript project references when manually specifying a `tsconfig`
- See more details: https://rolldown.rs/options/tsconfig

💥 Rename `__export` to `__exportAll`
- Update `rolldown-plugin-dts` to the latest version for compatibility

### 💥 BREAKING CHANGES

- tsconfig: enable project references support in manual mode (#7545) by @shulaoda

### 🚀 Features

- add `CANNOT_CALL_NAMESPACE` warning (#7636) by @sapphi-red
- add import path for unresolved import diagnostics (#7625) by @sapphi-red
- optimize dynamic entry facade chunks by merging with common chunks when they are captured by common chunks (#7486) by @IWANABETHATGUY

### 🐛 Bug Fixes

- rename `__export` to `__exportAll` to be compatible with `cjs-module-lexer` (#7640) by @IWANABETHATGUY
- strip UTF-8 BOM when using text loader (#7635) by @sapphi-red
- rolldown_plugin_replace: avoid crashing with invalid delimiters (#7621) by @sapphi-red

### 🚜 Refactor

- export all filter functions (#7622) by @sxzz
- allow multiple help messages in diagnostics (#7624) by @sapphi-red

### 📚 Documentation

- add README.md to packages/rolldown (#7556) by @Copilot

### ⚡ Performance

- use fsevents on macOS for file watching (#7596) by @sapphi-red

### 🧪 Testing

- handle re-exports of external modules in CJS format (#7641) by @IWANABETHATGUY
- update integration to use vite's rolldown-canary branch (#7633) by @shulaoda

### ⚙️ Miscellaneous Tasks

- docs: fix Netlify ignore condition to detect docs changes across all PR commits (#7637) by @Copilot
- deps: update rollup submodule for tests to v4.54.0 (#7630) by @sapphi-red
- skip benchmarks for PRs with 'graphite: merge-when-ready' label (#7631) by @Boshen
- deps: update esbuild for tests to 0.27.2 (#7629) by @sapphi-red
- fix "update-test-dependencies" workflow (#7628) by @sapphi-red
- deps: update test262 submodule for tests (#7626) by @sapphi-red
- deps: update dependency oxlint to v1.35.0 (#7623) by @renovate[bot]

Co-authored-by: shulaoda <[email protected]>
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.

[Bug] __export function breaking ES module imports

2 participants