Skip to content

CommonsChunkPlugin can break chunks when extracting entry modules #4795

@jbellenger

Description

@jbellenger

Do you want to request a feature or report a bug?
bug

What is the current behavior?
CommonsChunkPlugin can extract a chunks entryModule in a way that breaks the chunk.
Example: In this gist, chunk pageA.b287e3.js has entry module ./entry.js, which is neither contained within the chunk nor automatically loaded by the webpack runtime.
Trying to load chunk pageA.b287e3.js tenders this uncaught error:

Uncaught TypeError: Cannot read property 'call' of undefined
    at __webpack_require__ (manifest.cc96ba.js:55)
    at webpackJsonpCallback (manifest.cc96ba.js:26)
    at pageA.b287e3.js:1

If the current behavior is a bug, please provide the steps to reproduce.
Repro repo at https://github.com/jbellenger/CommonsChunkPlugin-async-testcase
Gist of build results at https://gist.github.com/jbellenger/f16429c8787969591e245d024c75db69

What is the expected behavior?
CommonsChunkPlugin should not modify chunks in ways that prevents them from loading. Either of these might fix the issue:

  • a chunks entryModule should never be extracted
  • an async chunk should be loaded by the runtime before the modified chunk is executed

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
This is observed in webpack@2.4.1, node 6.9.5, on osx 10.11.6.
I originally reported this as globalize-webpack-plugin issue 44. After seeing different behavior using webpack@1, I suspect this is an issue with CommonsChunkPlugin in webpack@2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions