Fix: refusing to accept isSelfAccepting
for JSX (#3521)
* fix: generate client directive scripts from metadata
* chore: changeset
* feat: add all runtime client scripts to optimized deps
* fix: remove hmr.js from optimized deps (monorepo-specific issue)
* Revert "fix: generate client directive scripts from metadata"
This reverts commit 56530a86ef
.
* refactor: move optimizedeps to dev only
* docs: add comment on why optimizdeps
* nit: indentation
This commit is contained in:
parent
574f47e885
commit
85b905495d
3 changed files with 17 additions and 1 deletions
5
.changeset/long-spies-check.md
Normal file
5
.changeset/long-spies-check.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fix isSelfAccepting errors when hydrating JSX components
|
|
@ -5,7 +5,6 @@ import { builtinModules } from 'module';
|
|||
import { fileURLToPath } from 'url';
|
||||
import fs from 'fs';
|
||||
import * as vite from 'vite';
|
||||
import { runHookServerSetup } from '../integrations/index.js';
|
||||
import astroVitePlugin from '../vite-plugin-astro/index.js';
|
||||
import astroViteServerPlugin from '../vite-plugin-astro-server/index.js';
|
||||
import astroPostprocessVitePlugin from '../vite-plugin-astro-postprocess/index.js';
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import glob from 'fast-glob';
|
||||
import path from 'path';
|
||||
import type { AddressInfo } from 'net';
|
||||
import type { AstroTelemetry } from '@astrojs/telemetry';
|
||||
import { performance } from 'perf_hooks';
|
||||
|
@ -33,10 +35,20 @@ export default async function dev(config: AstroConfig, options: DevOptions): Pro
|
|||
await options.telemetry.record([]);
|
||||
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');
|
||||
const viteConfig = await createVite(
|
||||
{
|
||||
mode: 'development',
|
||||
server: { host },
|
||||
optimizeDeps: {
|
||||
include: clientRuntimeFilePaths,
|
||||
}
|
||||
},
|
||||
{ astroConfig: config, logging: options.logging, mode: 'dev' }
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue