ConcatenatedModulePlugin causes name collision in 3.5.0

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

What is the current behavior?
when ConcatenatedModulePlugin is enabled i get this error:

SyntaxError: Identifier 'server__default' has already been declared
16:56:45 server.1     |     at createScript (vm.js:74:10)
16:56:45 server.1     |     at Object.runInThisContext (vm.js:116:10)
16:56:45 server.1     |     at Module._compile (module.js:533:28)
16:56:45 server.1     |     at Object.Module._extensions..js (module.js:580:10)
16:56:45 server.1     |     at Module.load (module.js:503:32)
16:56:45 server.1     |     at tryModuleLoad (module.js:466:12)
16:56:45 server.1     |     at Function.Module._load (module.js:458:3)
16:56:45 server.1     |     at Function.Module.runMain (module.js:605:10)
16:56:45 server.1     |     at startup (bootstrap_node.js:158:16)
16:56:45 server.1     |     at bootstrap_node.js:575:3

If the current behavior is a bug, please provide the steps to reproduce.
sorry – i’ll can’t share the code right now, i’ll try to build a repo to reproduce this tomorrow. but the basic gist is that we have server.js:

import App from 'server/app'
import express from 'express'
const server = express()
// .. application code 
export default server

and server/app.js:

import { renderToString, renderToStaticMarkup } from 'react-dom/server'
// .. rest of application

looking into the bundled code i see:

// EXTERNAL MODULE: external "react-dom/server"
var server_ = __webpack_require__(313);
var server__default = /*#__PURE__*/__webpack_require__.n(server_);
// ...
// CONCATENATED MODULE: ../server.js
const server__default=server;/* harmony default export */ 
var server_0 = __webpack_exports__["default"] = (server__default);;

What is the expected behavior?
this shouldn’t happen – it didn’t happen before 3.5.0, works fine with 3.4.1. if i disable ModuleConcatenationPlugin in our config our app runs fine with 3.5.2.

If this is a feature request, what is motivation or use case for changing the behavior?

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
node 8.2.1
webpack 3.5.2
mac osx 10.12.6

Author: Fantashit

1 thought on “ConcatenatedModulePlugin causes name collision in 3.5.0

Comments are closed.