Repository navigation
fix(config): default output.module to true when using module library type - #22063
Pcmhacker-piro wants to merge 1 commit into
Conversation
…type When output.library.type (or an entry library.type) is set to 'module' or 'modern-module', output.module must default to true so that webpack does not emit export statements wrapped inside an IIFE. Also throws a descriptive configuration error if output.module is explicitly set to false with a module library type. Fixes webpack#22061.
🦋 Changeset detectedLatest commit: e0d04f2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
👋 Hi there! This PR was automatically flagged and closed by our quality checks. If you believe this was a mistake, please review our contributing guidelines |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughWebpack now defaults ChangesModule library output
Suggested reviewers: Change: Bug fix · Severity of issue fixed: Medium Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@alexander-akait @avivkeller I'd like to respectfully ask for a human review to reopen this PR — the automated quality check flagged 'max-daily-forks' on my GitHub account activity, not the content of this PR. This PR addresses #22061 (where
Could a maintainer please reopen this PR for review? Thank you! |
|
|
Please in future avoid to duplicate PRs, also our actions properly found out that this job was just AI generated, please prefer be more human and keep answering by hands rather than only AI generated, thanks for helping us |
|
Closing as a duplicate of #22064, both superseded by #22071 — thanks for the report. Generated by Claude Code |
Summary
Following the removal of
experiments.outputModulein #22011,output.moduleshould default totruewhenever an ESM output is configured.Previously,
output.moduleonly defaulted totruewhen targeting universal, deno, or bun (tp.node === null && tp.web === null && tp.module !== false,tp.deno === true,tp.bun === true). If a user configuredoutput.library.type: "module"or"modern-module"(or set it per-entry inentry[name].library.type: "module"),output.moduleremainedfalse.As a consequence:
output.iifedefaulted totrue(because!output.module).(() => { ... })().ModuleLibraryPluginemittedexport default ...inside the IIFE body:SyntaxError: Unexpected token 'export'and failing Terser minification in production ("Export" statement may only appear at the top level).output: { module: false, library: { type: "module" } }was not guarded, allowing conflicting options to produce invalid code silently.This PR:
output.moduletotrueinlib/config/defaults.jswhenoutput.library.typeor anyentry[name].library.typeis"module"or"modern-module".lib/WebpackOptionsApply.jswhen!output.modulebut library type"module"or"modern-module"is enabled:library type "<type>" is only allowed when 'output.module' is enabled.test/harness/runner/index.jsso.mjsrunner tests with module library types are correctly dispatched to ESM execution.Fixes #22061.
What kind of change does this PR introduce?
bugfix
Did you add tests for your changes?
Yes:
test/Defaults.unittest.jstesting thatoutput.moduledefaults totrueforoutput.library.type: "module","modern-module", andentry[name].library.type: "module", and tests that a descriptive error is thrown whenoutput.module: falsewith module library types.test/configCases/library/module-default-output-module/verifying compilation and ESM execution without manually settingoutput.module: true.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?
Documentation for
output.library.type: "module"can note thatoutput.moduleis automatically enabled.Use of AI
Yes
Summary by CodeRabbit
moduleormodern-modulelibrary types, including per-entry libraries..mjslibrary bundles so they run correctly as ES modules in supported environments.