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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nuxt): remove cast on rollup input for island chunks #26589

Merged
merged 4 commits into from
Apr 3, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion packages/nuxt/src/components/islandsTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,21 @@ export const componentsChunkPlugin = createUnplugin((options: ComponentChunkOpti
config.build.rollupOptions.input = config.build.rollupOptions.input || {}
// don't use 'strict', this would create another "facade" chunk for the entry file, causing the ssr styles to not detect everything
config.build.rollupOptions.preserveEntrySignatures = 'allow-extension'
const { rollupOptions } = config.build

// convert input to object syntax
if (!rollupOptions.input) { rollupOptions.input = {} }

if (typeof rollupOptions.input === 'string') {
rollupOptions.input = { entry: rollupOptions.input }
} else if (typeof rollupOptions.input === 'object' && Array.isArray(rollupOptions.input)) {
rollupOptions.input = rollupOptions.input.reduce<{ [key: string]: string }>((acc, input) => { acc[input] = input; return acc }, {})
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm absolutely unsure about this conversion.

}

const input = rollupOptions.input
for (const component of components) {
if (component.mode === 'client' || component.mode === 'all') {
(config.build.rollupOptions.input as Record<string, string>)[component.pascalName] = await resolvePath(component.filePath)
input[component.pascalName] = await resolvePath(component.filePath)
}
}
},
Expand Down