Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid importing all of lodash #1853

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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]), []),
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
Loading