mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 14:48:41 +00:00
fix: add watch in fallback file load (#14938)
This commit is contained in:
parent
a92bc617cf
commit
b24b95119b
@ -722,6 +722,9 @@ export async function createPluginContainer(
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watchFiles.add(id)
|
||||||
|
if (watcher) ensureWatchedFile(watcher, id, root)
|
||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
|
|
||||||
|
10
playground/hmr-root/__tests__/hmr-root.spec.ts
Normal file
10
playground/hmr-root/__tests__/hmr-root.spec.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { expect, test } from 'vitest'
|
||||||
|
|
||||||
|
import { editFile, isServe, page, untilUpdated } from '~utils'
|
||||||
|
|
||||||
|
test.runIf(isServe)('should watch files outside root', async () => {
|
||||||
|
expect(await page.textContent('#foo')).toBe('foo')
|
||||||
|
editFile('foo.js', (code) => code.replace("'foo'", "'foobar'"))
|
||||||
|
await page.waitForEvent('load')
|
||||||
|
await untilUpdated(async () => await page.textContent('#foo'), 'foobar')
|
||||||
|
})
|
1
playground/hmr-root/foo.js
Normal file
1
playground/hmr-root/foo.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
export const foo = 'foo'
|
7
playground/hmr-root/root/index.html
Normal file
7
playground/hmr-root/root/index.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<div id="foo"></div>
|
||||||
|
|
||||||
|
<script type="module">
|
||||||
|
import { foo } from '../foo.js'
|
||||||
|
|
||||||
|
document.querySelector('#foo').textContent = foo
|
||||||
|
</script>
|
9
playground/hmr-root/vite.config.ts
Normal file
9
playground/hmr-root/vite.config.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import path from 'node:path'
|
||||||
|
import url from 'node:url'
|
||||||
|
import { defineConfig } from 'vite'
|
||||||
|
|
||||||
|
const __dirname = path.dirname(url.fileURLToPath(import.meta.url))
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
root: path.join(__dirname, './root'),
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user