Skip to content

Commit 68abba8

Browse files
committed
Remove svelte/ssr resolving
1 parent f112d8b commit 68abba8

File tree

6 files changed

+2
-44
lines changed

6 files changed

+2
-44
lines changed

packages/e2e-tests/kit-node/__tests__/kit.spec.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,6 @@ describe('kit-node', () => {
7575
});
7676
});
7777

78-
it('should load dynamic import in onMount', async () => {
79-
// expect log to contain message with dynamic import value from onMount
80-
expect(browserLogs.some((x) => x === 'onMount dynamic imported isSSR: false')).toBe(true);
81-
});
82-
83-
if (isBuild) {
84-
it('should not include dynamic import from onmount in ssr output', async () => {
85-
const app = readFileContent(path.join('.svelte-kit', 'output', 'server', 'app.js'));
86-
expect(app.includes('__SHOULD_NOT_BE_IN_SSR_APP_JS')).toBe(false);
87-
});
88-
}
89-
9078
if (!isBuild) {
9179
describe('hmr', () => {
9280
const updateIndexSvelte = editFileAndWaitForHmrComplete.bind(

packages/e2e-tests/kit-node/src/client-only-module.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/e2e-tests/kit-node/src/routes/index.svelte

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
export let load_status = 'NOT_LOADED';
2828
let mount_status = 'BEFORE_MOUNT';
2929
onMount(async () => {
30-
const isSSR = (await import('../client-only-module.js')).default;
31-
console.log(`onMount dynamic imported isSSR: ${isSSR}`);
3230
mount_status = 'AFTER_MOUNT';
3331
});
3432
setSomeContext();

packages/vite-plugin-svelte/src/index.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { VitePluginSvelteCache } from './utils/vite-plugin-svelte-cache';
1616
import { ensureWatchedFile, setupWatchers } from './utils/watch';
1717
import { resolveViaPackageJsonSvelte } from './utils/resolve';
1818
import { addExtraPreprocessors } from './utils/preprocess';
19-
import { PartialResolvedId } from 'rollup';
2019

2120
export function svelte(inlineOptions?: Partial<Options>): Plugin {
2221
if (process.env.DEBUG != null) {
@@ -37,8 +36,6 @@ export function svelte(inlineOptions?: Partial<Options>): Plugin {
3736
) => Promise<CompileData>;
3837
/* eslint-enable no-unused-vars */
3938

40-
let resolvedSvelteSSR: Promise<PartialResolvedId | null>;
41-
4239
return {
4340
name: 'vite-plugin-svelte',
4441
// make sure our resolver runs before vite internal resolver to resolve svelte field correctly
@@ -104,25 +101,6 @@ export function svelte(inlineOptions?: Partial<Options>): Plugin {
104101
return importee; // query with svelte tag, an id we generated, no need for further analysis
105102
}
106103

107-
if (ssr && importee === 'svelte') {
108-
if (!resolvedSvelteSSR) {
109-
resolvedSvelteSSR = this.resolve('svelte/ssr', undefined, { skipSelf: true }).then(
110-
(svelteSSR) => {
111-
log.debug('resolved svelte to svelte/ssr');
112-
return svelteSSR;
113-
},
114-
(err) => {
115-
log.debug(
116-
'failed to resolve svelte to svelte/ssr. Update svelte to a version that exports it',
117-
err
118-
);
119-
return null; // returning null here leads to svelte getting resolved regularly
120-
}
121-
);
122-
}
123-
return resolvedSvelteSSR;
124-
}
125-
126104
try {
127105
const resolved = resolveViaPackageJsonSvelte(importee, importer);
128106
if (resolved) {

packages/vite-plugin-svelte/src/utils/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export const SVELTE_IMPORTS = [
77
'svelte/easing',
88
'svelte/internal',
99
'svelte/motion',
10-
'svelte/ssr',
1110
'svelte/store',
1211
'svelte/transition',
1312
'svelte'

packages/vite-plugin-svelte/src/utils/options.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,8 @@ function buildOptimizeDepsForSvelte(
242242
);
243243
};
244244
if (!isExcluded('svelte')) {
245-
const svelteImportsToInclude = SVELTE_IMPORTS.filter((x) => x !== 'svelte/ssr'); // not used on clientside
246-
log.debug(
247-
`adding bare svelte packages to optimizeDeps.include: ${svelteImportsToInclude.join(', ')} `
248-
);
249-
include.push(...svelteImportsToInclude.filter((x) => !isIncluded(x)));
245+
log.debug(`adding bare svelte packages to optimizeDeps.include: ${SVELTE_IMPORTS.join(', ')} `);
246+
include.push(...SVELTE_IMPORTS.filter((x) => !isIncluded(x)));
250247
} else {
251248
log.debug('"svelte" is excluded in optimizeDeps.exclude, skipped adding it to include.');
252249
}

0 commit comments

Comments
 (0)