Skip to content

Commit

Permalink
Migrate from rollup to rolldown (#3578)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nstepien authored Dec 29, 2024
1 parent 7f9fd89 commit 4faa0a1
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 79 deletions.
17 changes: 1 addition & 16 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
{
"presets": [
[
"@babel/env",
{
"loose": true,
"bugfixes": true,
"shippedProposals": true
}
],
["@babel/react", { "runtime": "automatic" }],
"@babel/typescript"
],
"plugins": [
"@babel/transform-runtime",
["optimize-clsx", { "functionNames": ["getCellClassname"] }]
]
"presets": ["@babel/typescript"]
}
15 changes: 3 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"start": "vite serve --clearScreen false",
"preview": "vite preview",
"build:website": "vite build",
"build": "rollup --config --no-stdin",
"build": "rolldown -c",
"build:types": "tsc -p tsconfig.lib.json && api-extractor run --local --verbose",
"test": "vitest run",
"test:watch": "vitest watch",
Expand All @@ -55,21 +55,14 @@
"clsx": "^2.0.0"
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/plugin-transform-runtime": "^7.25.9",
"@babel/preset-env": "^7.26.0",
"@babel/preset-react": "^7.26.3",
"@babel/preset-typescript": "^7.26.0",
"@babel/runtime": "^7.26.0",
"@biomejs/biome": "1.9.4",
"@eslint/compat": "^1.2.4",
"@eslint/markdown": "^6.2.1",
"@faker-js/faker": "^9.3.0",
"@ianvs/prettier-plugin-sort-imports": "^4.0.2",
"@linaria/core": "^6.0.0",
"@microsoft/api-extractor": "^7.48.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-node-resolve": "^16.0.0",
"@tanstack/react-router": "^1.85.5",
"@tanstack/router-plugin": "^1.69.1",
"@testing-library/dom": "^10.1.0",
Expand All @@ -83,10 +76,9 @@
"@vitejs/plugin-react": "^4.3.4",
"@vitest/browser": "^2.1.8",
"@vitest/coverage-v8": "^2.1.8",
"@vitest/eslint-plugin": "^1.1.17",
"@vitest/eslint-plugin": "1.1.20",
"@wyw-in-js/rollup": "^0.5.0",
"@wyw-in-js/vite": "^0.5.0",
"babel-plugin-optimize-clsx": "^2.6.2",
"browserslist": "^4.24.3",
"eslint": "^9.17.0",
"eslint-plugin-jest-dom": "^5.5.0",
Expand All @@ -105,8 +97,7 @@
"react-dnd": "^16.0.1",
"react-dnd-html5-backend": "^16.0.1",
"react-dom": "^18.3.1",
"rollup": "^4.28.1",
"rollup-plugin-postcss": "^4.0.2",
"rolldown": "^1.0.0-beta.1",
"typescript": "~5.7.2",
"vite": "^6.0.3",
"vitest": "^2.1.8",
Expand Down
41 changes: 41 additions & 0 deletions rolldown.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// @ts-check
import { isAbsolute } from 'node:path';
import wyw from '@wyw-in-js/rollup';
import pkg from './package.json' with { type: 'json' };
import { defineConfig } from 'rolldown';

export default defineConfig({
input: './src/index.ts',
output: [
{
dir: 'lib',
entryFileNames: 'bundle.js',
cssEntryFileNames: 'styles.css',
format: 'es',
sourcemap: true
},
{
dir: 'lib',
entryFileNames: 'bundle.cjs',
cssEntryFileNames: 'styles.css',
format: 'cjs',
sourcemap: true
}
],
platform: 'browser',
external: (id) => !id.startsWith('.') && !isAbsolute(id),
plugins: [
// @ts-expect-error
wyw({
preprocessor: 'none',
/**
* @param {string} hash
*/
classNameSlug(hash) {
// We add the package version as suffix to avoid style conflicts
// between multiple versions of RDG on the same page.
return `${hash}${pkg.version.replaceAll('.', '-')}`;
}
})
]
});
50 changes: 0 additions & 50 deletions rollup.config.js

This file was deleted.

3 changes: 2 additions & 1 deletion tsconfig.js.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"allowJs": true,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"resolveJsonModule": true,
"skipLibCheck": true
},
"include": ["**/*.js", ".github/**/*.js"],
"include": ["**/*.js", ".github/**/*.js", "package.json"],
"exclude": ["./coverage/**/*", "./dist/**/*", "./lib/**/*"]
}

0 comments on commit 4faa0a1

Please sign in to comment.