diff --git a/packages/rspack-test-tools/tests/configCases/loader/match-when-empty/a.js b/packages/rspack-test-tools/tests/configCases/loader/match-when-empty/a.js new file mode 100644 index 00000000000..f31c910d79c --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/loader/match-when-empty/a.js @@ -0,0 +1 @@ +export default "a.js" \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/configCases/loader/match-when-empty/index.js b/packages/rspack-test-tools/tests/configCases/loader/match-when-empty/index.js new file mode 100644 index 00000000000..a7ced44acc5 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/loader/match-when-empty/index.js @@ -0,0 +1,7 @@ +import a1 from "./a.js" with { type: "raw" }; +import a2 from "./a.js"; + +it("should hit loader", () => { + expect(a1).toEqual("export default \"a.js\""); + expect(a2).toEqual("loader.js"); +}); \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/configCases/loader/match-when-empty/loader.js b/packages/rspack-test-tools/tests/configCases/loader/match-when-empty/loader.js new file mode 100644 index 00000000000..290ed756509 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/loader/match-when-empty/loader.js @@ -0,0 +1,3 @@ +module.exports = function (content) { + return "export default 'loader.js'"; +}; diff --git a/packages/rspack-test-tools/tests/configCases/loader/match-when-empty/rspack.config.js b/packages/rspack-test-tools/tests/configCases/loader/match-when-empty/rspack.config.js new file mode 100644 index 00000000000..c76cdcb7d9e --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/loader/match-when-empty/rspack.config.js @@ -0,0 +1,26 @@ +module.exports = { + mode: "development", + entry: "./index.js", + devtool: false, + module: { + rules: [ + { + test: /a\.js/, + with: { + type: { + not: "raw" + } + }, + use: [ + { + loader: "./loader.js", + } + ] + }, + { + with: { type: "raw" }, + type: "asset/source" + } + ] + } +};