From 11835febdd5900703bbcae7ab494b27a85940eef Mon Sep 17 00:00:00 2001 From: Timeless0911 <1604889533@qq.com> Date: Mon, 2 Dec 2024 12:13:41 +0800 Subject: [PATCH] chore: use `resolve.alias` instead of `source.alias` --- .../core/tests/__snapshots__/config.test.ts.snap | 12 +++++++++--- packages/core/tests/config.test.ts | 12 +++++++++--- tests/integration/alias/rslib.config.ts | 2 ++ .../style/less/bundle-false/rslib.config.ts | 2 ++ tests/integration/style/less/bundle/rslib.config.ts | 2 ++ 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/packages/core/tests/__snapshots__/config.test.ts.snap b/packages/core/tests/__snapshots__/config.test.ts.snap index e338e3013..3959432da 100644 --- a/packages/core/tests/__snapshots__/config.test.ts.snap +++ b/packages/core/tests/__snapshots__/config.test.ts.snap @@ -113,11 +113,13 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config 1 "setup": [Function], }, ], - "source": { + "resolve": { "alias": { "bar": "bar", "foo": "foo/esm", }, + }, + "source": { "entry": {}, "preEntry": "./b.js", }, @@ -348,11 +350,13 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config 1 "setup": [Function], }, ], - "source": { + "resolve": { "alias": { "bar": "bar/cjs", "foo": "foo", }, + }, + "source": { "entry": {}, "preEntry": [ "./a.js", @@ -572,11 +576,13 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config 1 "setup": [Function], }, ], - "source": { + "resolve": { "alias": { "bar": "bar", "foo": "foo", }, + }, + "source": { "entry": {}, "preEntry": "./a.js", }, diff --git a/packages/core/tests/config.test.ts b/packages/core/tests/config.test.ts index 1932c272a..355254322 100644 --- a/packages/core/tests/config.test.ts +++ b/packages/core/tests/config.test.ts @@ -154,19 +154,23 @@ describe('Should compose create Rsbuild config correctly', () => { { format: 'esm', source: { + preEntry: './b.js', + }, + resolve: { alias: { foo: 'foo/esm', }, - preEntry: './b.js', }, }, { format: 'cjs', source: { + preEntry: ['./c.js', './d.js'], + }, + resolve: { alias: { bar: 'bar/cjs', }, - preEntry: ['./c.js', './d.js'], }, }, { @@ -174,11 +178,13 @@ describe('Should compose create Rsbuild config correctly', () => { }, ], source: { + preEntry: './a.js', + }, + resolve: { alias: { foo: 'foo', bar: 'bar', }, - preEntry: './a.js', }, output: { filenameHash: false, diff --git a/tests/integration/alias/rslib.config.ts b/tests/integration/alias/rslib.config.ts index 726c76eda..cb4546231 100644 --- a/tests/integration/alias/rslib.config.ts +++ b/tests/integration/alias/rslib.config.ts @@ -7,6 +7,8 @@ export default defineConfig({ entry: { index: './src/index.ts', }, + }, + resolve: { alias: { '@src': 'src', }, diff --git a/tests/integration/style/less/bundle-false/rslib.config.ts b/tests/integration/style/less/bundle-false/rslib.config.ts index b4afac27e..ac9f4baa0 100644 --- a/tests/integration/style/less/bundle-false/rslib.config.ts +++ b/tests/integration/style/less/bundle-false/rslib.config.ts @@ -11,6 +11,8 @@ export default defineConfig({ entry: { index: ['../__fixtures__/basic/src/**', '!../__fixtures__/**/*.d.ts'], }, + }, + resolve: { alias: { '~': require('node:path').resolve( __dirname, diff --git a/tests/integration/style/less/bundle/rslib.config.ts b/tests/integration/style/less/bundle/rslib.config.ts index b45dca44d..d7b7991c5 100644 --- a/tests/integration/style/less/bundle/rslib.config.ts +++ b/tests/integration/style/less/bundle/rslib.config.ts @@ -8,6 +8,8 @@ export default defineConfig({ entry: { index: ['../__fixtures__/basic/src/index.less'], }, + }, + resolve: { alias: { '~': require('node:path').resolve( __dirname,