Skip to content

Commit eda853b

Browse files
fix: compatibility with ES modules output (#1795)
1 parent 706a160 commit eda853b

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

examples/default/dist/webpack-5/bundle.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
"use strict";
88
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
9-
/* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
9+
/* harmony export */ Z: () => (__WEBPACK_DEFAULT_EXPORT__)
1010
/* harmony export */ });
1111
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(609);
1212
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__);
@@ -117,7 +117,7 @@ var update = _node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js
117117

118118

119119

120-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_node_modules_css_loader_dist_cjs_js_main_css__WEBPACK_IMPORTED_MODULE_1__/* ["default"].locals */ .Z.locals || {});
120+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_node_modules_css_loader_dist_cjs_js_main_css__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z.locals || {});
121121

122122
/***/ }),
123123

examples/multi-page/dist/webpack-5/first.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
"use strict";
88
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
9-
/* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
9+
/* harmony export */ Z: () => (__WEBPACK_DEFAULT_EXPORT__)
1010
/* harmony export */ });
1111
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(609);
1212
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__);
@@ -117,7 +117,7 @@ var update = _node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js
117117

118118

119119

120-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_node_modules_css_loader_dist_cjs_js_main_css__WEBPACK_IMPORTED_MODULE_1__/* ["default"].locals */ .Z.locals || {});
120+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_node_modules_css_loader_dist_cjs_js_main_css__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z.locals || {});
121121

122122
/***/ }),
123123

examples/multi-page/dist/webpack-5/second.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
"use strict";
88
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
9-
/* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
9+
/* harmony export */ Z: () => (__WEBPACK_DEFAULT_EXPORT__)
1010
/* harmony export */ });
1111
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(609);
1212
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__);
@@ -117,7 +117,7 @@ var update = _node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js
117117

118118

119119

120-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_node_modules_css_loader_dist_cjs_js_main_css__WEBPACK_IMPORTED_MODULE_1__/* ["default"].locals */ .Z.locals || {});
120+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_node_modules_css_loader_dist_cjs_js_main_css__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z.locals || {});
121121

122122
/***/ }),
123123

lib/child-compiler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
/** @typedef {import("webpack/lib/Compiler.js")} WebpackCompiler */
44
/** @typedef {import("webpack/lib/Chunk.js")} WebpackChunk */
55
'use strict';
6+
67
/**
78
* @file
89
* This file uses webpack to compile a template with a child compiler.
910
*
1011
* [TEMPLATE] -> [JAVASCRIPT]
1112
*
1213
*/
13-
'use strict';
1414

1515
let instanceId = 0;
1616
/**

lib/loader.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ module.exports = function (source) {
2323
}
2424

2525
// Skip .js files (unless it's explicitly enforced)
26-
if (/\.js$/.test(this.resourcePath) && !force) {
26+
if (/\.(c|m)?js$/.test(this.resourcePath) && !force) {
2727
return source;
2828
}
2929

3030
// The following part renders the template with lodash as a minimalistic loader
3131
//
3232
const template = _.template(source, { interpolate: /<%=([\s\S]+?)%>/g, variable: 'data', ...options });
33-
// Use __non_webpack_require__ to enforce using the native nodejs require
33+
// Use `eval("require")("lodash")` to enforce using the native nodejs require
3434
// during template execution
35-
return 'var _ = __non_webpack_require__(' + JSON.stringify(require.resolve('lodash')) + ');' +
35+
return 'var _ = eval("require")(' + JSON.stringify(require.resolve('lodash')) + ');' +
3636
'module.exports = function (templateParams) { with(templateParams) {' +
3737
// Execute the lodash template
3838
'return (' + template.source + ')();' +

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"standard-version": "^9.3.0",
4545
"style-loader": "2.0.0",
4646
"typescript": "4.9.4",
47-
"webpack": "^5.79.0",
47+
"webpack": "^5.86.0",
4848
"webpack-cli": "4.5.0",
4949
"webpack-recompilation-simulator": "3.2.0"
5050
},

0 commit comments

Comments
 (0)