Skip to content

Commit

Permalink
fix: avoid importing all of lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Oct 17, 2024
1 parent 4c0c894 commit 808b130
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -987,7 +987,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]), []),
Expand Down
4 changes: 2 additions & 2 deletions lib/loader.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions spec/basic.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 808b130

Please sign in to comment.