feat: emit warnings for invalid pure annotations#9381
Merged
h-a-n-a merged 6 commits intoMay 14, 2026
Conversation
ce6406a to
8a34e92
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
h-a-n-a
reviewed
May 13, 2026
Member
|
Can you resolve the conflicts please? |
Contributor
Author
Already on it 😄 rebasing onto the latest main and resolving conflicts now. Will push the updated branch shortly. |
0a3c424 to
3240f98
Compare
h-a-n-a
approved these changes
May 14, 2026
3240f98 to
226daaa
Compare
h-a-n-a
pushed a commit
that referenced
this pull request
May 14, 2026
Follow-up to #9381 — addresses the review feedback about the `@__PURE__` docs being incomplete. The existing section only covered function calls. This expands it to: - Mention that `new` expressions also receive the annotation - Note the annotation's required position (immediately before the call/new expression) - List common invalid placements in a warning admonition — the same patterns that #9381's new `INVALID_ANNOTATION` warning now surfaces
IWANABETHATGUY
pushed a commit
that referenced
this pull request
May 18, 2026
Surfaces `/* #__PURE__ */` / `/* @__PURE__ */` annotations that the parser cannot apply, using Rollup's `INVALID_ANNOTATION` log code. The parser metadata comes from oxc-project/oxc#20687 (in `oxc@0.130.0`, already a dependency). `PreProcessEcmaAst::build` iterates `program.comments` after the semantic-warnings block and pushes one diagnostic per `PureNotApplied` comment. No AST mutation; codegen and tree-shaking unchanged. Five positive fixtures + one negative (a valid annotation that must produce zero warnings, guarding against false positives) cover the three contexts oxc marks plus the `@__PURE__` variant and a mixed valid/invalid case. Two existing snapshots (`remove_unused_pure_comment_calls`, `property_read_side_effects`) gained the warning because their inputs already contained misplaced annotations — their `# Assets` output is unchanged. One open question: Rollup also _strips_ invalid annotations from output (per its log text "The comment will be removed to avoid issues"). I left that out to avoid a behavior change during the RC phase; happy to follow up in a separate PR if desired. Fixes #8898.
IWANABETHATGUY
pushed a commit
that referenced
this pull request
May 18, 2026
Follow-up to #9381 — addresses the review feedback about the `@__PURE__` docs being incomplete. The existing section only covered function calls. This expands it to: - Mention that `new` expressions also receive the annotation - Note the annotation's required position (immediately before the call/new expression) - List common invalid placements in a warning admonition — the same patterns that #9381's new `INVALID_ANNOTATION` warning now surfaces
graphite-app Bot
pushed a commit
to oxc-project/oxc
that referenced
this pull request
May 19, 2026
`/* #__PURE__ */ test().a.b.c` was marked as `PureNotApplied` because `set_pure_on_call_or_new_expr` only checked the top-level AST node. For member-access chains rooted at a call/new, the top-level node is a `MemberExpression`, which fell through to the `_ => false` arm. Rollup and esbuild apply PURE to the innermost call/new in this shape (member-access side effects are handled separately by `propertyReadSideEffects` in Rollup). Aligning here fixes false-positive warnings in downstream consumers that forward `PureNotApplied` to users (e.g. rolldown/rolldown#9381). Recurse through `StaticMemberExpression`, `ComputedMemberExpression`, `PrivateFieldExpression`, and the matching `ChainElement` variants (plus `TSNonNullExpression` in chains) to reach the underlying call. Fixes #22394 AI disclosure: implemented with Claude Code, reviewed manually.
Merged
shulaoda
added a commit
that referenced
this pull request
May 20, 2026
## [1.0.2] - 2026-05-20 ### 🚀 Features - devtools: emit package size in PackageGraphReady (#9434) by @IWANABETHATGUY - devtools: classify package dependency types (#9427) by @IWANABETHATGUY - devtools: map packages to modules and chunks (#9426) by @IWANABETHATGUY - devtools: mark used packages (#9423) by @IWANABETHATGUY - devtools: make duplicate packages discoverable (#9422) by @IWANABETHATGUY - devtools: emit package metadata (#9421) by @IWANABETHATGUY - update oxc to 0.132.0 (#9449) by @shulaoda - update oxc to 0.131.0 (#9424) by @shulaoda - allow checks.* to escalate emissions to hard errors (#9388) by @IWANABETHATGUY - dev: support watcher options `include` and `exclude` (#9395) by @h-a-n-a - emit warnings for invalid pure annotations (#9381) by @Kyujenius ### 🐛 Bug Fixes - hash: keep chunk file names stable when an unrelated entry is added (#9444) by @hyf0 - call `codeSplitting.groups[].name` in deterministic order (#9457) by @sapphi-red - dev/lazy: make `resolve_id` idempotent when the resolved id is already a lazy entry (#9439) by @h-a-n-a - chunk-optimization: publish absorbed dynamic-entry namespace cross-chunk (#9448) by @IWANABETHATGUY - treeshake: propagate pure annotation through compound exprs (#9431) by @Dunqing - finalizer: skip redundant init call when barrel executes in same chunk (#9354) by @IWANABETHATGUY - linking: initialize wrapped ESM re-export owners (#9353) by @IWANABETHATGUY - do not inherit __toESM across chunks for named-only external imports (#9333) (#9415) by @IWANABETHATGUY - watcher: don't write output or emit events after close() (#9328) by @situ2001 - chunk-optimization: avoid unsafe dynamic-only merges (#9398) by @IWANABETHATGUY - cjs: rename CJS-wrapped locals that would shadow chunk-scope names (#9392) by @hyf0 - dev/lazy: watch lazy modules added in rebuilds (#9391) by @h-a-n-a ### 🚜 Refactor - rolldown_dev: move dev example to break publish cycle (#9465) by @Boshen - binding: drop unsafe napi string helper, hoist transform ArcStr (#9456) by @hyf0 - ecmascript_utils: split rewrite_ident_reference off JsxExt trait (#9417) by @IWANABETHATGUY - use `ThreadsafeFunction::call_async_catch` (#9390) by @sapphi-red ### 📚 Documentation - devtools: document @rolldown/debug usage and package graph consumption (#9435) by @IWANABETHATGUY - replace `Inter` with system font stack in OG template SVG (#9240) by @yvbopeng - remove `output.comments` warning as all issues have been resolved (#9393) by @sapphi-red - in-depth: clarify @__PURE__ scope and document positions (#9389) by @Kyujenius - readme: remove release candidate notice (#9387) by @shulaoda ### ⚡ Performance - vite-resolve: cache importer existence checks (#9443) by @Brooooooklyn - binding: reduce plugin string clones (#9436) by @Brooooooklyn ### 🧪 Testing - enable `legal_comments_inline` test (#9394) by @sapphi-red ### ⚙️ Miscellaneous Tasks - bump pnpm to v11.1.2 (#9447) by @Boshen - deps: update rust crates (#9461) by @renovate[bot] - deps: update rollup submodule for tests to v4.60.4 (#9453) by @rolldown-guard[bot] - deps: update test262 submodule for tests (#9454) by @rolldown-guard[bot] - deps: update npm packages (#9430) by @renovate[bot] - deps: update github actions (#9429) by @renovate[bot] - deps: update dependency rolldown-plugin-dts to v0.25.1 (#9452) by @renovate[bot] - deps: update rust crates (#9428) by @renovate[bot] - revert allow checks.* to escalate emissions to hard errors (#9388) (#9438) by @IWANABETHATGUY - update mimalloc-safe to 0.1.61 (#9413) by @shulaoda - deny `todo`, `unimplemented`, and `print_stderr` clippy lints (#9412) by @Boshen - deps: update mimalloc-safe to 0.1.60 (#9410) by @shulaoda - remove `pip install setuptools` workaround for node-gyp on macOS (#9370) by @sapphi-red - renovate: disable automerge to require manual approval (#9386) by @shulaoda - deps: update napi (#9385) by @renovate[bot] ### ❤️ New Contributors * @yvbopeng made their first contribution in [#9240](#9240) Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
Closed
V1OL3TF0X
pushed a commit
to V1OL3TF0X/rolldown
that referenced
this pull request
May 25, 2026
## [1.0.2] - 2026-05-20 ### 🚀 Features - devtools: emit package size in PackageGraphReady (rolldown#9434) by @IWANABETHATGUY - devtools: classify package dependency types (rolldown#9427) by @IWANABETHATGUY - devtools: map packages to modules and chunks (rolldown#9426) by @IWANABETHATGUY - devtools: mark used packages (rolldown#9423) by @IWANABETHATGUY - devtools: make duplicate packages discoverable (rolldown#9422) by @IWANABETHATGUY - devtools: emit package metadata (rolldown#9421) by @IWANABETHATGUY - update oxc to 0.132.0 (rolldown#9449) by @shulaoda - update oxc to 0.131.0 (rolldown#9424) by @shulaoda - allow checks.* to escalate emissions to hard errors (rolldown#9388) by @IWANABETHATGUY - dev: support watcher options `include` and `exclude` (rolldown#9395) by @h-a-n-a - emit warnings for invalid pure annotations (rolldown#9381) by @Kyujenius ### 🐛 Bug Fixes - hash: keep chunk file names stable when an unrelated entry is added (rolldown#9444) by @hyf0 - call `codeSplitting.groups[].name` in deterministic order (rolldown#9457) by @sapphi-red - dev/lazy: make `resolve_id` idempotent when the resolved id is already a lazy entry (rolldown#9439) by @h-a-n-a - chunk-optimization: publish absorbed dynamic-entry namespace cross-chunk (rolldown#9448) by @IWANABETHATGUY - treeshake: propagate pure annotation through compound exprs (rolldown#9431) by @Dunqing - finalizer: skip redundant init call when barrel executes in same chunk (rolldown#9354) by @IWANABETHATGUY - linking: initialize wrapped ESM re-export owners (rolldown#9353) by @IWANABETHATGUY - do not inherit __toESM across chunks for named-only external imports (rolldown#9333) (rolldown#9415) by @IWANABETHATGUY - watcher: don't write output or emit events after close() (rolldown#9328) by @situ2001 - chunk-optimization: avoid unsafe dynamic-only merges (rolldown#9398) by @IWANABETHATGUY - cjs: rename CJS-wrapped locals that would shadow chunk-scope names (rolldown#9392) by @hyf0 - dev/lazy: watch lazy modules added in rebuilds (rolldown#9391) by @h-a-n-a ### 🚜 Refactor - rolldown_dev: move dev example to break publish cycle (rolldown#9465) by @Boshen - binding: drop unsafe napi string helper, hoist transform ArcStr (rolldown#9456) by @hyf0 - ecmascript_utils: split rewrite_ident_reference off JsxExt trait (rolldown#9417) by @IWANABETHATGUY - use `ThreadsafeFunction::call_async_catch` (rolldown#9390) by @sapphi-red ### 📚 Documentation - devtools: document @rolldown/debug usage and package graph consumption (rolldown#9435) by @IWANABETHATGUY - replace `Inter` with system font stack in OG template SVG (rolldown#9240) by @yvbopeng - remove `output.comments` warning as all issues have been resolved (rolldown#9393) by @sapphi-red - in-depth: clarify @__PURE__ scope and document positions (rolldown#9389) by @Kyujenius - readme: remove release candidate notice (rolldown#9387) by @shulaoda ### ⚡ Performance - vite-resolve: cache importer existence checks (rolldown#9443) by @Brooooooklyn - binding: reduce plugin string clones (rolldown#9436) by @Brooooooklyn ### 🧪 Testing - enable `legal_comments_inline` test (rolldown#9394) by @sapphi-red ### ⚙️ Miscellaneous Tasks - bump pnpm to v11.1.2 (rolldown#9447) by @Boshen - deps: update rust crates (rolldown#9461) by @renovate[bot] - deps: update rollup submodule for tests to v4.60.4 (rolldown#9453) by @rolldown-guard[bot] - deps: update test262 submodule for tests (rolldown#9454) by @rolldown-guard[bot] - deps: update npm packages (rolldown#9430) by @renovate[bot] - deps: update github actions (rolldown#9429) by @renovate[bot] - deps: update dependency rolldown-plugin-dts to v0.25.1 (rolldown#9452) by @renovate[bot] - deps: update rust crates (rolldown#9428) by @renovate[bot] - revert allow checks.* to escalate emissions to hard errors (rolldown#9388) (rolldown#9438) by @IWANABETHATGUY - update mimalloc-safe to 0.1.61 (rolldown#9413) by @shulaoda - deny `todo`, `unimplemented`, and `print_stderr` clippy lints (rolldown#9412) by @Boshen - deps: update mimalloc-safe to 0.1.60 (rolldown#9410) by @shulaoda - remove `pip install setuptools` workaround for node-gyp on macOS (rolldown#9370) by @sapphi-red - renovate: disable automerge to require manual approval (rolldown#9386) by @shulaoda - deps: update napi (rolldown#9385) by @renovate[bot] ### ❤️ New Contributors * @yvbopeng made their first contribution in [rolldown#9240](rolldown#9240) Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
5 tasks
shulaoda
added a commit
that referenced
this pull request
May 27, 2026
## Summary - Bump oxc Rust crates and `@oxc-project/*` / `oxc-*` npm packages from `0.132.0` to `0.133.0`. ~~Bump `oxc_resolver` / `oxc_resolver_napi` from `11.19.1` to `11.19.2`.~~ - Regenerate `embedded_helpers.rs` to point at `@oxc-project+runtime@0.133.0` (version string only — no helper-content drift). - Handle two new oxc fields surfaced by `cargo check`: - `oxc::transformer::DecoratorOptions.strict_null_checks` — hardcoded to `true` in the `From` impl (matches oxc's default). Exposing it through rolldown's wrapper would be a separate API change. - `oxc_minify_napi::CodegenOptions.legal_comments` — set to `None`. - Extend `DecoratorOptionSchema` and `CodegenOptionsSchema` in `validator.ts` to mirror the new optional fields. - Refresh 32 snapshots driven by upstream oxc PR [#22547](oxc-project/oxc#22547) ("fix(minifier): preserve IIFE structure in DCE-only mode"). In DCE-only mode (rolldown's per-module preprocess via `Compressor::dead_code_elimination_with_scoping`), oxc no longer inlines `(() => …)()` IIFEs that carry — or could carry — `/*#__PURE__*/` annotations, so downstream tree-shaking can see them. Empty-IIFE elision still fires. Side effects: `property_read_side_effects` now correctly tree-shakes `/*#__PURE__*/ test().a.b.c;` lines and drops the previously spurious `INVALID_ANNOTATION` warnings; TS class `(() => new Foo())()` patterns and `Symbol((() => Math.random() < 0.5)() ? …)` calls are preserved as the sources actually wrote them; `dce_of_iife/diff.md` divergence vs esbuild shrunk. ## Issues fixed Pulled in from upstream oxc fixes between 0.132.0 and 0.133.0: - Fixes #9437 — Pure-annotated IIFE returning an array is inlined (via oxc [#22547](oxc-project/oxc#22547)) - Fixes #9494 — Cross-module enum inlining mis-folds auto-increment member to 0 (via oxc [#22646](oxc-project/oxc#22646)) - Fixes #9408 — Rolldown drops `@preserve` from `/* #__PURE__ -- @preserve */` comments (via oxc [#22525](oxc-project/oxc#22525) "preserve verbatim text of pure/no-side-effects comments") - Partially addresses #8688 — `dce/dce_of_iife` esbuild divergence shrunk (via oxc [#22589](oxc-project/oxc#22589) "drop empty-body IIFE wrapper when called with arguments") Also relevant: oxc [#22566](oxc-project/oxc#22566) reduces false-positive `PureNotApplied` warnings (the warnings system landed in rolldown #9381) by applying PURE through member-access chains. ## Test plan - [x] `cargo check --workspace --all-targets` - [x] `just update-generated-code` - [x] `just test-update` - [x] `just ued` - [x] `just roll` — 32 Rust suites pass (0 failed), 1212 node tests pass (0 failed), TS lint+types clean on 804 files --------- Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Surfaces
/* #__PURE__ *///* @__PURE__ */annotations that the parser cannot apply, using Rollup'sINVALID_ANNOTATIONlog code. The parser metadata comes from oxc-project/oxc#20687 (inoxc@0.130.0, already a dependency).PreProcessEcmaAst::builditeratesprogram.commentsafter the semantic-warnings block and pushes one diagnostic perPureNotAppliedcomment. No AST mutation; codegen and tree-shaking unchanged.Five positive fixtures + one negative (a valid annotation that must produce zero warnings, guarding against false positives) cover the three contexts oxc marks plus the
@__PURE__variant and a mixed valid/invalid case. Two existing snapshots (remove_unused_pure_comment_calls,property_read_side_effects) gained the warning because their inputs already contained misplaced annotations — their# Assetsoutput is unchanged.One open question: Rollup also strips invalid annotations from output (per its log text "The comment will be removed to avoid issues"). I left that out to avoid a behavior change during the RC phase; happy to follow up in a separate PR if desired.
Fixes #8898.