diff --git a/package.json b/package.json index cbb497d769..0163a1b716 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,6 @@ "react-dnd-html5-backend": "^16.0.1", "react-dom": "^18.3.1", "rolldown": "^0.15.1", - "rollup-plugin-postcss": "^4.0.2", "typescript": "~5.7.2", "vite": "^6.0.3", "vitest": "^2.1.8", diff --git a/rolldown.config.js b/rolldown.config.js index c42f4dba15..7e5e040cd0 100644 --- a/rolldown.config.js +++ b/rolldown.config.js @@ -1,39 +1,52 @@ +// @ts-check import { isAbsolute } from 'node:path'; import wyw from '@wyw-in-js/rollup'; -import postcss from 'rollup-plugin-postcss'; import pkg from './package.json' with { type: 'json' }; import { defineConfig } from 'rolldown'; -const annotationRegexp = /^[@#]__.+__$/; +// TODO: can't preserve minifier annotations, open issue +// const annotationRegexp = /^[@#]__.+__$/; -export default defineConfig({ - 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' - }) - ] -}); +/** + * @type {readonly import('rolldown').OutputOptions[]} + */ +const outputs = [ + { + dir: 'lib', + entryFileNames: 'bundle.js', + cssEntryFileNames: 'styles.css', + format: 'es', + sourcemap: true, + comments: 'preserve-legal' + }, + { + dir: 'lib', + entryFileNames: 'bundle.cjs', + cssEntryFileNames: 'styles.css', + format: 'cjs', + sourcemap: true + } +]; + +export default outputs.map((output) => + defineConfig({ + input: './src/index.ts', + output, + 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/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/**/*"] }