diff --git a/babel.config.json b/babel.config.json index 249dc5cef4..f878e8f9f9 100644 --- a/babel.config.json +++ b/babel.config.json @@ -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"] } diff --git a/package.json b/package.json index 555d76b87f..048a739033 100644 --- a/package.json +++ b/package.json @@ -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", @@ -55,12 +55,7 @@ "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", @@ -68,8 +63,6 @@ "@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", @@ -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", @@ -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", diff --git a/rolldown.config.js b/rolldown.config.js new file mode 100644 index 0000000000..161d7b664f --- /dev/null +++ b/rolldown.config.js @@ -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('.', '-')}`; + } + }) + ] +}); diff --git a/rollup.config.js b/rollup.config.js deleted file mode 100644 index d4296f6924..0000000000 --- a/rollup.config.js +++ /dev/null @@ -1,50 +0,0 @@ -import { isAbsolute } from 'node:path'; -import wyw from '@wyw-in-js/rollup'; -import postcss from 'rollup-plugin-postcss'; -import { babel } from '@rollup/plugin-babel'; -import nodeResolve from '@rollup/plugin-node-resolve'; -import pkg from './package.json' with { type: 'json' }; - -const extensions = ['.ts', '.tsx']; -const annotationRegexp = /^[@#]__.+__$/; - -export default { - input: './src/index.ts', - output: [ - { - file: './lib/bundle.js', - format: 'es', - generatedCode: 'es2015', - sourcemap: true - }, - { - file: './lib/bundle.cjs', - format: 'cjs', - generatedCode: 'es2015', - sourcemap: true - } - ], - external: (id) => !id.startsWith('.') && !id.startsWith('@linaria:') && !isAbsolute(id), - plugins: [ - wyw({ - preprocessor: 'none', - 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('.', '-')}`; - } - }), - postcss({ - extract: 'styles.css' - }), - babel({ - babelHelpers: 'runtime', - extensions, - // remove all comments except terser annotations - // https://github.com/terser/terser#annotations - // https://babeljs.io/docs/en/options#shouldprintcomment - shouldPrintComment: (comment) => annotationRegexp.test(comment) - }), - nodeResolve({ extensions }) - ] -}; diff --git a/tsconfig.js.json b/tsconfig.js.json index ee8264bb3c..f015060dcd 100644 --- a/tsconfig.js.json +++ b/tsconfig.js.json @@ -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/**/*"] }