Skip to content

Commit dc0019c

Browse files
committed
Merge branch 'main' into refactor/modular-plugins
2 parents 01061c9 + b875b0c commit dc0019c

File tree

15 files changed

+103
-94
lines changed

15 files changed

+103
-94
lines changed

.changeset/nasty-ghosts-warn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/vite-plugin-svelte': major
3+
---
4+
5+
remove support for loading commonjs svelte config files

.changeset/real-cups-scream.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/vite-plugin-svelte': patch
3+
---
4+
5+
log known-issues link when using rolldown-vite

.changeset/tall-rivers-sleep.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/vite-plugin-svelte': minor
3+
---
4+
5+
add support for loading typescript svelte config files in runtimes that support it

packages/e2e-tests/configfile-custom/__tests__/configfile-custom.spec.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { it, expect } from 'vitest';
22
import { editViteConfig, isBuild, page, e2eServer } from '~utils';
3+
import { versions } from 'node:process';
4+
5+
const isNodeWithoutTypeStripping = Number(versions.node?.split('.', 1)[0]) < 22;
36

47
it('should load default config and work', async () => {
58
expect(e2eServer.logs.server.out).toContain('default svelte config loaded');
@@ -11,11 +14,11 @@ it('should load default config and work', async () => {
1114
if (!isBuild) {
1215
// editing vite config does not work in build tests, build only runs once
1316
// TODO split into different tests
14-
it('should load custom cjs config and work', async () => {
17+
it.skipIf(isNodeWithoutTypeStripping)('should load custom ts config and work', async () => {
1518
await editViteConfig((c) =>
16-
c.replace(/svelte\([^)]*\)/, "svelte({configFile:'svelte.config.custom.cjs'})")
19+
c.replace(/svelte\([^)]*\)/, "svelte({configFile:'svelte.config.custom.ts'})")
1720
);
18-
expect(e2eServer.logs.server.out).toContain('custom svelte config loaded cjs');
21+
expect(e2eServer.logs.server.out).toContain('custom svelte config loaded ts');
1922
expect(await page.textContent('h1')).toMatch('Hello world!');
2023
expect(await page.textContent('#test-child')).toBe('test-child');
2124
expect(await page.textContent('#dependency-import')).toBe('dependency-import');

packages/e2e-tests/configfile-custom/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"private": true,
44
"version": "1.0.0",
55
"scripts": {
6-
"dev": "vite",
7-
"build": "vite build",
6+
"dev": "cross-env NODE_OPTIONS=\"--experimental-strip-types\" vite",
7+
"build": "cross-env NODE_OPTIONS=\"--experimental-strip-types\" vite build",
88
"preview": "vite preview"
99
},
1010
"dependencies": {

packages/e2e-tests/configfile-custom/svelte.config.custom.cjs

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
console.log('custom svelte config loaded ts');
2+
import type { SvelteConfig } from '@sveltejs/vite-plugin-svelte';
3+
const config: SvelteConfig = {
4+
vitePlugin: {
5+
emitCss: false
6+
}
7+
};
8+
export default config;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
console.log('default svelte config loaded');
2-
module.exports = {};
2+
export default {};

packages/e2e-tests/hmr/__tests__/hmr.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ if (!isBuild) {
164164
});
165165

166166
test('should work with emitCss: false in svelte config', async () => {
167-
addFile('svelte.config.cjs', 'module.exports={vitePlugin:{emitCss:false}}');
167+
addFile('svelte.config.js', 'export default {vitePlugin:{emitCss:false}}');
168168
await waitForServerRestartAndPageReload();
169169
expect(await getColor('#hmr-test-1 .label')).toBe('red');
170-
removeFile('svelte.config.cjs');
170+
removeFile('svelte.config.js');
171171
});
172172

173173
test('should detect changes in svelte config and restart', async () => {
@@ -182,8 +182,8 @@ if (!isBuild) {
182182
}
183183
};
184184
await addFile(
185-
'svelte.config.cjs',
186-
`module.exports = {
185+
'svelte.config.js',
186+
`export default {
187187
preprocess:[{markup:${injectPreprocessor.toString()}}]};`
188188
);
189189
await waitForServerRestartAndPageReload();
@@ -196,7 +196,7 @@ if (!isBuild) {
196196
await updateHmrTest((content) => content.replace('color: red', 'color: green'));
197197
expect(await getColor('#hmr-test-1 .label')).toBe('green');
198198
expect(await getText('#hmr-test-1 .counter')).toBe('1');
199-
await editFile('svelte.config.cjs', (content) =>
199+
await editFile('svelte.config.js', (content) =>
200200
content
201201
.replace('preprocess-inject', 'preprocess-inject-2')
202202
.replace('Injected', 'Injected 2')
@@ -212,7 +212,7 @@ if (!isBuild) {
212212
await updateHmrTest((content) => content.replace('color: green', 'color: red'));
213213
expect(await getColor('#hmr-test-1 .label')).toBe('red');
214214
expect(await getText('#hmr-test-1 .counter')).toBe('1');
215-
await removeFile('svelte.config.cjs');
215+
await removeFile('svelte.config.js');
216216
await waitForServerRestartAndPageReload();
217217
expect(await getEl('#preprocess-inject-2')).toBe(null);
218218
expect(await getEl('#preprocess-inject')).toBe(null);

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

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ import {
1616

1717
import glob from 'tiny-glob';
1818
import path from 'node:path';
19-
import { defaultClientConditions, defaultClientMainFields } from 'vite';
19+
import { env } from 'node:process';
20+
import * as vite from 'vite';
21+
const {
22+
defaultClientConditions,
23+
defaultClientMainFields,
24+
//@ts-expect-error not typed in vite
25+
rolldownVersion
26+
} = vite;
2027
import { describe, expect, it } from 'vitest';
2128

2229
describe('kit-node', () => {
@@ -93,18 +100,23 @@ describe('kit-node', () => {
93100
});
94101

95102
if (isBuild) {
96-
it('should not include dynamic import from onmount in ssr output', async () => {
97-
const ssrManifest = JSON.parse(
98-
readFileContent('.svelte-kit/output/server/.vite/manifest.json')
99-
);
100-
const serverFilesSrc = Object.values(ssrManifest)
101-
.filter((e) => !!e.src)
102-
.map((e) => e.src);
103-
const includesClientOnlyModule = serverFilesSrc.some((file: string) =>
104-
file.includes('client-only-module')
105-
);
106-
expect(includesClientOnlyModule).toBe(false);
107-
});
103+
// this is known to fail, skip the test in our own CI but keep it in ecosystem-ci so that rolldown-vite-ecosystem-ci still gets this fail
104+
// TODO remove skip once fixed
105+
it.skipIf(rolldownVersion && !env.ECOSYSTEM_CI)(
106+
'should not include dynamic import from onMount in ssr output',
107+
async () => {
108+
const ssrManifest = JSON.parse(
109+
readFileContent('.svelte-kit/output/server/.vite/manifest.json')
110+
);
111+
const serverFilesSrc = Object.values(ssrManifest)
112+
.filter((e) => !!e.src)
113+
.map((e) => e.src);
114+
const includesClientOnlyModule = serverFilesSrc.some((file: string) =>
115+
file.includes('client-only-module')
116+
);
117+
expect(includesClientOnlyModule).toBe(false);
118+
}
119+
);
108120
it('should include dynamic import from onmount in client output', async () => {
109121
const clientManifest = JSON.parse(
110122
readFileContent('.svelte-kit/output/client/.vite/manifest.json')

0 commit comments

Comments
 (0)