Do you want to request a feature or report a bug?
A bug, I think.
What is the current behavior?
At runtime, a .mjs module with injections from ProvidePlugin will throw an error at runtime, indicating that require is not defined. The final module code produced by webpack looks like this:
/*! no static exports found */
/***/ (function(module, exports) {
/* WEBPACK VAR INJECTION */(function(foo) {console.log(foo);
/* WEBPACK VAR INJECTION */}.call(this, require("/Users/aparker/src/notes/webpack4upgrade/mjs-provide/foo.js")))
/***/ })
/******/ });
(Note the call to require.)
If the current behavior is a bug, please provide the steps to reproduce.
You can reproduce the behavior using this repository.
What is the expected behavior?
The module should look more like this:
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(foo) {console.log(foo);
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./foo.js */ "./foo.js")))
/***/ })
/******/ });
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 -v: v9.11.1
webpack -v: 4.5.0
- OS: Mac OS 10.13.4
Do you want to request a feature or report a bug?
A bug, I think.
What is the current behavior?
At runtime, a
.mjsmodule with injections fromProvidePluginwill throw an error at runtime, indicating thatrequireis not defined. The final module code produced by webpack looks like this:(Note the call to
require.)If the current behavior is a bug, please provide the steps to reproduce.
You can reproduce the behavior using this repository.
What is the expected behavior?
The module should look more like this:
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 -v:v9.11.1webpack -v:4.5.0