Cannot get final name for export “default” in “delegated …” with Webpack 3 scope hoisting

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

Bug report.

What is the current behavior?

This error occured when upgrading to webpack 3 and added scope hoisting using the new webpack.optimize.ModuleConcatenationPlugin() (line 92 in webpack.config.js).
When trying to build the project, app part, the one referencing the dlls, breaks with the following error:

ERROR in chunk js [entry]
app-[hash].js
Cannot get final name for export "default" in "delegated ./node_modules/lodash-es/_freeGlobal.js from dll-reference vendor_369f235e615c7d44cdbc" (known exports: true, known reexports: )

If the current behavior is a bug, please provide the steps to reproduce.

Repo reproducing the bug with steps to reproduce: https://github.com/markogresak/webpack-3-bug.

Without adding the scope hoisting plugin, it works fine, even with the webpack 3 update.
I’m not sure if there is a problem with the library or webpack itself. If there is a hack I could add to the config to avoid this error, that would work too.

What is the expected behavior?

The webpack command should not fail.

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.

Browser version: N/A
Node version: 8.1.2
Webpack version: 3.0.0
OS: macOS Sierra 10.12.5

Author: Fantashit

2 thoughts on “Cannot get final name for export “default” in “delegated …” with Webpack 3 scope hoisting

  1. Adding context to vendor DllPlugin solved it for me:

    My comment was actually misleading DllPlugin context so it would bundle without making use of the vendor bundle (dll) that’s why the error was gone.

  2. Ran into this today. Some of my findings:

    1. Our system was having import from 'react-router' and import from 'react-router-dom' at the same time, and the error message is complaining about:
    Cannot get final name for export "Route" in
    "delegated ../node_modules/react-router/es/index.js from dll-reference vendor"
    (known exports: true, known reexports: )
    
    1. And the contents of node_modules/react-router/es/index.js is:
    import _Route from './Route';
    export { _Route as Route };
    1. I suspect this bug may be related to ES2015 module re-export, so I change all imports to react-router-dom and it seems fixed the error.

    The warnings by CLI arg --display-optimization-bailout are still exists but it finally compiles and outputs the bundle.

Comments are closed.