GeezerVison is showing github.com — feat: support `#__NO_SIDE_EFFECTS__` annotation by hai-x · Pull Request #20775 · webpack/webpack
Conversation
hai-x
commented
Apr 4, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
What kind of change does this PR introduce?
Support #NO_SIDE_EFFECTS annotation. To be mentioned, the annotation can't take effect across modules and it's applied only within the module where it is declared. We will support it in another PR in future.
Did you add tests for your changes?
Yes
Does this PR introduce a breaking change?
No
If relevant, what needs to be documented once your changes are merged or what have you already documented?
No
Use of AI
Partial
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
alexander-akait and xiaoxiaojx reacted with heart emoji
changeset-bot
Bot
commented
Apr 4, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
This PR is packaged and the instant preview is available (3825d6a).
Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@3825d6a
yarn add -D webpack@https://pkg.pr.new/webpack@3825d6a
pnpm add -D webpack@https://pkg.pr.new/webpack@3825d6a
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
codecov
Bot
commented
Apr 4, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.42%. Comparing base (51de347) to head (e6b4eb2).
⚠️ Report is 24 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #20775 +/- ##
==========================================
+ Coverage 91.40% 91.42% +0.01%
==========================================
Files 561 561
Lines 55359 55408 +49
Branches 14610 14630 +20
==========================================
+ Hits 50603 50656 +53
+ Misses 4756 4752 -4
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.
🚀 New features to boost your workflow:
- ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
codspeed
Bot
commented
Apr 4, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Merging this PR will not alter performance
✅ 144 untouched benchmarks
Comparing NO_SIDE_EFFECTS (e6b4eb2) with main (51de347)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
"index"
|
|
|
]),
|
|
|
/** @type {SyncBailHook<[VariableDeclarator, Statement], boolean | void>} */
|
|
|
/** @type {SyncBailHook<[VariableDeclarator, VariableDeclaration], boolean | void>} */
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a type fix right?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's a one-line type fix. _preWalkVariableDeclaration should accept a parameter of type VariableDeclaration, so it will pass a VariableDeclaration as the statement argument to preDeclarator.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
this.destructuringAssignmentProperties = new WeakMap();
|
|
|
this.detectMode(ast.body);
|
|
|
this.modulePreWalkStatements(ast.body);
|
|
|
this.prevStatement = undefined;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need it here right?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's one bug fix. When we enter parsing for an import/export statement of module, prevStatement will be assigned, but currently it's never cleared then. This causes incorrect behavior in anything that relies on prevStatement at preWalk stage.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
alexander-akait reacted with thumbs up emoji
Types CoverageCoverage after merging __NO_SIDE_EFFECTS__ into main will be
Coverage Report| File | Stmts | Branches | Funcs | Lines | Uncovered Lines |
|---|
| bin | | webpack.js | 98.77% | 100% | 100% | 98.77% | 91 | | examples | | build-common.js | 100% | 100% | 100% | 100% | | | buildAll.js | 100% | 100% | 100% | 100% | | | examples.js | 100% | 100% | 100% | 100% | | | template-common.js | 98.21% | 100% | 100% | 98.21% | 72 | | examples/custom-javascript-parser | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/custom-javascript-parser/internals | | acorn-parse.js | 100% | 100% | 100% | 100% | | | meriyah-parse.js | 100% | 100% | 100% | 100% | | | oxc-parse.js | 91.30% | 100% | 100% | 91.30% | 140, 142–143, 145, 147, 153–154, 161, 168, 90 | | examples/markdown | | webpack.config.mjs | 100% | 100% | 100% | 100% | | | examples/typescript | | test.filter.js | 50% | 100% | 100% | 50% | 5 | | examples/virtual-modules | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-bindgen-esm | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-complex | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-simple | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-simple-source-phase | | test.filter.js | 100% | 100% | 100% | 100% | | | lib | | APIPlugin.js | 100% | 100% | 100% | 100% | | | AbstractMethodError.js | 100% | 100% | 100% | 100% | | | AsyncDependenciesBlock.js | 100% | 100% | 100% | 100% | | | AsyncDependencyToInitialChunkError.js | 100% | 100% | 100% | 100% | | | AutomaticPrefetchPlugin.js | 100% | 100% | 100% | 100% | | | BannerPlugin.js | 100% | 100% | 100% | 100% | | | Cache.js | 98.21% | 100% | 100% | 98.21% | 104 | | CacheFacade.js | 100% | 100% | 100% | 100% | | | CaseSensitiveModulesWarning.js | 100% | 100% | 100% | 100% | | | Chunk.js | 99.72% | 100% | 100% | 99.72% | 37 | | ChunkGraph.js | 100% | 100% | 100% | 100% | | | ChunkGroup.js | 100% | 100% | 100% | 100% | | | ChunkRenderError.js | 100% | 100% | 100% | 100% | | | ChunkTemplate.js | 100% | 100% | 100% | 100% | | | CleanPlugin.js | 98.72% | 100% | 100% | 98.72% | 206, 226, 382 | | CodeGenerationError.js | 100% | 100% | 100% | 100% | | | CodeGenerationResults.js | 100% | 100% | 100% | 100% | | | CommentCompilationWarning.js | 100% | 100% | 100% | 100% | | | CompatibilityPlugin.js | 100% | 100% | 100% | 100% | | | Compilation.js | 98.55% | 100% | 100% | 98.55% | 1559, 1855, 1862, 1870, 1892, 2788, 3213, 3868, 3897, 3950–3951, 3955, 3960, 3976–3977, 3991–3992, 3997–3998, 4471, 4497, 498, 503, 5205, 5286, 5301, 5326–5327, 5329, 5651, 5656, 5662, 5665, 5677, 5679, 5683, 5699, 5714, 5746, 5800, 5824, 5938, 717–718 | | Compiler.js | 99.56% | 100% | 100% | 99.56% | 1116–1117, 1125 | | ConcatenationScope.js | 98.59% | 100% | 100% | 98.59% | 189 | | ConcurrentCompilationError.js | 100% | 100% | 100% | 100% | | | ConditionalInitFragment.js | 100% | 100% | 100% | 100% | | | ConstPlugin.js | 100% | 100% | 100% | 100% | | | ContextExclusionPlugin.js | 100% | 100% | 100% | 100% | | | ContextModule.js | 100% | 100% | 100% | 100% | | | ContextModuleFactory.js | 97.75% | 100% | 100% | 97.75% | 258, 393, 418, 443, 447, 458 | | ContextReplacementPlugin.js | 100% | 100% | 100% | 100% | | | CssModule.js | 81.32% | 100% | 100% | 81.32% | 157, 162–177 | | DefinePlugin.js | 98.92% | 100% | 100% | 98.92% | 158–159, 175, 194, 268 | | DelegatedModule.js | 95.24% | 100% | 100% | 95.24% | 253–257 | | DelegatedModuleFactoryPlugin.js | 98.15% | 100% | 100% | 98.15% | 106 | | DelegatedPlugin.js | 100% | 100% | 100% | 100% | | | DependenciesBlock.js | 100% | 100% | 100% | 100% | | | Dependency.js | 98.13% | 100% | 100% | 98.13% | 371, 404 | | DependencyTemplate.js | 100% | 100% | 100% | 100% | | | DependencyTemplates.js | 100% | 100% | 100% | 100% | | | DllEntryPlugin.js | 100% | 100% | 100% | 100% | | | DllModule.js | 100% | 100% | 100% | 100% | | | DllModuleFactory.js | 100% | 100% | 100% | 100% | | | DllPlugin.js | 100% | 100% | 100% | 100% | | | DllReferencePlugin.js | 100% | 100% | 100% | 100% | | | DotenvPlugin.js | 97.88% | 100% | 100% | 97.88% | 237, 378, 391–392 | | DynamicEntryPlugin.js | 100% | 100% | 100% | 100% | | | EntryOptionPlugin.js | 100% | 100% | 100% | 100% | | | EntryPlugin.js | 100% | 100% | 100% | 100% | | | Entrypoint.js | 100% | 100% | 100% | 100% | | | EnvironmentNotSupportAsyncWarning.js | 100% | 100% | 100% | 100% | | | EnvironmentPlugin.js | 97.14% | 100% | 100% | 97.14% | 49 | | ErrorHelpers.js | 100% | 100% | 100% | 100% | | | EvalDevToolModulePlugin.js | 100% | 100% | 100% | 100% | | | EvalSourceMapDevToolPlugin.js | 100% | 100% | 100% | 100% | | | ExportsInfo.js | 100% | 100% | 100% | 100% | | | ExportsInfoApiPlugin.js | 100% | 100% | 100% | 100% | | | ExternalModule.js | 98.89% | 100% | 100% | 98.89% | 399–403, 542 | | ExternalModuleFactoryPlugin.js | 100% | 100% | 100% | 100% | | | ExternalsPlugin.js | 100% | 100% | 100% | 100% | | | FalseIIFEUmdWarning.js | 100% | 100% | 100% | 100% | | | FileSystemInfo.js | 99.49% | 100% | 100% | 99.49% | 182, 2213–2214, 2217, 2228, 2239, 2250, 278, 3596, 3611, 3635 | | FlagAllModulesAsUsedPlugin.js | 100% | 100% | 100% | 100% | | | FlagDependencyExportsPlugin.js | 98.74% | 100% | 100% | 98.74% | 399, 401, 405 | | FlagDependencyUsagePlugin.js | 100% | 100% | 100% | 100% | | | FlagEntryExportAsUsedPlugin.js | 100% | 100% | 100% | 100% | | | Generator.js | 100% | 100% | 100% | 100% | | | GraphHelpers.js | 100% | 100% | 100% | 100% | | | HarmonyLinkingError.js | 100% | 100% | 100% | 100% | | | HookWebpackError.js | 100% | 100% | 100% | 100% | | | HotModuleReplacementPlugin.js | 100% | 100% | 100% | 100% | | | HotUpdateChunk.js | 100% | 100% | 100% | 100% | | | IgnoreErrorModuleFactory.js | 100% | 100% | 100% | 100% | | | IgnorePlugin.js | 100% | 100% | 100% | 100% | | | IgnoreWarningsPlugin.js | 100% | 100% | 100% | 100% | | | InitFragment.js | 100% | 100% | 100% | 100% | | | InvalidDependenciesModuleWarning.js | 100% | 100% | 100% | 100% | | | JavascriptMetaInfoPlugin.js | 100% | 100% | 100% | 100% | | | LibManifestPlugin.js | 97.14% | 100% | 100% | 97.14% | 117, 120 | | LibraryTemplatePlugin.js | 100% | 100% | 100% | 100% | | | LoaderOptionsPlugin.js | 100% | 100% | 100% | 100% | | | LoaderTargetPlugin.js | 100% | 100% | 100% | 100% | | | MainTemplate.js | 100% | 100% | 100% | 100% | | | ManifestPlugin.js | 100% | 100% | 100% | 100% | | | Module.js | 98.50% | 100% | 100% | 98.50% | 1303, 1308, 1369, 1383, 1445, 1454 | | ModuleBuildError.js | 100% | 100% | 100% | 100% | | | ModuleDependencyError.js | 100% | 100% | 100% | 100% | | | ModuleDependencyWarning.js | 100% | 100% | 100% | 100% | | | ModuleError.js | 100% | 100% | 100% | 100% | | | ModuleFactory.js | 100% | 100% | 100% | 100% | | | ModuleFilenameHelpers.js | 98.85% | 100% | 100% | 98.85% | 106, 108 | | ModuleGraph.js | 99.73% | 100% | 100% | 99.73% | 1004 | | ModuleGraphConnection.js | 100% | 100% | 100% | 100% | | | ModuleHashingError.js | 100% | 100% | 100% | 100% | | | ModuleInfoHeaderPlugin.js | 100% | 100% | 100% | 100% | | | ModuleNotFoundError.js | 100% | 100% | 100% | 100% | | | ModuleParseError.js | 100% | 100% | 100% | 100% | | | ModuleProfile.js | 100% | 100% | 100% | 100% | | | ModuleRestoreError.js | 100% | 100% | 100% | 100% | | | ModuleSourceTypeConstants.js | 100% | 100% | 100% | 100% | | | ModuleStoreError.js | 100% | 100% | 100% | 100% | | | ModuleTemplate.js | 100% | 100% | 100% | 100% | | | ModuleTypeConstants.js | 100% | 100% | 100% | 100% | | | ModuleWarning.js | 100% | 100% | 100% | 100% | | | MultiCompiler.js | 99.69% | 100% | 100% | 99.69% | 645 | | MultiStats.js | 100% | 100% | 100% | 100% | | | MultiWatching.js | 100% | 100% | 100% | 100% | | | NoEmitOnErrorsPlugin.js | 100% | 100% | 100% | 100% | | | NoModeWarning.js | 100% | 100% | 100% | 100% | | | NodeStuffInWebError.js | 100% | 100% | 100% | 100% | | | NodeStuffPlugin.js | 100% | 100% | 100% | 100% | | | NormalModule.js | 97.78% | 100% | 100% | 97.78% | 1002, 1036, 1052, 1139, 1781, 1786–1796, 214, 726, 744, 761 | | NormalModuleFactory.js | 99.47% | 100% | 100% | 99.47% | 1067, 1376, 466, 478 | | NormalModuleReplacementPlugin.js | 100% | 100% | 100% | 100% | | | NullFactory.js | 100% | 100% | 100% | 100% | | | OptimizationStages.js | 100% | 100% | 100% | 100% | | | OptionsApply.js | 100% | 100% | 100% | 100% | | | Parser.js | 100% | 100% | 100% | 100% | | | PlatformPlugin.js | 100% | 100% | 100% | 100% | | | PrefetchPlugin.js | 100% | 100% | 100% | 100% | | | ProgressPlugin.js | 98.75% | 100% | 100% | 98.75% | 448–449, 454, 456, 520 | | ProvidePlugin.js | 100% | 100% | 100% | 100% | | | RawModule.js | 100% | 100% | 100% | 100% | | | RecordIdsPlugin.js | 100% | 100% | 100% | 100% | | | RequestShortener.js | 100% | 100% | 100% | 100% | | | RequireJsStuffPlugin.js | 100% | 100% | 100% | 100% | | | ResolverFactory.js | 100% | 100% | 100% | 100% | | | RuntimeGlobals.js | 100% | 100% | 100% | 100% | | | RuntimeModule.js | 100% | 100% | 100% | 100% | | | RuntimePlugin.js | 100% | 100% | 100% | 100% | | | RuntimeTemplate.js | 100% | 100% | 100% | 100% | | | SelfModuleFactory.js | 100% | 100% | 100% | 100% | | | SingleEntryPlugin.js | 100% | 100% | 100% | 100% | | | SizeFormatHelpers.js | 100% | 100% | 100% | 100% | | | SourceMapDevToolModuleOptionsPlugin.js | 100% | 100% | 100% | 100% | | | SourceMapDevToolPlugin.js | 99.16% | 100% | 100% | 99.16% | 267–268, 610 | | Stats.js | 100% | 100% | 100% | 100% | | | Template.js | 100% | 100% | 100% | 100% | | | TemplatedPathPlugin.js | 98.86% | 100% | 100% | 98.86% | 134–135 | | UnhandledSchemeError.js | 100% | 100% | 100% | 100% | | | UnsupportedFeatureWarning.js | 100% | 100% | 100% | 100% | | | UseStrictPlugin.js | 100% | 100% | 100% | 100% | | | WarnCaseSensitiveModulesPlugin.js | 100% | 100% | 100% | 100% | | | WarnDeprecatedOptionPlugin.js | 100% | 100% | 100% | 100% | | | WarnNoModeSetPlugin.js | 100% | 100% | 100% | 100% | | | WatchIgnorePlugin.js | 100% | 100% | 100% | 100% | | | Watching.js | 100% | 100% | 100% | 100% | | | WebpackError.js | 96.97% | 100% | 100% | 96.97% | 44 | | WebpackIsIncludedPlugin.js | 100% | 100% | 100% | 100% | | | WebpackOptionsApply.js | 100% | 100% | 100% | 100% | | | WebpackOptionsDefaulter.js | 100% | 100% | 100% | 100% | | | buildChunkGraph.js | 99.87% | 100% | 100% | 99.87% | 326 | | cli.js | 98.71% | 100% | 100% | 98.71% | 117, 469, 501, 543, 813 | | formatLocation.js | 100% | 100% | 100% | 100% | | | index.js | 100% | 100% | 100% | 100% | | | validateSchema.js | 94.67% | 100% | 100% | 94.67% | 100, 87, 89, 98 | | webpack.js | 97.22% | 100% | 100% | 97.22% | 196, 218, 220 | | lib/asset | | AssetBytesGenerator.js | 100% | 100% | 100% | 100% | | | AssetBytesParser.js | 100% | 100% | 100% | 100% | | | AssetGenerator.js | 100% | 100% | 100% | 100% | | | AssetModulesPlugin.js | 97.77% | 100% | 100% | 97.77% | 285, 309, 312, 364, 40 | | AssetParser.js | 100% | 100% | 100% | 100% | | | AssetSourceGenerator.js | 100% | 100% | 100% | 100% | | | AssetSourceParser.js | 100% | 100% | 100% | 100% | | | RawDataUrlModule.js | 100% | 100% | 100% | 100% | | | lib/async-modules | | AsyncModuleHelpers.js | 100% | 100% | 100% | 100% | | | AwaitDependenciesInitFragment.js | 100% | 100% | 100% | 100% | | | InferAsyncModulesPlugin.js | 100% | 100% | 100% | 100% | | | lib/cache | | AddBuildDependenciesPlugin.js | 100% | 100% | 100% | 100% | | | AddManagedPathsPlugin.js | 100% | 100% | 100% | 100% | | | IdleFileCachePlugin.js | 97.92% | 100% | 100% | 97.92% | 71, 83, 91 | | MemoryCachePlugin.js | 95.83% | 100% | 100% | 95.83% | 33 | | MemoryWithGcCachePlugin.js | 93.15% | 100% | 100% | 93.15% | 106, 113–114, 122, 89 | | PackFileCacheStrategy.js |
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Let's merge after the next patch release (Monday/Tuesday)
|
arthurdandrea and hai-x reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
bjohansebas
added a commit
to webpack/webpack.js.org
that referenced
this pull request
May 17, 2026
Webpack 5.107 supports the #__NO_SIDE_EFFECTS__ annotation from the
compiler-notations-spec, letting authors mark function declarations as
side-effect-free so calls can be tree-shaken when their return value is
unused. Adds a new subsection in the tree shaking guide right after the
existing /*#__PURE__*/ section, with the caveat that propagation is
currently intra-module only.
Refs: webpack/webpack#20775
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|