From 748ce9b06f3c8a59666c807859efb6c72cdcff0f Mon Sep 17 00:00:00 2001 From: ahabhgk Date: Wed, 24 Apr 2024 13:30:59 +0800 Subject: [PATCH] add test --- packages/rspack/tests/configCases/resolve/roots/dir/a.js | 1 + packages/rspack/tests/configCases/resolve/roots/dir2/b.js | 1 + packages/rspack/tests/configCases/resolve/roots/index.js | 8 ++++++++ .../tests/configCases/resolve/roots/webpack.config.js | 3 +++ 4 files changed, 13 insertions(+) create mode 100644 packages/rspack/tests/configCases/resolve/roots/dir/a.js create mode 100644 packages/rspack/tests/configCases/resolve/roots/dir2/b.js create mode 100644 packages/rspack/tests/configCases/resolve/roots/index.js create mode 100644 packages/rspack/tests/configCases/resolve/roots/webpack.config.js diff --git a/packages/rspack/tests/configCases/resolve/roots/dir/a.js b/packages/rspack/tests/configCases/resolve/roots/dir/a.js new file mode 100644 index 000000000000..90bd54cd7f2e --- /dev/null +++ b/packages/rspack/tests/configCases/resolve/roots/dir/a.js @@ -0,0 +1 @@ +export default 'a' diff --git a/packages/rspack/tests/configCases/resolve/roots/dir2/b.js b/packages/rspack/tests/configCases/resolve/roots/dir2/b.js new file mode 100644 index 000000000000..691b3d450123 --- /dev/null +++ b/packages/rspack/tests/configCases/resolve/roots/dir2/b.js @@ -0,0 +1 @@ +export default "b" diff --git a/packages/rspack/tests/configCases/resolve/roots/index.js b/packages/rspack/tests/configCases/resolve/roots/index.js new file mode 100644 index 000000000000..444c90e74f66 --- /dev/null +++ b/packages/rspack/tests/configCases/resolve/roots/index.js @@ -0,0 +1,8 @@ +import a from "/dir/a"; + +it("should support roots", async () => { + expect(a).toBe("a"); + const b = "b"; // keep /dir2/ as a context module + const m = await import("/dir2/" + b); + expect(m.default).toBe("b") +}) diff --git a/packages/rspack/tests/configCases/resolve/roots/webpack.config.js b/packages/rspack/tests/configCases/resolve/roots/webpack.config.js new file mode 100644 index 000000000000..72afab4b02ae --- /dev/null +++ b/packages/rspack/tests/configCases/resolve/roots/webpack.config.js @@ -0,0 +1,3 @@ +module.exports = { + context: __dirname, +}