@@ -36,7 +36,6 @@ import {
3636} from './module_ids.js' ;
3737import { import_peer } from '../../utils/import.js' ;
3838import { compact } from '../../utils/array.js' ;
39- import { crawlFrameworkPkgs } from 'vitefu' ;
4039
4140const cwd = process . cwd ( ) ;
4241
@@ -229,7 +228,7 @@ async function kit({ svelte_config }) {
229228 * Build the SvelteKit-provided Vite config to be merged with the user's vite.config.js file.
230229 * @see https://vitejs.dev/guide/api-plugin.html#config
231230 */
232- async config ( config , config_env ) {
231+ config ( config , config_env ) {
233232 initial_config = config ;
234233 vite_config_env = config_env ;
235234 is_build = config_env . command === 'build' ;
@@ -252,20 +251,6 @@ async function kit({ svelte_config }) {
252251
253252 const generated = path . posix . join ( kit . outDir , 'generated' ) ;
254253
255- const packages_depending_on_svelte_kit = (
256- await crawlFrameworkPkgs ( {
257- root : cwd ,
258- isBuild : is_build ,
259- viteUserConfig : config ,
260- isSemiFrameworkPkgByJson : ( pkg_json ) => {
261- return (
262- ! ! pkg_json . dependencies ?. [ '@sveltejs/kit' ] ||
263- ! ! pkg_json . peerDependencies ?. [ '@sveltejs/kit' ]
264- ) ;
265- }
266- } )
267- ) . ssr . noExternal ;
268-
269254 // dev and preview config can be shared
270255 /** @type {import('vite').UserConfig } */
271256 const new_config = {
@@ -299,7 +284,6 @@ async function kit({ svelte_config }) {
299284 `!${ kit . files . routes } /**/+*server.*`
300285 ] ,
301286 exclude : [
302- '@sveltejs/kit' ,
303287 // exclude kit features so that libraries using them work even when they are prebundled
304288 // this does not affect app code, just handling of imported libraries that use $app or $env
305289 '$app' ,
@@ -313,20 +297,7 @@ async function kit({ svelte_config }) {
313297 // that bundle later on from resolving the export conditions incorrectly
314298 // and for example include browser-only code in the server output
315299 // because they for example use esbuild.build with `platform: 'browser'`
316- 'esm-env' ,
317- // We need this for two reasons:
318- // 1. Without this, `@sveltejs/kit` imports are kept as-is in the server output,
319- // and that causes modules and therefore classes like `Redirect` to be imported twice
320- // under different IDs, which breaks a bunch of stuff because of failing instanceof checks.
321- // 2. Vitest bypasses Vite when loading external modules, so we bundle
322- // when it is detected to keep our virtual modules working.
323- // See https://github.com/sveltejs/kit/pull/9172
324- // and https://vitest.dev/config/#deps-registernodeloader
325- '@sveltejs/kit' ,
326- // We need to bundle any packages depending on @sveltejs /kit so that
327- // everyone uses the same instances of classes such as `Redirect`
328- // which we use in `instanceof` checks
329- ...packages_depending_on_svelte_kit
300+ 'esm-env'
330301 ]
331302 }
332303 } ;
0 commit comments