Skip to content

Commit 4faa0a1

Browse files
authored
Migrate from rollup to rolldown (adazzle#3578)
* Migrate from rollup to rolldown * use defineConfig * tweak command * update rolldown * update rolldown * update rolldown config * don't need this * add todo, remove other comment * remove most babel deps * update rolldown * use output array * pin @vitest/eslint-plugin
1 parent 7f9fd89 commit 4faa0a1

File tree

5 files changed

+47
-79
lines changed

5 files changed

+47
-79
lines changed

babel.config.json

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
11
{
2-
"presets": [
3-
[
4-
"@babel/env",
5-
{
6-
"loose": true,
7-
"bugfixes": true,
8-
"shippedProposals": true
9-
}
10-
],
11-
["@babel/react", { "runtime": "automatic" }],
12-
"@babel/typescript"
13-
],
14-
"plugins": [
15-
"@babel/transform-runtime",
16-
["optimize-clsx", { "functionNames": ["getCellClassname"] }]
17-
]
2+
"presets": ["@babel/typescript"]
183
}

package.json

+3-12
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"start": "vite serve --clearScreen false",
3737
"preview": "vite preview",
3838
"build:website": "vite build",
39-
"build": "rollup --config --no-stdin",
39+
"build": "rolldown -c",
4040
"build:types": "tsc -p tsconfig.lib.json && api-extractor run --local --verbose",
4141
"test": "vitest run",
4242
"test:watch": "vitest watch",
@@ -55,21 +55,14 @@
5555
"clsx": "^2.0.0"
5656
},
5757
"devDependencies": {
58-
"@babel/core": "^7.26.0",
59-
"@babel/plugin-transform-runtime": "^7.25.9",
60-
"@babel/preset-env": "^7.26.0",
61-
"@babel/preset-react": "^7.26.3",
6258
"@babel/preset-typescript": "^7.26.0",
63-
"@babel/runtime": "^7.26.0",
6459
"@biomejs/biome": "1.9.4",
6560
"@eslint/compat": "^1.2.4",
6661
"@eslint/markdown": "^6.2.1",
6762
"@faker-js/faker": "^9.3.0",
6863
"@ianvs/prettier-plugin-sort-imports": "^4.0.2",
6964
"@linaria/core": "^6.0.0",
7065
"@microsoft/api-extractor": "^7.48.1",
71-
"@rollup/plugin-babel": "^6.0.4",
72-
"@rollup/plugin-node-resolve": "^16.0.0",
7366
"@tanstack/react-router": "^1.85.5",
7467
"@tanstack/router-plugin": "^1.69.1",
7568
"@testing-library/dom": "^10.1.0",
@@ -83,10 +76,9 @@
8376
"@vitejs/plugin-react": "^4.3.4",
8477
"@vitest/browser": "^2.1.8",
8578
"@vitest/coverage-v8": "^2.1.8",
86-
"@vitest/eslint-plugin": "^1.1.17",
79+
"@vitest/eslint-plugin": "1.1.20",
8780
"@wyw-in-js/rollup": "^0.5.0",
8881
"@wyw-in-js/vite": "^0.5.0",
89-
"babel-plugin-optimize-clsx": "^2.6.2",
9082
"browserslist": "^4.24.3",
9183
"eslint": "^9.17.0",
9284
"eslint-plugin-jest-dom": "^5.5.0",
@@ -105,8 +97,7 @@
10597
"react-dnd": "^16.0.1",
10698
"react-dnd-html5-backend": "^16.0.1",
10799
"react-dom": "^18.3.1",
108-
"rollup": "^4.28.1",
109-
"rollup-plugin-postcss": "^4.0.2",
100+
"rolldown": "^1.0.0-beta.1",
110101
"typescript": "~5.7.2",
111102
"vite": "^6.0.3",
112103
"vitest": "^2.1.8",

rolldown.config.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// @ts-check
2+
import { isAbsolute } from 'node:path';
3+
import wyw from '@wyw-in-js/rollup';
4+
import pkg from './package.json' with { type: 'json' };
5+
import { defineConfig } from 'rolldown';
6+
7+
export default defineConfig({
8+
input: './src/index.ts',
9+
output: [
10+
{
11+
dir: 'lib',
12+
entryFileNames: 'bundle.js',
13+
cssEntryFileNames: 'styles.css',
14+
format: 'es',
15+
sourcemap: true
16+
},
17+
{
18+
dir: 'lib',
19+
entryFileNames: 'bundle.cjs',
20+
cssEntryFileNames: 'styles.css',
21+
format: 'cjs',
22+
sourcemap: true
23+
}
24+
],
25+
platform: 'browser',
26+
external: (id) => !id.startsWith('.') && !isAbsolute(id),
27+
plugins: [
28+
// @ts-expect-error
29+
wyw({
30+
preprocessor: 'none',
31+
/**
32+
* @param {string} hash
33+
*/
34+
classNameSlug(hash) {
35+
// We add the package version as suffix to avoid style conflicts
36+
// between multiple versions of RDG on the same page.
37+
return `${hash}${pkg.version.replaceAll('.', '-')}`;
38+
}
39+
})
40+
]
41+
});

rollup.config.js

-50
This file was deleted.

tsconfig.js.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
"allowJs": true,
55
"module": "NodeNext",
66
"moduleResolution": "NodeNext",
7+
"resolveJsonModule": true,
78
"skipLibCheck": true
89
},
9-
"include": ["**/*.js", ".github/**/*.js"],
10+
"include": ["**/*.js", ".github/**/*.js", "package.json"],
1011
"exclude": ["./coverage/**/*", "./dist/**/*", "./lib/**/*"]
1112
}

0 commit comments

Comments
 (0)