Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nine-lizards-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/vite-plugin-svelte': patch
---

Update experimental support for rolldown-vite to vite 8 beta
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ jobs:
os: ubuntu-latest
vite: 'baseline'
svelte: 'baseline'
# future test with rolldown-vite
# future test with vite-8-beta
- node: 24
os: ubuntu-latest
vite: 'rolldown-vite'
vite: '8-beta'
svelte: 'current'
steps:
- uses: actions/checkout@v5
Expand Down Expand Up @@ -128,17 +128,17 @@ jobs:
run: |
pnpm update -r --no-save [email protected]
pnpm ls svelte
- name: update vite to rolldown-vite
if: matrix.vite == 'rolldown-vite'
- name: update vite to vite-8-beta
if: matrix.vite == '8-beta'
run: |
pnpm update -r --no-save vite@npm:rolldown-vite@latest
pnpm ls rolldown-vite
pnpm update -r --no-save vite@beta
pnpm ls vite
- name: install playwright chromium
run: pnpm playwright install chromium
- name: run tests
run: pnpm test
- name: check-types with rolldown-vite
if: matrix.vite == 'rolldown-vite'
- name: check-types with vite-8-beta
if: matrix.vite == '8-beta'
run: pnpm check:types
- name: archive tests temp directory
if: failure()
Expand Down
3 changes: 2 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export default {
'packages/e2e-tests/dynamic-compile-options/src/components/A.svelte',
'packages/playground/big/src/pages/**', // lots of generated files
'packages/e2e-tests/scan-deps/src/Svelte*.svelte', // various syntax tests that require no format
'**/.vite-inspect/**'
'**/.vite-inspect/**',
'packages/e2e-tests/_test_dependencies/**/*.svelte' // TODO remove after sourcemap bug is fixed
],
options: {
rangeEnd: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const label = 'dependency-import';
import * as cjsOnly from 'e2e-test-dep-cjs-only';
const { cjs } = cjsOnly;
</script>
/* //TODO: move closing tag back to column zero after sourcemap bug is fixed */ </script>

<div id="dependency-import"><span class="label">{label}</span></div>
<div id="sticky-dep" class="sticky-dep">sticky-dep</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const label = 'dependency-import';
import * as cjsOnly from 'e2e-test-dep-cjs-only';
const { cjs } = cjsOnly;
</script>
/* //TODO: move closing tag back to column zero after sourcemap bug is fixed */ </script>

<div id="dependency-import"><span class="label">{label}</span></div>
<div id="sticky-dep" class="sticky-dep">sticky-dep</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { createCounter } from './Counter.svelte.js';
const counter = createCounter(0);
let localCounter = $state(0);
</script>
/* //TODO: move closing tag back to column zero after sourcemap bug is fixed */ </script>

<button onclick={counter.increment}>
count is {counter.count}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
export let message = '';
import { cjs_and_esm } from 'e2e-test-dep-cjs-and-esm';
import 'e2e-test-dep-scss-only';
</script>
/* //TODO: move closing tag back to column zero after sourcemap bug is fixed */
</script>

<div {id}>{message}</div>
<div id="cjs-and-esm">{cjs_and_esm()}</div>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
export let message = '';
import { cjs_and_esm } from 'e2e-test-dep-cjs-and-esm';
import 'e2e-test-dep-scss-only';
</script>
/* //TODO: move closing tag back to column zero after sourcemap bug is fixed */ </script>

<div {id}>{message}</div>
<div id="cjs-and-esm">{cjs_and_esm()}</div>
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<script>
const label = 'dependency-import';
import * as cjsOnly from 'e2e-test-dep-cjs-only';
const label = 'dependency-import';
const { cjs } = cjsOnly;
</script>
// moving the following script close tag to column 0 triggers a bug in svelte sourcemap creation that prevents rolldown optimizer from processing the sourcemap
// TODO: move it back after fixed in svelte see https://github.com/sveltejs/svelte/pull/17167
/* //TODO: move closing tag back to column zero after sourcemap bug is fixed */ </script>

<div id="dependency-import"><span class="label">{label}</span></div>
<div id="sticky-dep" class="sticky-dep">sticky-dep</div>
Expand Down
10 changes: 2 additions & 8 deletions packages/e2e-tests/scan-deps/__tests__/scan-deps.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import { e2eServer, getText } from '~utils';
import { getServerErrors, getText } from '~utils';
import { describe, expect, it } from 'vitest';
describe('vite import scan', () => {
it('should not fail to discover dependencies exported from script module', async () => {
// vite logs an error if scan fails but continues, so validate no errors logged
const errorLogs = e2eServer.logs.server.err.filter(
(line) =>
![
'Support for rolldown-vite in vite-plugin-svelte is experimental',
'See https://github.com/sveltejs/vite-plugin-svelte/issues/1143 for a list of known issues'
].some((ignore) => line.includes(ignore))
);
const errorLogs = getServerErrors();
expect(errorLogs.length, `unexpected errors:\n${errorLogs.join('\n')}`).toBe(0);
});
it('should work with exports from module context', async () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/e2e-tests/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,9 @@ function filterMessages(arr) {
const excludes = [];
if (isRolldownVite) {
excludes.push(
'Support for rolldown-vite in vite-plugin-svelte is experimental',
'See https://github.com/sveltejs/vite-plugin-svelte/issues/1143'
'Support for vite 8 beta in vite-plugin-svelte is experimental',
'See https://github.com/sveltejs/vite-plugin-svelte/issues/1143',
'`optimizeDeps.esbuildOptions`' //TODO: remove after sveltekit is updated
);
}
if (excludes.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugin-svelte/src/plugins/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const { version: viteVersion, rolldownVersion } = vite;
export function configure(api, inlineOptions) {
if (rolldownVersion) {
log.warn.once(
`!!! Support for rolldown-vite in vite-plugin-svelte is experimental (rolldown: ${rolldownVersion}, vite: ${viteVersion}) !!!
`!!! Support for vite 8 beta in vite-plugin-svelte is experimental (rolldown: ${rolldownVersion}, vite: ${viteVersion}) !!!
See https://github.com/sveltejs/vite-plugin-svelte/issues/1143 for a list of known issues and to report feedback.`.replace(
/\t+/g,
'\t'
Expand Down
4 changes: 2 additions & 2 deletions packages/vite-plugin-svelte/src/plugins/setup-optimizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function setupOptimizer(api) {
// the added plugins are patched in configResolved below
if (rolldownVersion) {
//@ts-ignore rolldown types not finished
optimizeDeps.rollupOptions = {
optimizeDeps.rolldownOptions = {
plugins: [
placeholderRolldownOptimizerPlugin(optimizeSveltePluginName),
placeholderRolldownOptimizerPlugin(optimizeSvelteModulePluginName)
Expand All @@ -65,7 +65,7 @@ export function setupOptimizer(api) {
if (rolldownVersion) {
const plugins =
// @ts-expect-error not typed
optimizeDeps.rollupOptions?.plugins?.filter((p) =>
optimizeDeps.rolldownOptions?.plugins?.filter((p) =>
[optimizeSveltePluginName, optimizeSvelteModulePluginName].includes(p.name)
) ?? [];
for (const plugin of plugins) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugin-svelte/src/types/compile.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface Code {
map?: any;
dependencies?: any[];
hasGlobal?: boolean;
moduleType?: string; //rolldown-vite
moduleType?: string; //vite-8 beta
meta?: {
vite?: CustomPluginOptionsVite;
};
Expand Down
4 changes: 2 additions & 2 deletions packages/vite-plugin-svelte/src/utils/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,9 @@ function validateViteConfig(extraViteConfig, config, options) {
if (rolldownVersion && isBuild) {
// read user config inlineConst value
const inlineConst =
//@ts-ignore optimization only exists in rolldown-vite
//@ts-ignore optimization only exists in vite-8 beta
config.build?.rolldownOptions?.optimization?.inlineConst ??
//@ts-ignore optimization only exists in rolldown-vite
//@ts-ignore optimization only exists in vite-8 beta
config.build?.rollupOptions?.optimization?.inlineConst;

if (inlineConst === false) {
Expand Down