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 + ')();' + diff --git a/spec/caching.spec.js b/spec/caching.spec.js index be263dd7..32ecd068 100644 --- a/spec/caching.spec.js +++ b/spec/caching.spec.js @@ -202,7 +202,7 @@ describe('HtmlWebpackPluginCaching', () => { .then(done); }); - it('should not slow down linear (15 plugins should not take twice as much time as a 1 plugin)', done => { + it('should not slow down linear (10 plugins should not take twice as much time as a 1 plugin)', done => { const template = path.join(__dirname, 'fixtures/plain.html'); const createHtmlWebpackPlugin = () => new HtmlWebpackPlugin({ template: template @@ -213,7 +213,7 @@ describe('HtmlWebpackPluginCaching', () => { let multiCompileRunDuration; let singleCompiler = setUpCompiler(createHtmlWebpackPlugin()); - let multiCompiler = setUpCompiler.apply(null, Array(15).fill(0).map(() => createHtmlWebpackPlugin())); + let multiCompiler = setUpCompiler.apply(null, Array(10).fill(0).map(() => createHtmlWebpackPlugin())); Promise.resolve() .then(function singleCompileRun () {