Skip to content

Commit 7f21910

Browse files
committed
fix: Prevent lodash from being inlined to work around a babel-loader incompatibility
fix #1223
1 parent d1bcd95 commit 7f21910

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/loader.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ module.exports = function (source) {
2424
// The following part renders the template with lodash as a minimalistic loader
2525
//
2626
const template = _.template(source, _.defaults(options, { interpolate: /<%=([\s\S]+?)%>/g, variable: 'data' }));
27-
// Require !!lodash - using !! will disable all loaders (e.g. babel)
28-
return 'var _ = require(' + loaderUtils.stringifyRequest(this, '!!' + require.resolve('lodash')) + ');' +
27+
// Use __non_webpack_require__ to enforce using the native nodejs require
28+
// during template execution
29+
return 'var _ = __non_webpack_require__(' + JSON.stringify(require.resolve('lodash')) + ');' +
2930
'module.exports = function (templateParams) { with(templateParams) {' +
3031
// Execute the lodash template
3132
'return (' + template.source + ')();' +

0 commit comments

Comments
 (0)