Skip to content

Commit

Permalink
fix(vite-node): mjs files watch not work (#3982)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing authored Oct 3, 2023
1 parent 271ec3d commit 77ea932
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/vite-node/src/externalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const defaultInline = [
]

const depsExternal = [
/\.cjs\.js$/,
/\.mjs$/,
/\/node_modules\/.*\.cjs\.js$/,
/\/node_modules\/.*\.mjs$/,
]

export function guessCJSversion(id: string): string | undefined {
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions test/vite-node/src/watch/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line no-console
console.log('test 1')
2 changes: 2 additions & 0 deletions test/vite-node/src/watch/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line no-console
console.log('test 1')
4 changes: 2 additions & 2 deletions test/vite-node/test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ it('script args in -- after', async () => {
expect(parseResult(cli1.stdout)).include('--version').include('--help')
})

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

0 comments on commit 77ea932

Please sign in to comment.