diff --git a/.changeset/fuzzy-falcons-tan.md b/.changeset/fuzzy-falcons-tan.md new file mode 100644 index 000000000000..45323269d56e --- /dev/null +++ b/.changeset/fuzzy-falcons-tan.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Marks internal `vite-plugin-fileurl` plugin with `enforce: 'pre'` diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index 23a4068a8bda..7fbfe60ddd71 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -151,7 +151,7 @@ export async function createVite( astroPrefetch({ settings }), astroTransitions({ settings }), astroDevToolbar({ settings, logger }), - vitePluginFileURL({}), + vitePluginFileURL(), astroInternationalization({ settings }), settings.config.experimental.serverIslands && vitePluginServerIslands({ settings }), astroContainer(), diff --git a/packages/astro/src/vite-plugin-fileurl/index.ts b/packages/astro/src/vite-plugin-fileurl/index.ts index 4a14323a0759..73132f3af979 100644 --- a/packages/astro/src/vite-plugin-fileurl/index.ts +++ b/packages/astro/src/vite-plugin-fileurl/index.ts @@ -1,8 +1,9 @@ import type { Plugin as VitePlugin } from 'vite'; -export default function vitePluginFileURL({}): VitePlugin { +export default function vitePluginFileURL(): VitePlugin { return { name: 'astro:vite-plugin-file-url', + enforce: 'pre', resolveId(source, importer) { if (source.startsWith('file://')) { const rest = source.slice(7); diff --git a/packages/integrations/preact/src/client.ts b/packages/integrations/preact/src/client.ts index fdf615659ea5..39ad1f0f6cf2 100644 --- a/packages/integrations/preact/src/client.ts +++ b/packages/integrations/preact/src/client.ts @@ -18,13 +18,13 @@ export default (element: HTMLElement) => let signalsRaw = element.dataset.preactSignals; if (signalsRaw) { const { signal } = await import('@preact/signals'); - let signals: Record = JSON.parse( + let signals: Record = JSON.parse( element.dataset.preactSignals!, ); for (const [propName, signalId] of Object.entries(signals)) { if (Array.isArray(signalId)) { - signalId.forEach(({ id, i }) => { - const [valueOfSignal, indexInProps] = props[propName][i]; + signalId.forEach(([id, indexInPropsArray]) => { + const [valueOfSignal, indexInProps] = props[propName][indexInPropsArray]; if (!sharedSignalMap.has(id)) { const signalValue = signal(valueOfSignal); sharedSignalMap.set(id, signalValue); diff --git a/packages/integrations/preact/src/signals.ts b/packages/integrations/preact/src/signals.ts index ad04ac9ce0cf..89eaabd568df 100644 --- a/packages/integrations/preact/src/signals.ts +++ b/packages/integrations/preact/src/signals.ts @@ -37,8 +37,8 @@ export function serializeSignals( props[key] = props[key].map((v: SignalLike, i: number) => i === index ? [signal.peek(), i] : v, ); - map.set(key, [...((map.get(key) || []) as []), [signal, index]]); + signals[key] = [...((signals[key] || []) as []), [getSignalId(ctx, signal), index]]; } });