chore: migrate to rolldown

rolldown
Rich Harris 2 months ago
parent 85dcb91f7c
commit bc205c64d5

@ -3,5 +3,8 @@
| Feature | Chrome/Edge | Firefox | Safari |
| - | - | - | - |
| [`$state.snapshot`](/docs/svelte/$state#$state.snapshot) | 98 | 94 | 15.4 |
| [`bind:borderBoxSize`](/TODO) | <span style="color: var(--sk-fg-4)"></span> | 93 | not supported |
| [`bind:contentBoxSize`](/TODO) | <span style="color: var(--sk-fg-4)"></span> | 93 | not supported |
| [`bind:contentRect`](/TODO) | <span style="color: var(--sk-fg-4)"></span> | 93 | not supported |
| [`bind:devicePixelContentBoxSize`](/docs/svelte/bind#Dimensions) | <span style="color: var(--sk-fg-4)"></span> | 93 | not supported |
| [`flip` from `svelte/animate`](/docs/svelte/svelte-animate#flip) | <span style="color: var(--sk-fg-4)"></span> | 126 | <span style="color: var(--sk-fg-4)"></span> |

@ -138,8 +138,8 @@
"templating"
],
"scripts": {
"build": "rollup -c && pnpm generate && node scripts/check-treeshakeability.js",
"dev": "node scripts/process-messages -w & rollup -cw",
"build": "rolldown -c && pnpm generate && node scripts/check-treeshakeability.js",
"dev": "node scripts/process-messages -w & rolldown -cw",
"check": "tsc --project tsconfig.runtime.json && tsc && cd ./tests/types && tsc",
"check:tsgo": "tsgo --project tsconfig.runtime.json --skipLibCheck && tsgo --skipLibCheck",
"check:watch": "tsc --watch",
@ -153,16 +153,12 @@
"devDependencies": {
"@jridgewell/trace-mapping": "^0.3.25",
"@playwright/test": "^1.60.0",
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-virtual": "^3.0.2",
"@types/aria-query": "^5.0.4",
"@types/node": "^20.11.5",
"baseline-browser-mapping": "^2.10.32",
"dts-buddy": "^0.5.5",
"esbuild": "^0.25.10",
"rollup": "^4.59.0",
"rolldown": "^1.0.3",
"source-map": "^0.7.4",
"tinyglobby": "^0.2.12",
"typescript": "^5.5.4",

@ -1,7 +1,4 @@
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import { defineConfig } from 'rollup';
import { defineConfig } from 'rolldown';
// runs the version generation as a side-effect of importing
import './scripts/generate-version.js';
@ -12,6 +9,5 @@ export default defineConfig({
file: 'compiler/index.js',
format: 'umd',
name: 'svelte'
},
plugins: [resolve(), commonjs(), terser()]
}
});

@ -1,16 +1,15 @@
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import { rollup } from 'rollup';
import virtual from '@rollup/plugin-virtual';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import { rolldown } from 'rolldown';
import { virtual } from './virtual.js';
import { compile } from 'svelte/compiler';
/**
* @param {string} entry
*/
async function bundle_code(entry) {
const bundle = await rollup({
const bundle = await rolldown({
input: '__entry__',
plugins: [
virtual({
@ -24,10 +23,7 @@ async function bundle_code(entry) {
return path.resolve(entry.browser ?? entry.default);
}
}
},
nodeResolve({
exportConditions: ['production', 'import', 'browser', 'default']
})
}
],
onwarn: (warning, handle) => {
if (warning.code !== 'EMPTY_BUNDLE' && warning.code !== 'CIRCULAR_DEPENDENCY') {

@ -24,9 +24,8 @@ import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
import { rollup, type OutputChunk } from 'rollup';
import virtual from '@rollup/plugin-virtual';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import { rolldown, type OutputChunk } from 'rolldown';
import { virtual } from './virtual.js';
import { getCompatibleVersions } from 'baseline-browser-mapping';
import {
detect_features,
@ -54,6 +53,9 @@ type ConditionalRow = {
const doc_links: Record<string, string | null> = {
'`$state.snapshot`': '/docs/svelte/$state#$state.snapshot',
'`bind:contentRect`': '/TODO',
'`bind:contentBoxSize`': '/TODO',
'`bind:borderBoxSize`': '/TODO',
'`bind:devicePixelContentBoxSize`': '/docs/svelte/bind#Dimensions',
'`flip` from `svelte/animate`': '/docs/svelte/svelte-animate#flip'
};
@ -286,11 +288,11 @@ function safe_name(importee: string): string {
*
* `entry_code` is virtual module source: typically `export * from
* 'svelte/...'` for a runtime entry, or compiled fixture JS for a per-feature
* scan. `silent` suppresses rollup's circular-dependency warnings used for
* scan. `silent` suppresses rolldown's circular-dependency warnings used for
* fixture bundles where they're known and noisy.
*/
async function bundle(entry_code: string, options: { silent?: boolean } = {}): Promise<string> {
const built = await rollup({
const built = await rolldown({
input: '__entry__',
plugins: [
virtual({ __entry__: entry_code }),
@ -305,8 +307,7 @@ async function bundle(entry_code: string, options: { silent?: boolean } = {}): P
if (file) return path.resolve(pkg_dir, file);
}
}
},
nodeResolve({ exportConditions: ['production', 'import', 'browser', 'default'] })
}
],
// Treat optional peers / Node-only branches as external so we only scan
// code that actually runs in the browser.

@ -0,0 +1,18 @@
/**
*
* @param {Record<string, string>} modules
* @returns {import('rolldown').Plugin}
*/
export function virtual(modules) {
const resolved_ids = new Map(Object.entries(modules).map(([id, code]) => ['\0' + id, code]));
return {
name: 'virtual',
resolveId(id) {
if (id in modules) return '\0' + id;
},
load(id) {
return resolved_ids.get(id) ?? null;
}
};
}

@ -78,7 +78,7 @@ export function init_render_context() {
return als_import;
}
// this has to be a function because rollup won't treeshake it if it's a constant
// this has to be a function because rolldown won't treeshake it if it's a constant
function in_webcontainer() {
// @ts-ignore -- this will fail when we run typecheck because we exclude node types
// eslint-disable-next-line n/prefer-global/process

@ -21,7 +21,7 @@
"polka": "^1.0.0-next.25",
"svelte": "workspace:*",
"tinyglobby": "^0.2.12",
"vite": "^7.3.2",
"vite": "^8.0.16",
"vite-plugin-devtools-json": "^1.0.0",
"vite-plugin-inspect": "^11.3.3"
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save