fix: accessor with decorators should be kept#7499
Merged
sapphi-red merged 7 commits intomainfrom Dec 15, 2025
Merged
Conversation
✅ Deploy Preview for rolldown-rs canceled.
|
Co-authored-by: sapphi-red <[email protected]>
Co-authored-by: sapphi-red <[email protected]>
Co-authored-by: sapphi-red <[email protected]>
Co-authored-by: sapphi-red <[email protected]>
Copilot
AI
changed the title
[WIP] Fix test in esbuild reasons file
Fix decorator side effect detection for AccessorProperty
Dec 15, 2025
sapphi-red
reviewed
Dec 15, 2025
Signed-off-by: 翠 <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the side effect detector where AccessorProperty elements with decorators were not being detected as having side effects, causing classes with accessor decorators to be incorrectly removed during dead code elimination (DCE). The fix adds a decorator check for AccessorProperty that matches the existing pattern used for MethodDefinition and PropertyDefinition.
Key changes:
- Added early-return decorator check for
AccessorPropertyindetect_side_effect_of_class() - Added comprehensive unit tests covering all decorator types (class, method, field, accessor)
- Updated test snapshots to reflect that accessor properties with decorators are now correctly preserved
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
crates/rolldown/src/ast_scanner/side_effect_detector/mod.rs |
Added decorator check for AccessorProperty (lines 127-129) and unit tests for decorator side effect detection |
crates/rolldown/tests/esbuild/dce/dce_of_decorators/artifacts.snap |
Updated snapshot showing Accessor and StaticAccessor classes are now preserved in output |
crates/rolldown/tests/esbuild/lower/java_script_decorators_bundle_issue3768/artifacts.snap |
Updated snapshot showing all accessor property variants with decorators are preserved |
crates/rolldown/tests/snapshots/integration_rolldown__filename_with_hash.snap |
Hash updates reflecting changed output content for tests with accessor decorators |
scripts/src/esbuild-tests/reasons.ts |
Updated failure reason to be more specific about the remaining limitation with class-level decorators |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
IWANABETHATGUY
approved these changes
Dec 15, 2025
Member
|
@copilot update the esbuild diff with |
Contributor
Benchmarks Rust |
Co-authored-by: sapphi-red <[email protected]>
Contributor
Author
This was referenced Dec 17, 2025
shulaoda
added a commit
that referenced
this pull request
Dec 17, 2025
## [1.0.0-beta.55] - 2025-12-17 ### 🚀 Features - add validation errors for incompatible `inlineDynamicImports` options (#7539) by @Copilot - rolldown_plugin_vite_reporter: truncate long importer lists in ineffective dynamic import warnings (#7528) by @Copilot - export `memfs` from `rolldown/experimental` for browser builds (#7490) by @Copilot - implement `postBanner` and `postFooter` (#7487) by @sevenc-nanashi - port getLogFilter helper from Rollup for advanced log filtering (#6890) by @taearls - dev: initialize `rolldown_plugin_lazy_compilation` (#7488) by @hyf0 - enable `experimental.transform_hires_sourcemap: 'boundary'` by default (#7478) by @sapphi-red - apply merge CJS namespace optimizations more generally (#7475) by @sapphi-red ### 🐛 Bug Fixes - avoid panic on invalid values for `output.exports`, `output.format`, `output.hash_characters` (#7542) by @sapphi-red - handle `__proto__` export for module namespace correctly (#7534) by @sapphi-red - handle `__proto__` export correctly (#7533) by @sapphi-red - rolldown_plugin_vite_resolve: acquire resolver lock before package json resolution (#7524) by @sapphi-red - disable syntax transform optimization for `minify: 'dce-only'` (#7520) by @sapphi-red - arrow function expression keep names (#7519) by @IWANABETHATGUY - skip symbols that are imported from other module when deconflicting module symbols (#7510) by @IWANABETHATGUY - preserve class names in assignment expressions with keepNames option (#7491) by @IWANABETHATGUY - accessor with decorators should be kept (#7499) by @Copilot - rolldown_plugin_vite_reporter: support `Infinity` for chunk_limit (#7497) by @shulaoda - change filename template validation errors from UNHANDLEABLE_ERROR to INVALID_OPTION (#7472) by @Copilot - `no entry found for key` error when merging CJS namespace exports (#7474) by @sapphi-red - generate output with syntax error when wrapped esm module using tla syntax (#7468) by @IWANABETHATGUY ### 🚜 Refactor - dev: rename `experimental.hmr` to `experimental.devMode` (#7527) by @hyf0 - pass addon option to rust as it is (#7526) by @hyf0 - remove unused stmtinfo meta flag (#7518) by @IWANABETHATGUY ### 📚 Documentation - clarify `closeBundle` behavior (#7525) by @sapphi-red ### 🧪 Testing - add tests for static string postBanner and postFooter (#7516) by @Copilot - disable pluginTimings in Rust integration tests to avoid snapshot noise (#7485) by @shulaoda - port Rollup JSX tests to `crates/rolldown/tests/rollup` (#7480) by @sapphi-red - re-triage some esbuild JSX preserve tests (#7479) by @sapphi-red - disable pluginTimings by default to avoid snapshot noise (#7471) by @shulaoda ### ⚙️ Miscellaneous Tasks - mark feature that will not be supported as ignored in rollup test status (#7535) by @sapphi-red - support `banner`/`footer`/`intro`/`outro` for config variants (#7532) by @sapphi-red - `dce/dce_of_decorators` esbuild test is now passing (#7531) by @sapphi-red - deps: update github-actions (major) (#7495) by @renovate[bot] - deps: update npm packages (#7493) by @renovate[bot] - add a check to verify failedReasons are updated (#7521) by @sapphi-red - deps: update test262 submodule for tests (#7523) by @sapphi-red - deps: update taiki-e/install-action action to v2.63.2 (#7496) by @renovate[bot] - deps: update oxc apps (#7511) by @renovate[bot] - deps: update oxc to v0.103.0 (#7513) by @camc314 - fix format in `.github/instructions/bug-investigation.instructions.md` (#7506) by @sapphi-red - add instructions for REPL decoding (#7502) by @sapphi-red - deps: update github-actions (#7492) by @renovate[bot] - deps: cargo-shear v1.9.0 (#7483) by @Boshen - deps: update dependency oxlint-tsgolint to v0.9.0 (#7484) by @renovate[bot] - deps: update dependency oxlint-tsgolint to v0.8.6 (#7470) by @renovate[bot] - add syntax validation for test output chunks that are not executed (#7466) by @IWANABETHATGUY - deps: update dependency rust to v1.92.0 (#7467) by @renovate[bot] - deps: update test262 submodule for tests (#7457) by @sapphi-red ### ❤️ New Contributors * @sevenc-nanashi made their first contribution in [#7487](#7487) * @taearls made their first contribution in [#6890](#6890) Co-authored-by: shulaoda <[email protected]>
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.
Fix dce_of_decorators test - Add Accessor Decorator Support
Summary
This PR fixes the
dce/dce_of_decoratorstest by adding missing decorator detection forAccessorPropertyin the side effect detector. Accessor and static accessor decorators are now correctly preserved during dead code elimination.Changes Made
Added decorator check for AccessorProperty (
crates/rolldown/src/ast_scanner/side_effect_detector/mod.rs)detect_side_effect_of_classfunction now checks ifAccessorPropertyhas decorators, similar to existing checks forMethodDefinitionandPropertyDefinitionAdded comprehensive unit tests (
crates/rolldown/src/ast_scanner/side_effect_detector/mod.rs)Updated test expectations (
crates/rolldown/tests/esbuild/dce/dce_of_decorators/artifacts.snap)AccessorandStaticAccessorclasses that were previously incorrectly removedUpdated esbuild diff files (
just ued)Test Results
✅ Accessor decorators now work correctly:
class MyClass { @fn accessor x }- keptclass MyClass { @fn static accessor x }- kept✅ All existing decorator functionality preserved:
@fn class Class {}) still removed - requires deeper investigation into tree-shaking logicImpact
This fix ensures that accessor decorators (a TC39 Stage 3 feature) are properly handled during tree-shaking, bringing Rolldown closer to feature parity with esbuild for the new decorator proposal.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.