Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: refusing to accept isSelfAccepting for JSX #3521

Merged
merged 8 commits into from
Jun 6, 2022
5 changes: 5 additions & 0 deletions .changeset/long-spies-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix isSelfAccepting errors when hydrating JSX components
1 change: 0 additions & 1 deletion packages/astro/src/core/create-vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
12 changes: 12 additions & 0 deletions packages/astro/src/core/dev/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;


bholmesdev marked this conversation as resolved.
Show resolved Hide resolved
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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be a problem for astro files not in our monorepo, or is hmr.js always ready before the client needs it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it's always ready since we inject hmr.js as a hoisted script!

const viteConfig = await createVite(
{
mode: 'development',
server: { host },
optimizeDeps: {
include: clientRuntimeFilePaths,
}
},
{ astroConfig: config, logging: options.logging, mode: 'dev' }
);
Expand Down