Skip to content
Open
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 svelte@5.0.0
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@^8.0.0-beta.0
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<script>
const label = 'dependency-import';
import * as cjsOnly from 'e2e-test-dep-cjs-only';
const label = 'dependency-import';
const { cjs } = cjsOnly;
// 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
</script>

<div id="dependency-import"><span class="label">{label}</span></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
2 changes: 1 addition & 1 deletion packages/e2e-tests/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ function filterMessages(arr) {
const excludes = [];
if (isRolldownVite) {
excludes.push(
'Support for rolldown-vite in vite-plugin-svelte is experimental',
'Support for vite 8 beta in vite-plugin-svelte is experimental',
'See https://github.com/sveltejs/vite-plugin-svelte/issues/1143'
);
}
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
Loading