Do you want to request a feature or report a bug?
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.
Example:
externals: [
'buttercup-importer'
]
File:
import test from 'buttercup-importer';
console.log(test);
Output:
/* 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
Never mind, found the issue.
libraryTarget
option needs to be set in order to fix this. More:https://webpack.js.org/configuration/output/#output-librarytarget
I think
externals
docs should be more clear.