Skip to content

Comments

feat: mark __export runtime helper as pure#5926

Merged
IWANABETHATGUY merged 1 commit intomainfrom
08-27-feat_mark___export_runtime_helper_as_pure
Aug 27, 2025
Merged

feat: mark __export runtime helper as pure#5926
IWANABETHATGUY merged 1 commit intomainfrom
08-27-feat_mark___export_runtime_helper_as_pure

Conversation

@IWANABETHATGUY
Copy link
Member

@IWANABETHATGUY IWANABETHATGUY commented Aug 27, 2025

__export​ just like __esm​ it only take effects when the export object are used, so mark it as pure​ could reduce the output size in some scenario see #5923 as an example

@IWANABETHATGUY IWANABETHATGUY marked this pull request as ready for review August 27, 2025 04:22
Copy link
Member Author

IWANABETHATGUY commented Aug 27, 2025

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

@netlify
Copy link

netlify bot commented Aug 27, 2025

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 46b30d4
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/68ae88b430a9420008f9ccc3

@IWANABETHATGUY IWANABETHATGUY force-pushed the 08-27-feat_mark___export_runtime_helper_as_pure branch from cb65567 to 46b30d4 Compare August 27, 2025 04:25
@IWANABETHATGUY IWANABETHATGUY added this pull request to the merge queue Aug 27, 2025
Merged via the queue into main with commit 9dcb0e5 Aug 27, 2025
23 checks passed
@IWANABETHATGUY IWANABETHATGUY deleted the 08-27-feat_mark___export_runtime_helper_as_pure branch August 27, 2025 04:39
@github-actions
Copy link
Contributor

Benchmarks Rust

  • target: main(28e8702)
  • pr: 08-27-feat_mark___export_runtime_helper_as_pure(46b30d4)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     85.1±2.80ms        ? ?/sec    1.00     84.9±4.96ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     94.7±3.55ms        ? ?/sec    1.00     94.6±3.71ms        ? ?/sec
bundle/bundle@rome_ts                                        1.01    123.9±3.04ms        ? ?/sec    1.00    123.2±2.37ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    143.8±2.63ms        ? ?/sec    1.01    145.1±3.03ms        ? ?/sec
bundle/bundle@threejs                                        1.02     47.0±1.99ms        ? ?/sec    1.00     46.2±2.66ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.02     56.5±2.74ms        ? ?/sec    1.00     55.2±1.41ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    477.9±8.88ms        ? ?/sec    1.01   482.0±11.82ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    562.3±7.53ms        ? ?/sec    1.00   563.7±10.92ms        ? ?/sec
scan/scan@rome_ts                                            1.00     98.5±2.26ms        ? ?/sec    1.00     98.3±2.25ms        ? ?/sec
scan/scan@threejs                                            1.02     35.4±0.98ms        ? ?/sec    1.00     34.8±1.89ms        ? ?/sec
scan/scan@threejs10x                                         1.00    362.1±5.97ms        ? ?/sec    1.00    360.9±4.94ms        ? ?/sec

//#region node_modules/demo-pkg/index-module.js
var index_module_exports = {};
__export(index_module_exports, { foo: () => foo });
/* @__PURE__ */ __export(index_module_exports, { foo: () => foo });
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is correct. This means this expression can be removed whenever because the return value is not used.
We have to output something like:

var index_module_exports = /* @__PURE__ */ __export({}, { foo: () => foo });

to mark the call expression as pure.

I haven't checked but I assume this is the reason why Vite's tests failed after this PR is merged.
https://github.com/rolldown/rolldown/actions/runs/17257477246/job/48972158671

Copy link
Member

Choose a reason for hiding this comment

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

IWANABETHATGUY added a commit that referenced this pull request Aug 27, 2025
github-merge-queue bot pushed a commit that referenced this pull request Aug 27, 2025
@github-actions github-actions bot mentioned this pull request Sep 5, 2025
shulaoda added a commit that referenced this pull request Sep 5, 2025
## [1.0.0-beta.35] - 2025-09-05

### 🚀 Features

- rolldown_plugin_vite_css_post: attch vite metadata to chunks (#6011) by @shulaoda
- rolldown_plugin_vite_css_post: emit a single CSS asset for non–code-split builds (#6005) by @shulaoda
- rolldown_plugin_vite_css_post: align empty CSS chunk removal logic (#6004) by @shulaoda
- use frequent characters first for internal export names (#5524) by @AliceLanniste
- rolldown_plugin_vite_css_post: align partial `generateBundle` logic (#5987) by @shulaoda
- rolldown_plugin_vite_css_post: align `augmentChunkHash` logic (#5986) by @shulaoda
- rolldown_watcher: introduce `WatcherConfig` for configurable watcher parameters (#5991) by @hyf0
- dev: support `import.meta.invalidate` and migrate tests (#5979) by @hyf0
- dev: adapt `TestDevServer` with `DevEngine` (#5976) by @hyf0
- propertyWriteSideEffects (#5977) by @IWANABETHATGUY
- rolldown_plugin_vite_css_post: complete `transform` logic (#5985) by @shulaoda
- dev: generate hmr updates for file changes (#5961) by @hyf0
- rolldown_plugin_vite_css_post: complete `finalize_css` (#5974) by @shulaoda
- dev: manage cache by `DevEngine` (#5960) by @hyf0
- rolldown_plugin_vite_css_post: align `hoist_at_rules` (#5967) by @shulaoda
- rolldown_plugin_vte_css_post: complete `resolve_asset_urls_in_css` (#5958) by @shulaoda
- rolldown_plugin_utils: support common `to_output_file_path` (#5956) by @shulaoda
- dev: default to not eager rebuild (#5949) by @hyf0
- treeshake.propertyReadSideEffects (#5945) by @IWANABETHATGUY
- improve error message for `this.resolve` and `this.load` (#5596) by @sapphi-red
- dev: accept `onHmrUpdates` callback (#5942) by @hyf0
- rolldown_plugin_vite_css_post: align partial `resolve_asset_urls_in_css` (#5929) by @shulaoda
- mark `__export` runtime helper as pure (#5926) by @IWANABETHATGUY
- rolldown_plugin_vite_css_post: extract `finalize_css_chunk` (#5916) by @shulaoda
- implement inlineConst.pass (#5912) by @IWANABETHATGUY
- rolldown_plugin_vite_css_post: align partial legacy logic (#5915) by @shulaoda
- add inlineConst.pass options  (#5911) by @IWANABETHATGUY
- rolldown_plugin_vite_css_post: align partial css code split logic (#5906) by @shulaoda
- inlineConst: safe (#5899) by @IWANABETHATGUY

### 🐛 Bug Fixes

- rolldown: don't cleanup for browser build (#6024) by @sxzz
- propertyWriteSideEffects for toplevel staticClassBlock (#5989) by @IWANABETHATGUY
- handle `obj().prop` when `propertyReadSideEffects: false` (#5988) by @IWANABETHATGUY
- handle objectSpread when `treeshake.propertyReadSideEffects` is enabled (#5981) by @IWANABETHATGUY
- __toESM function breaking ES module imports (#5966) by @IWANABETHATGUY
- merge `typescript.onlyRemoveTypeImports` correctly (#5962) by @shulaoda
- should not generate `init_mod` when record is a ExportAllDeclaration and importee is a inner concatenate module (#5952) by @IWANABETHATGUY
- use symbol existance to detect if a plugin is BuiltinPlugin (#5940) by @IWANABETHATGUY
- handle errors thrown in `onLog` and `onwarn` options (#5931) by @sapphi-red
- `replace_plugin` does not work as expected with .ts config (#5920) by @IWANABETHATGUY
- `replace_plugin` support primitive values replacement  (#5921) by @IWANABETHATGUY
- node 20 test version (#5918) by @IWANABETHATGUY
- trigger trace subscriber cleanup on Node.js side (#5913) by @sapphi-red
- add friendly deprecation warning for `resolve.tsconfigFilename` (#5908) by @shulaoda
- inlineConst inlines a var (#5903) by @IWANABETHATGUY
- types: omit `sourcemap` property from `MinifyOptions` correctly (#5892) by @sapphi-red

### 🚜 Refactor

- hmr: process changed files in one update (#6013) by @hyf0
- rolldown_plugin_vite_css_post: improve (#6006) by @shulaoda
- migrate remaining crates from #[allow] to #[expect] attributes (#6002) by @hyf0
- crates/rolldown_common: migrate from #[allow] to #[expect] attributes (#6001) by @hyf0
- crates/rolldown_binding: migrate from #[allow] to #[expect] attributes (#6000) by @hyf0
- crates/rolldown: migrate from #[allow] to #[expect] attributes (#5999) by @hyf0
- extract all options usage in `impl_visit.rs` into `FlatOptionsFlag` (#5992) by @IWANABETHATGUY
- rolldown_watcher: distinguish debounced and non-debounced watchers (#5990) by @hyf0
- dev: only use poll-based watch if required (#5984) by @hyf0
- dev: use dynamic dispatch watcher (#5982) by @hyf0
- improve plugin logic relate to `to_output_file_path` (#5959) by @shulaoda
- make reference_needed_symbols lock free (#5964) by @IWANABETHATGUY
- tweak module loader code (#5950) by @shulaoda
- use less memory to store frequently accessed options field (#5948) by @IWANABETHATGUY
- make `ecma_related` in `NormalModuleTaskResult` non-optional (#5947) by @shulaoda
- dev: replace `BuildStatus` with `BuildStateMachine` (#5927) by @hyf0
- rename `inlineConst: 'safe'` to `inlineConst: 'smart'` (#5909) by @IWANABETHATGUY

### 📚 Documentation

- add redirect for old plugin development page link (#5963) by @TheAlexLichter

### ⚡ Performance

- rolldown: use allocator pool when minifying chunks (#5978) by @Boshen
- merge two `PreProcessor` and `EnsureSpanUniqueness` (#5968) by @IWANABETHATGUY

### 🧪 Testing

- cjs module lexer for named import external with cjs format (#5970) by @IWANABETHATGUY
- hmr: import.meta.hot?.accept case (#5935) by @sapphi-red
- hmr: accept outside circular case (#5938) by @sapphi-red
- hmr: no accept outside circular dependencies case (#5937) by @sapphi-red
- hmr: self accept within circular dependencies case (#5936) by @sapphi-red

### ⚙️ Miscellaneous Tasks

- deps: update crate-ci/typos action to v1.36.2 (#6015) by @renovate[bot]
- deps: update dependency rolldown-plugin-dts to ^0.16.0 (#6023) by @renovate[bot]
- ci: re-enable WASM tests in CI workflows (#6007) by @hyf0
- deps: update crate-ci/typos action to v1.35.8 (#6012) by @renovate[bot]
- clippy: enable allow_attributes lint and migrate to #[expect] (#6008) by @hyf0
- remove unmaintained AGENTS.md file (#6009) by @hyf0
- deps: update github-actions (#5993) by @renovate[bot]
- fix `knip` warnings and remove redundant `@rolldown/testing` (#5973) by @shulaoda
- deps: update dependency rolldown-plugin-dts to v0.15.10 (#5925) by @renovate[bot]
- deps: update rust crate tracing-subscriber to v0.3.20 [security] (#5972) by @renovate[bot]
- fix wasi build failed (#5969) by @shulaoda
- deps: update crate-ci/typos action to v1.35.7 (#5965) by @renovate[bot]
- remove redundant code (#5943) by @shulaoda
- npm trusted publisher (#5953) by @Brooooooklyn
- deps: update crate-ci/typos action to v1.35.6 (#5957) by @renovate[bot]
- Revert "feat: mark `__export` runtime helper as pure (#5926)" (#5928) by @IWANABETHATGUY
- deps: update dependency rolldown-plugin-dts to v0.15.10 (#5900) by @renovate[bot]
- validator: improve the diagnostic message (#5919) by @shulaoda
- add more tracing instrumentation (#5914) by @sapphi-red
- add proper error message when passing unexpected minify options in rust test (#5905) by @IWANABETHATGUY
- deps: update dependency tsdown to v0.14.2 (#5901) by @renovate[bot]
- add automatic issue closing (#5895) by @shulaoda

Co-authored-by: shulaoda <[email protected]>
graphite-app bot pushed a commit that referenced this pull request Sep 10, 2025
related to #5923

Now use the suggestion from @sapphi-red #5926 (comment) to construct module_namespace.

note: It is safe to merge `module_namespace` declaration and the `__export` statement, since we always append `__export` statement before `__reexport` statements https://github.com/rolldown/rolldown/pull/5939/files#diff-869ccc2e55fee0609d8452d49a68b9df851a71c9f34bdd0324cbd5dfdfe8d1bfL458-L459
graphite-app bot pushed a commit that referenced this pull request Sep 10, 2025
related to #5923

Now use the suggestion from @sapphi-red #5926 (comment) to construct module_namespace.

note: It is safe to merge `module_namespace` declaration and the `__export` statement, since we always append `__export` statement before `__reexport` statements https://github.com/rolldown/rolldown/pull/5939/files#diff-869ccc2e55fee0609d8452d49a68b9df851a71c9f34bdd0324cbd5dfdfe8d1bfL458-L459

Something still needs to be done before the merge:
- ~`rolldown-dts-plugin` supports our new `__exports` codegen pattern~
- ~`rolldown-vite` upgrade to version has the fixing patch.~
graphite-app bot pushed a commit that referenced this pull request Dec 24, 2025
…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
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.

3 participants