Skip to content

Commit a28f815

Browse files
committed
fix: add cwd to hmr test
1 parent 01090e0 commit a28f815

File tree

3 files changed

+36
-11
lines changed

3 files changed

+36
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"format": "prettier --write --cache .",
2424
"lint": "eslint --cache .",
2525
"typecheck": "tsc -p scripts --noEmit && pnpm -r --parallel run typecheck",
26-
"test": "pnpm test-unit && pnpm test-serve && pnpm test-build",
26+
"test": "pnpm test-unit && pnpm test-serve && pnpm run test-full-bundle-mode && pnpm test-build",
2727
"test-full-bundle-mode": "VITE_TEST_FULL_BUNDLE_MODE=1 vitest run -c vitest.config.e2e.ts",
2828
"test-serve": "vitest run -c vitest.config.e2e.ts",
2929
"test-build": "VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts",

packages/vite/src/node/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ async function buildEnvironment(
660660
// ? 'strict'
661661
// : false,
662662
// cache: options.watch ? undefined : false,
663-
cwd: root,
663+
// cwd: root,
664664
...options.rollupOptions,
665665
output: options.rollupOptions.output,
666666
input,

playground/hmr/vite.config.ts

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,41 @@ export default defineConfig({
1515
},
1616
rollupOptions: {
1717
input: [
18-
path.resolve(import.meta.dirname, 'accept-exports/dynamic-imports/index.html'),
19-
path.resolve(import.meta.dirname, 'accept-exports/export-from/index.html'),
20-
path.resolve(import.meta.dirname, 'accept-exports/main-accepted/index.html'),
21-
path.resolve(import.meta.dirname, 'accept-exports/main-non-accepted/index.html'),
22-
path.resolve(import.meta.dirname, 'accept-exports/side-effects/index.html'),
23-
path.resolve(import.meta.dirname, 'accept-exports/star-imports/index.html'),
24-
path.resolve(import.meta.dirname, 'accept-exports/unused-exports/index.html'),
18+
path.resolve(
19+
import.meta.dirname,
20+
'accept-exports/dynamic-imports/index.html',
21+
),
22+
path.resolve(
23+
import.meta.dirname,
24+
'accept-exports/export-from/index.html',
25+
),
26+
path.resolve(
27+
import.meta.dirname,
28+
'accept-exports/main-accepted/index.html',
29+
),
30+
path.resolve(
31+
import.meta.dirname,
32+
'accept-exports/main-non-accepted/index.html',
33+
),
34+
path.resolve(
35+
import.meta.dirname,
36+
'accept-exports/side-effects/index.html',
37+
),
38+
path.resolve(
39+
import.meta.dirname,
40+
'accept-exports/star-imports/index.html',
41+
),
42+
path.resolve(
43+
import.meta.dirname,
44+
'accept-exports/unused-exports/index.html',
45+
),
2546
path.resolve(import.meta.dirname, 'index.html'),
26-
]
27-
}
47+
],
48+
// TODO(underfin): find a nice way
49+
// The vite root not using `cwd` option call rolldown, the rolldown register module is base on process.cwd to calculate path.
50+
// make full bundle mode print the hmr path base on the dirname
51+
cwd: import.meta.dirname,
52+
},
2853
},
2954
plugins: [
3055
{

0 commit comments

Comments
 (0)