GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(config): default output.module to true when using module library type by Pcmhacker-piro · Pull Request #22063 · webpack/webpack

Conversation

@Pcmhacker-piro

@Pcmhacker-piro Pcmhacker-piro commented Sep 11, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

Following the removal of experiments.outputModule in #22011, output.module should default to true whenever an ESM output is configured.

Previously, output.module only defaulted to true when targeting universal, deno, or bun (tp.node === null && tp.web === null && tp.module !== false, tp.deno === true, tp.bun === true). If a user configured output.library.type: "module" or "modern-module" (or set it per-entry in entry[name].library.type: "module"), output.module remained false.

As a consequence:

  1. output.iife defaulted to true (because !output.module).
  2. Webpack wrapped the output in an IIFE (() => { ... })().
  3. ModuleLibraryPlugin emitted export default ... inside the IIFE body:
    (() => {
    // ...
    export default __webpack_exports__;
    })();
  4. This emitted invalid JavaScript syntax, throwing a runtime SyntaxError: Unexpected token 'export' and failing Terser minification in production ("Export" statement may only appear at the top level).
  5. Furthermore, configuring output: { module: false, library: { type: "module" } } was not guarded, allowing conflicting options to produce invalid code silently.

This PR:

  • Defaults output.module to true in lib/config/defaults.js when output.library.type or any entry[name].library.type is "module" or "modern-module".
  • Adds an explicit error in lib/WebpackOptionsApply.js when !output.module but library type "module" or "modern-module" is enabled: library type "<type>" is only allowed when 'output.module' is enabled.
  • Updates test/harness/runner/index.js so .mjs runner 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:

  • Unit tests in test/Defaults.unittest.js testing that output.module defaults to true for output.library.type: "module", "modern-module", and entry[name].library.type: "module", and tests that a descriptive error is thrown when output.module: false with module library types.
  • Integration config test in test/configCases/library/module-default-output-module/ verifying compilation and ESM execution without manually setting output.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 that output.module is automatically enabled.

Use of AI

Yes

Summary by CodeRabbit

  • New Features
    • Module output is now enabled by default when using the module or modern-module library types, including per-entry libraries.
    • ES module libraries can now be used without explicitly setting module output.
  • Bug Fixes
    • Added clear validation errors when module library types are configured with module output disabled.
    • Improved handling of .mjs library bundles so they run correctly as ES modules in supported environments.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Pcmhacker-piro
fix(config): default output.module to true when using module library …
e0d04f2
…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-bot

changeset-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e0d04f2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack Patch

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the area: config Options, defaults, validation (lib/config, schemas/) label Sep 11, 2026
@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

👋 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
and leave a comment explaining why this is a mistake.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot closed this Sep 11, 2026
@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 6d94bf5d-620e-4ea7-bdb4-2318df26d1f4

📥 Commits

Reviewing files that changed from the base of the PR and between 3a69d29 and e0d04f2.

📒 Files selected for processing (9)
  • .changeset/008-library-module-output-default.md
  • lib/WebpackOptionsApply.js
  • lib/config/defaults.js
  • test/Defaults.unittest.js
  • test/configCases/library/module-default-output-module/dep.js
  • test/configCases/library/module-default-output-module/index.js
  • test/configCases/library/module-default-output-module/test.config.js
  • test/configCases/library/module-default-output-module/webpack.config.js
  • test/harness/runner/index.js

📝 Walkthrough

Walkthrough

Webpack now defaults output.module to true for "module" and "modern-module" library types. It rejects explicit incompatible settings and adds unit, configuration-case, and ESM runner coverage.

Changes

Module library output

Layer / File(s) Summary
Module output defaults
lib/config/defaults.js
Module output detection covers top-level and entry-level "module" and "modern-module" libraries. The shared entry iterator replaces a duplicate helper.
Incompatible output validation
lib/WebpackOptionsApply.js, .changeset/008-library-module-output-default.md
Webpack throws when these library types are combined with output.module: false. The changeset records the patch.
Configuration and runner coverage
test/Defaults.unittest.js, test/configCases/library/module-default-output-module/*, test/harness/runner/index.js
Tests verify defaults, validation errors, emitted module execution, and .mjs ESM runner selection.

Suggested reviewers: alexander-akait

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.

❤️ Share
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Pcmhacker-piro

Pcmhacker-piro commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

@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 output.library.type: 'module' defaults output.module to false, emitting invalid JavaScript with an export statement wrapped inside an IIFE).

  • EasyCLA is signed and passing.
  • All code/commit quality checks passed (conventional commit format, commit author match, newline, etc.).
  • Unit tests added in test/Defaults.unittest.js and an end-to-end integration test in test/configCases/library/module-default-output-module/.
  • Valid patch changeset included in .changeset/008-library-module-output-default.md.
  • All linters, formatting, and spell checks pass cleanly.

Could a maintainer please reopen this PR for review? Thank you!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Pcmhacker-piro Pcmhacker-piro mentioned this pull request Sep 11, 2026
output.library.type: 'module' defaults output.module to false, emitting invalid JavaScript (export inside IIFE) #22061
Closed
@avivkeller

avivkeller commented Sep 11, 2026

Copy link
Copy Markdown
Member

User created 8 fork(s) in a 24-hour window, exceeds maximum of 4

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@avivkeller avivkeller added the exempt [Exempt from Quality Checks] label Sep 11, 2026
@avivkeller avivkeller reopened this Sep 11, 2026
@alexander-akait

alexander-akait commented Sep 12, 2026

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait alexander-akait closed this Sep 12, 2026
@alexander-akait alexander-akait mentioned this pull request Sep 12, 2026
fix(config): default output.module to true for module library types #22071
Merged
@alexander-akait Claude

alexander-akait commented Sep 12, 2026

Copy link
Copy Markdown
Member

Closing as a duplicate of #22064, both superseded by #22071 — thanks for the report.


Generated by Claude Code

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

area: config Options, defaults, validation (lib/config, schemas/) exempt [Exempt from Quality Checks]

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

output.library.type: 'module' defaults output.module to false, emitting invalid JavaScript (export inside IIFE)

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@Pcmhacker-piro @avivkeller @alexander-akait
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.