From 94ad699baa1805a0646e7db1d69eb5997df6c8db Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Thu, 7 Oct 2021 17:56:58 +0300 Subject: [PATCH] fix: infinity applying loaders leading to memory allocation fail (#849) --- src/loader.js | 6 +++-- .../ignore-other-loaders/expected/main.css | 4 ++++ test/cases/ignore-other-loaders/index.js | 1 + test/cases/ignore-other-loaders/other.css | 3 +++ test/cases/ignore-other-loaders/style.css | 3 +++ .../ignore-other-loaders/webpack.config.js | 23 +++++++++++++++++++ 6 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 test/cases/ignore-other-loaders/expected/main.css create mode 100644 test/cases/ignore-other-loaders/index.js create mode 100644 test/cases/ignore-other-loaders/other.css create mode 100644 test/cases/ignore-other-loaders/style.css create mode 100644 test/cases/ignore-other-loaders/webpack.config.js diff --git a/src/loader.js b/src/loader.js index 001b0fd2..6dac3261 100644 --- a/src/loader.js +++ b/src/loader.js @@ -213,7 +213,7 @@ export function pitch(request) { )}`; this.importModule( - `${this.resourcePath}.webpack[javascript/auto]!=!${request}`, + `${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, { layer: options.layer, publicPath: publicPathForExtract, @@ -366,4 +366,6 @@ export function pitch(request) { } // eslint-disable-next-line func-names -export default function () {} +export default function (content) { + console.log(content); +} diff --git a/test/cases/ignore-other-loaders/expected/main.css b/test/cases/ignore-other-loaders/expected/main.css new file mode 100644 index 00000000..cebc5c1c --- /dev/null +++ b/test/cases/ignore-other-loaders/expected/main.css @@ -0,0 +1,4 @@ +body { + background: red; +} + diff --git a/test/cases/ignore-other-loaders/index.js b/test/cases/ignore-other-loaders/index.js new file mode 100644 index 00000000..4fe51c72 --- /dev/null +++ b/test/cases/ignore-other-loaders/index.js @@ -0,0 +1 @@ +import "./style.css"; diff --git a/test/cases/ignore-other-loaders/other.css b/test/cases/ignore-other-loaders/other.css new file mode 100644 index 00000000..d005c9f3 --- /dev/null +++ b/test/cases/ignore-other-loaders/other.css @@ -0,0 +1,3 @@ +.color { + color: red; +} diff --git a/test/cases/ignore-other-loaders/style.css b/test/cases/ignore-other-loaders/style.css new file mode 100644 index 00000000..67ce83e4 --- /dev/null +++ b/test/cases/ignore-other-loaders/style.css @@ -0,0 +1,3 @@ +body { + background: red; +} diff --git a/test/cases/ignore-other-loaders/webpack.config.js b/test/cases/ignore-other-loaders/webpack.config.js new file mode 100644 index 00000000..394fd463 --- /dev/null +++ b/test/cases/ignore-other-loaders/webpack.config.js @@ -0,0 +1,23 @@ +import Self from "../../../src"; + +module.exports = { + entry: "./index.js", + module: { + rules: [ + { + test: /\.css|\.less$/, + use: [ + { + loader: Self.loader, + }, + "css-loader", + ], + }, + ], + }, + plugins: [ + new Self({ + filename: "[name].css", + }), + ], +};