summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2022-06-10 12:38:19 -0400
committerGravatar GitHub <noreply@github.com> 2022-06-10 12:38:19 -0400
commit614769a39b4976dc292d1ed7fa1735811c0bdb8c (patch)
tree2987ecfdcaf332e026aa1d92c797ae058bad4f32
parentd02578fd4cab1a95980dbf6c0e5f12efb4aa9582 (diff)
downloadastro-614769a39b4976dc292d1ed7fa1735811c0bdb8c.tar.gz
astro-614769a39b4976dc292d1ed7fa1735811c0bdb8c.tar.zst
astro-614769a39b4976dc292d1ed7fa1735811c0bdb8c.zip
Preoptimize renderers and hydration directives (#3568)
* Preoptimize renderers and hydration directives * Adds a changeset * Upgrade to Vite 2.9.12
-rw-r--r--.changeset/modern-toes-glow.md5
-rw-r--r--packages/astro/package.json2
-rw-r--r--packages/astro/src/core/dev/index.ts21
-rw-r--r--pnpm-lock.yaml8
4 files changed, 22 insertions, 14 deletions
diff --git a/.changeset/modern-toes-glow.md b/.changeset/modern-toes-glow.md
new file mode 100644
index 000000000..cfab01c82
--- /dev/null
+++ b/.changeset/modern-toes-glow.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Fixes race condition causing the "self accepting" error message
diff --git a/packages/astro/package.json b/packages/astro/package.json
index cdecaf45f..d58c5a189 100644
--- a/packages/astro/package.json
+++ b/packages/astro/package.json
@@ -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"
},
diff --git a/packages/astro/src/core/dev/index.ts b/packages/astro/src/core/dev/index.ts
index 37a0e63ee..7c25bb17f 100644
--- a/packages/astro/src/core/dev/index.ts
+++ b/packages/astro/src/core/dev/index.ts
@@ -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' }
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d86bd07f1..f51f66a14 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -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: