Skip to content

Commit 77ea932

Browse files
authored
fix(vite-node): mjs files watch not work (#3982)
1 parent 271ec3d commit 77ea932

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
lines changed

packages/vite-node/src/externalize.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const defaultInline = [
1919
]
2020

2121
const depsExternal = [
22-
/\.cjs\.js$/,
23-
/\.mjs$/,
22+
/\/node_modules\/.*\.cjs\.js$/,
23+
/\/node_modules\/.*\.mjs$/,
2424
]
2525

2626
export function guessCJSversion(id: string): string | undefined {

test/vite-node/src/watch/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// eslint-disable-next-line no-console
2+
console.log('test 1')

test/vite-node/src/watch/index.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// eslint-disable-next-line no-console
2+
console.log('test 1')

test/vite-node/test/cli.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ it('script args in -- after', async () => {
3939
expect(parseResult(cli1.stdout)).include('--version').include('--help')
4040
})
4141

42-
it('correctly runs --watch', async () => {
43-
const entryPath = resolve(__dirname, '../src/watched.js')
42+
it.each(['index.js', 'index.cjs', 'index.mjs'])('correctly runs --watch %s', async (file) => {
43+
const entryPath = resolve(__dirname, '../src/watch', file)
4444
const cli = await runViteNodeCli('--watch', entryPath)
4545
await cli.waitForStdout('test 1')
4646
editFile(entryPath, c => c.replace('test 1', 'test 2'))

0 commit comments

Comments
 (0)