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 — __webpack_module__ is rewritten to module, causing identifier collision with user-defined const module · Issue #20264 · webpack/webpack

__webpack_module__ is rewritten to module, causing identifier collision with user-defined const module #20264

New issue
Copy link
New issue
Copy link
Closed
#20265
Closed
__webpack_module__ is rewritten to module, causing identifier collision with user-defined const module#20264
#20265
Copy link
Assignees
xiaoxiaojx

Description

@SyMind
SyMind
opened on Dec 22, 2025
Issue body actions

Bug Description

When using __webpack_module__.id in source code, webpack rewrites it to module.id and generates a module factory with a function parameter named module. If the user also declares a variable named module, this creates a name collision/illegal redeclaration.

Source:

console.log(__webpack_module__.id);
const module = 'layout';
module;

Bundled output (excerpt):

/***/ ((module) => {

console.log(module.id);
const module = 'layout';
module;

/***/ })

This results in the user’s const module conflicting with the generated function parameter module (either a runtime bug or a SyntaxError due to redeclaration).

Uncaught SyntaxError: Identifier 'module' has already been declared

Link to Minimal Reproduction and step to reproduce

https://github.com/SyMind/webpack-module-collision

  1. pnpm install
  2. pnpm serve

Expected Behavior

Bundled output (excerpt):

/***/ ((__webpack_module__) => {

console.log(__webpack_module__.id);
const module = 'layout';
module;

/***/ })

Actual Behavior

Bundled output (excerpt):

/***/ ((module) => {

console.log(module.id);
const module = 'layout';
module;

/***/ })

Environment

System:
    OS: macOS 14.0
    CPU: (10) arm64 Apple M1 Pro
    Memory: 105.95 MB / 32.00 GB
  Binaries:
    Node: 22.20.0 - /Users/bytedance/.nvm/versions/node/v22.20.0/bin/node
    Yarn: 1.22.22 - /Users/bytedance/.nvm/versions/node/v22.20.0/bin/yarn
    npm: 10.9.3 - /Users/bytedance/.nvm/versions/node/v22.20.0/bin/npm
    pnpm: 10.23.0 - /Users/bytedance/.nvm/versions/node/v22.20.0/bin/pnpm
  Browsers:
    Chrome: 143.0.7499.147
    Firefox: 142.0.1
  Packages:
    html-loader: ^5.1.0 => 5.1.0 
    html-webpack-plugin: ^5.6.5 => 5.6.5 
    webpack: ^5.104.1 => 5.104.1 
    webpack-cli: ^6.0.1 => 6.0.1 
    webpack-dev-server: ^5.2.2 => 5.2.2

Is this a regression?

None

Last Working Version

No response

Additional Context

No response

Reacted by Xiao

Activity

  1. iashutoshyadav commented on Dec 22, 2025

    @iashutoshyadav
    iashutoshyadav
    on Dec 22, 2025 · Hidden as spam
    show commentMore actions
  2. xiaoxiaojx
    self-assigned this
    on Dec 22, 2025
  3. xiaoxiaojx
    added
    bug
    on Dec 22, 2025
  4. alexander-akait commented on Dec 22, 2025

    @alexander-akait
    alexander-akait
    on Dec 22, 2025
    Member
    More actions

    @SyMind Just interesting why do you want to use internal __webpack_module__.id?

  5. alexander-akait
    closed this as completedin #20265on Dec 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @xiaoxiaojx
    xiaoxiaojx

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    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.