Preoptimize renderers and hydration directives (#3568)
* Preoptimize renderers and hydration directives * Adds a changeset * Upgrade to Vite 2.9.12
This commit is contained in:
parent
d02578fd4c
commit
614769a39b
4 changed files with 22 additions and 14 deletions
5
.changeset/modern-toes-glow.md
Normal file
5
.changeset/modern-toes-glow.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fixes race condition causing the "self accepting" error message
|
|
@ -130,7 +130,7 @@
|
|||
"strip-ansi": "^7.0.1",
|
||||
"supports-esm": "^1.0.0",
|
||||
"tsconfig-resolver": "^3.0.1",
|
||||
"vite": "^2.9.10",
|
||||
"vite": "^2.9.12",
|
||||
"yargs-parser": "^21.0.1",
|
||||
"zod": "^3.17.3"
|
||||
},
|
||||
|
|
|
@ -36,20 +36,23 @@ export default async function dev(config: AstroConfig, options: DevOptions): Pro
|
|||
config = await runHookConfigSetup({ config, command: 'dev' });
|
||||
const { host, port } = config.server;
|
||||
|
||||
// load client runtime scripts ahead-of-time to fix "isSelfAccepting" bug during HMR
|
||||
const clientRuntimeScripts = await glob(
|
||||
new URL('../../runtime/client/*.js', import.meta.url).pathname
|
||||
);
|
||||
const clientRuntimeFilePaths = clientRuntimeScripts
|
||||
.map((script) => `astro/client/${path.basename(script)}`)
|
||||
// fixes duplicate dependency issue in monorepo when using astro: "workspace:*"
|
||||
.filter((filePath) => filePath !== 'astro/client/hmr.js');
|
||||
// The client entrypoint for renderers. Since these are imported dynamically
|
||||
// we need to tell Vite to preoptimize them.
|
||||
const rendererClientEntries = config._ctx.renderers.map(r => r.clientEntrypoint).filter(Boolean) as string[];
|
||||
|
||||
const viteConfig = await createVite(
|
||||
{
|
||||
mode: 'development',
|
||||
server: { host },
|
||||
optimizeDeps: {
|
||||
include: clientRuntimeFilePaths,
|
||||
include: [
|
||||
'astro/client/idle.js',
|
||||
'astro/client/load.js',
|
||||
'astro/client/visible.js',
|
||||
'astro/client/media.js',
|
||||
'astro/client/only.js',
|
||||
...rendererClientEntries
|
||||
],
|
||||
},
|
||||
},
|
||||
{ astroConfig: config, logging: options.logging, mode: 'dev' }
|
||||
|
|
|
@ -542,7 +542,7 @@ importers:
|
|||
strip-ansi: ^7.0.1
|
||||
supports-esm: ^1.0.0
|
||||
tsconfig-resolver: ^3.0.1
|
||||
vite: ^2.9.10
|
||||
vite: ^2.9.12
|
||||
yargs-parser: ^21.0.1
|
||||
zod: ^3.17.3
|
||||
dependencies:
|
||||
|
@ -599,7 +599,7 @@ importers:
|
|||
strip-ansi: 7.0.1
|
||||
supports-esm: 1.0.0
|
||||
tsconfig-resolver: 3.0.1
|
||||
vite: 2.9.10_sass@1.52.2
|
||||
vite: 2.9.12_sass@1.52.2
|
||||
yargs-parser: 21.0.1
|
||||
zod: 3.17.3
|
||||
devDependencies:
|
||||
|
@ -13612,8 +13612,8 @@ packages:
|
|||
fsevents: 2.3.2
|
||||
dev: false
|
||||
|
||||
/vite/2.9.10_sass@1.52.2:
|
||||
resolution: {integrity: sha512-TwZRuSMYjpTurLqXspct+HZE7ONiW9d+wSWgvADGxhDPPyoIcNywY+RX4ng+QpK30DCa1l/oZgi2PLZDibhzbQ==}
|
||||
/vite/2.9.12_sass@1.52.2:
|
||||
resolution: {integrity: sha512-suxC36dQo9Rq1qMB2qiRorNJtJAdxguu5TMvBHOc/F370KvqAe9t48vYp+/TbPKRNrMh/J55tOUmkuIqstZaew==}
|
||||
engines: {node: '>=12.2.0'}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
|
|
Loading…
Reference in a new issue