diff --git a/lib/loader.js b/lib/loader.js index 01c52cd9..cbc6e536 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -24,8 +24,9 @@ module.exports = function (source) { // The following part renders the template with lodash as aminimalistic loader // const template = _.template(source, _.defaults(options, { interpolate: /<%=([\s\S]+?)%>/g, variable: 'data' })); - // Require !!lodash - using !! will disable all loaders (e.g. babel) - return 'var _ = require(' + loaderUtils.stringifyRequest(this, '!!' + require.resolve('lodash')) + ');' + + // Use __non_webpack_require__ to enforce using the native nodejs require + // during template execution + return 'var _ = __non_webpack_require__(' + JSON.stringify(require.resolve('lodash')) + ');' + 'module.exports = function (templateParams) { with(templateParams) {' + // Execute the lodash template 'return (' + template.source + ')();' +