Using Webpack 2 Externals causes syntax error

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


What is the current behavior?

When externals config option is provided an array of external modules, it produces an output which causes syntax error in the bundle.

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

  • Add a module to externals array
  • Import it in a file
  • Build using webpack 2.2.0
  • Check output.

Github repo of buggy behavior


    externals: [


import test from 'buttercup-importer';


/* 1 */
/***/ (function(module, exports) {

module.exports = buttercup-importer;

/***/ }),

What is the expected behavior?

The output should not cause syntax error. Correct output:

/* 1 */
/***/ (function(module, exports) {

module.exports = require("buttercup-importer");

/***/ }),

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

Webpack: 2.2.0
Node: 7.4

Author: Fantashit

1 thought on “Using Webpack 2 Externals causes syntax error

Comments are closed.