-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
@sveltejs/kit and vite@3 broke .svelte file processing in packages #5549
Comments
I'm having the same issue, and here is another work around (if you have a component library like me): before
now, i removed all the exports and to import something:
the build error is the same |
Thank you. It does help. |
another workaround is to add an ssr.noExternal entry for the problematic import that uses // vite.config.js
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [sveltekit()],
+ ssr: { noExternal: ['@rgossiaux/svelte-heroicons/**'] }
}); |
and here is a more generic workaround using a vite plugin to modify the ssr.noExternal configuration. import { sveltekit } from '@sveltejs/kit/vite';
/** @type {import('vite').UserConfig} */
const config = {
plugins: [
sveltekit(),
// utility plugin to append `/**` to strings in ssr.noExternal
{
name: 'vite-plugin-patch-ssr-noexternal',
enforce: 'post',
config(cfg) {
if (!cfg.ssr?.noExternal) return;
cfg.ssr.noExternal = cfg.ssr.noExternal.map((x) =>
typeof x !== 'string' || x.includes('*') || x.endsWith('/**') ? x : `${x}${!x.endsWith('/') ? '/' : ''}**`
);
}
}
]
};
export default config; |
It's merged |
yes, a vite release that includes the fix should be available in the next days. Until then you can continue to use one of the workarounds above or also something like pnpm patch to patch your local vite with that PR. |
The fix in Vite has been released in Vite 3.0.1. Upgrading to it should fix the issue. |
I test it with vite 3.0.2 and got the same error:
sample code: import Footer from "./footer/Footer.svelte";
export {
Footer,
}; tests/src/routes/__layout.svelte: <script lang="ts">
import {Footer} from "@higenku/theme"
</script> Source code: https://gitlab.com/higenku/sdks/theme currently on the |
I tried this: // vite.config.js
import { sveltekit } from '@sveltejs/kit/vite';
/** @type {import('vite').UserConfig} */
const config = {
plugins: [sveltekit(),
{
name: 'vite-plugin-patch-ssr-noexternal',
enforce: 'post',
config(cfg) {
if (!cfg.ssr?.noExternal) return;
cfg.ssr.noExternal = cfg.ssr.noExternal.map((x) =>
typeof x !== 'string' || x.includes('*') || x.endsWith('/**') ? x : `${x}${!x.endsWith('/') ? '/' : ''}**`
);
}
}
],
server: {
port: 3000,
},
deps: {
inline: ['@higenku/theme'],
}
};
export default config; but even this did not work |
Describe the bug
We use the excellent @rgossiaux/svelte-heroicons package to render icons, and the recent change in Sveltekit and Vite broke the project. The page now fails to load with a 500 error and a
Unknown file extension ".svelte"
message.The last known working version of Sveltekit is "1.0.0-next.360" with Vite "2.9.13".
This might be related to #5542
Reproduction
Here's a an example of the issue
Logs
System Info
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: