diff --git a/index.js b/index.js index f4588af0..74c723fe 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,7 @@ const promisify = require("util").promisify; const vm = require("vm"); const fs = require("fs"); -const _ = require("lodash"); +const _uniq = require("lodash/uniq"); const path = require("path"); const { CachedChildCompilation } = require("./lib/cached-child-compiler"); @@ -990,7 +990,7 @@ class HtmlWebpackPlugin { * @private */ getAssetFiles(assets) { - const files = _.uniq( + const files = _uniq( Object.keys(assets) .filter((assetType) => assetType !== "chunks" && assets[assetType]) .reduce((files, assetType) => files.concat(assets[assetType]), []), diff --git a/lib/loader.js b/lib/loader.js index 8c385921..c9a69260 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -1,7 +1,7 @@ /* This loader renders the template with underscore if no other loader was found */ // @ts-nocheck "use strict"; -const _ = require("lodash"); +const _template = require("lodash/template"); module.exports = function (source) { // Get templating options @@ -34,7 +34,7 @@ module.exports = function (source) { // The following part renders the template with lodash as a minimalistic loader // - const template = _.template(source, { + const template = _template(source, { interpolate: /<%=([\s\S]+?)%>/g, variable: "data", ...options, diff --git a/spec/basic.spec.js b/spec/basic.spec.js index 6a415ea9..14cbef6b 100644 --- a/spec/basic.spec.js +++ b/spec/basic.spec.js @@ -9,7 +9,7 @@ const path = require("path"); const fs = require("fs"); const webpack = require("webpack"); const rimraf = require("rimraf"); -const _ = require("lodash"); +const _extend = require("lodash/extend"); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const webpackMajorVersion = Number( require("webpack/package.json").version.split(".")[0], @@ -2167,7 +2167,7 @@ describe("HtmlWebpackPlugin", () => { compilation, ).beforeEmit.tapAsync("HtmlWebpackPluginTest", (object, callback) => { eventFiredForFirstPlugin = true; - const result = _.extend(object, { + const result = _extend(object, { html: object.html + "Injected by first plugin", }); callback(null, result); @@ -2224,7 +2224,7 @@ describe("HtmlWebpackPlugin", () => { compilation, ).beforeEmit.tapAsync("HtmlWebpackPluginTest", (object, callback) => { eventFiredForFirstPlugin = true; - const result = _.extend(object, { + const result = _extend(object, { html: object.html + "Injected by first plugin", }); callback(null, result); @@ -2239,7 +2239,7 @@ describe("HtmlWebpackPlugin", () => { compilation, ).beforeEmit.tapAsync("HtmlWebpackPluginTest", (object, callback) => { eventFiredForSecondPlugin = true; - const result = _.extend(object, { + const result = _extend(object, { html: object.html + " Injected by second plugin", }); callback(null, result);