Skip to content

Update rolldown, adopt rolldown-plugin-dts #3787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 19, 2025
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
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ jobs:
- name: Prettier
run: node --run prettier:check
- name: Bundle
run: |
node --run build
node --run build:types
run: node --run build
- name: Build website
run: node --run build:website
- name: Install Playwright Browsers
Expand Down
35 changes: 0 additions & 35 deletions api-extractor.json

This file was deleted.

15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
"./lib/styles.css": "./lib/styles.css",
".": {
"types": "./lib/index.d.ts",
"default": "./lib/bundle.js"
"default": "./lib/index.js"
}
},
"browser": "./lib/bundle.js",
"main": "./lib/bundle.js",
"module": "./lib/bundle.js",
"browser": "./lib/index.js",
"main": "./lib/index.js",
"module": "./lib/index.js",
Comment on lines +23 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need all three?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not at this point, it's just there for older bundlers, but we could try removing those.

"types": "./lib/index.d.ts",
"files": [
"lib"
Expand All @@ -35,7 +35,6 @@
"preview": "vite preview",
"build:website": "vite build",
"build": "rolldown -c",
"build:types": "tsc -p tsconfig.lib.json && api-extractor run --local --verbose",
"test": "vitest run",
"test:watch": "vitest watch",
"format": "biome format --write",
Expand All @@ -46,7 +45,7 @@
"prettier:check": "prettier --check .",
"prettier:format": "prettier --write .",
"typecheck": "tsc --build",
"prepublishOnly": "npm install && node --run build && node --run build:types",
"prepublishOnly": "npm install && node --run build",
"postpublish": "git push --follow-tags origin HEAD"
},
"dependencies": {
Expand All @@ -59,7 +58,6 @@
"@faker-js/faker": "^9.6.0",
"@ianvs/prettier-plugin-sort-imports": "^4.4.1",
"@linaria/core": "^6.3.0",
"@microsoft/api-extractor": "^7.52.7",
"@tanstack/react-router": "^1.114.16",
"@tanstack/router-plugin": "^1.114.16",
"@types/node": "^22.15.16",
Expand Down Expand Up @@ -91,7 +89,8 @@
"react-dnd": "^16.0.1",
"react-dnd-html5-backend": "^16.0.1",
"react-dom": "^19.1.0",
"rolldown": "^1.0.0-beta.8",
"rolldown": "^1.0.0-beta.9",
"rolldown-plugin-dts": "^0.13.3",
"typescript": "~5.8.2",
"vite": "^6.3.5",
"vitest": "^3.1.3",
Expand Down
13 changes: 7 additions & 6 deletions rolldown.config.js → rolldown.config.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
// @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';
import { dts } from 'rolldown-plugin-dts';

import pkg from './package.json' with { type: 'json' };

export default defineConfig({
input: './src/index.ts',
output: {
dir: 'lib',
entryFileNames: 'bundle.js',
cssEntryFileNames: 'styles.css',
sourcemap: true
},
platform: 'browser',
external: (id) => !id.startsWith('.') && !isAbsolute(id),
plugins: [
// @ts-expect-error
dts({
tsconfig: './tsconfig.lib.json'
}),
wyw({
exclude: ['**/*.d.ts'],
preprocessor: 'none',
classNameSlug(/** @type {string} */ hash) {
// We add the package version as suffix to avoid style conflicts
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"composite": false,
"declaration": true,
"lib": ["ESNext", "DOM", "DOM.Iterable", "DOM.AsyncIterable"],
"noCheck": true,
"outDir": "./.cache/lib"
"noCheck": true
},
"files": ["src/index.ts"]
}
2 changes: 1 addition & 1 deletion tsconfig.vite.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"skipLibCheck": true,
"types": ["@vitest/browser/providers/playwright"]
},
"include": ["vite.config.ts"]
"include": ["package.json", "rolldown.config.ts", "vite.config.ts"]
}
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default defineConfig(({ command }) => ({
exclude: ['./.cache/**/*']
}),
wyw({
exclude: ['./.cache/**/*'],
exclude: ['./.cache/**/*', '**/*.d.ts', '**/*.gen.ts'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need to excluded '**/*.d.ts', '**/*.gen.ts' in rolldown.config?

Copy link
Contributor Author

@nstepien nstepien May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did add '**/*.d.ts', as otherwise the build fails with the new plugin.
'**/*.gen.ts' is probably not needed as rolldown won't touch the website files.

preprocessor: 'none',
displayName: command === 'serve'
})
Expand Down