Skip to content

Commit

Permalink
refactor: switch to reusable rollup config for React components
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert committed Nov 17, 2024
1 parent ac4c7a5 commit 3d14f92
Show file tree
Hide file tree
Showing 45 changed files with 339 additions and 2,799 deletions.
14 changes: 1 addition & 13 deletions packages/components-react/body-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,19 @@
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "7.24.7",
"@babel/preset-env": "7.24.7",
"@babel/preset-react": "7.24.7",
"@babel/preset-typescript": "7.24.7",
"@rollup/plugin-babel": "6.0.4",
"@rollup/plugin-commonjs": "26.0.1",
"@rollup/plugin-json": "6.1.0",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-typescript": "12.1.0",
"@testing-library/dom": "8.20.1",
"@testing-library/jest-dom": "6.5.0",
"@testing-library/react": "16.0.1",
"@testing-library/user-event": "14.5.1",
"@types/jest": "29.5.13",
"@types/react": "18.3.3",
"@types/testing-library__jest-dom": "5.14.9",
"@utrecht/build-utils-react": "workspace:*",
"@utrecht/body-css": "workspace:*",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"react": "18.3.1",
"rollup": "4.23.0",
"rollup-plugin-filesize": "10.0.0",
"rollup-plugin-node-externals": "7.1.2",
"rollup-plugin-peer-deps-external": "2.2.4",
"rollup-plugin-postcss": "4.0.2",
"typescript": "5.6.2"
},
"keywords": [
Expand Down
88 changes: 2 additions & 86 deletions packages/components-react/body-react/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,87 +1,3 @@
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import { readFileSync } from 'fs';
import filesize from 'rollup-plugin-filesize';
import nodeExternal from 'rollup-plugin-node-externals';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import postcss from 'rollup-plugin-postcss';
import { createConfig } from '@utrecht/build-utils-react/src/rollup.mjs';

const packagePath = new URL('./package.json', import.meta.url).pathname;
const packageJson = JSON.parse(readFileSync(packagePath, 'utf8'));

/**
* @type {import('rollup').RollupOptions}
*/
export default [
{
input: './src/index.tsx',
output: [
{
file: packageJson.main,
format: 'cjs',
sourcemap: true,
},
{
file: packageJson.module,
format: 'es',
sourcemap: true,
},
],
plugins: [
peerDepsExternal(),
commonjs(),
nodeExternal(),
resolve({ browser: true }),
json(),
typescript({ tsconfig: './tsconfig.build.json' }),
babel({
presets: ['@babel/preset-react'],
babelHelpers: 'runtime',
exclude: ['node_modules/**', 'dist/**'],
extensions: ['.ts', '.tsx'],
inputSourceMap: true,
plugins: ['@babel/plugin-transform-runtime'],
}),
filesize(),
],
},
{
input: './src/css.tsx',
output: [
{
file: './dist/css.js',
format: 'cjs',
sourcemap: true,
},
{
file: './dist/css.mjs',
format: 'es',
sourcemap: true,
},
],
plugins: [
peerDepsExternal(),
commonjs(),
nodeExternal(),
resolve({ browser: true }),
json(),
postcss({
extensions: ['.css', '.scss'],
minimize: true,
}),
typescript({ tsconfig: './tsconfig.build.json' }),
babel({
presets: ['@babel/preset-react'],
babelHelpers: 'runtime',
exclude: ['node_modules/**', 'dist/**'],
extensions: ['.ts', '.tsx'],
inputSourceMap: true,
plugins: ['@babel/plugin-transform-runtime'],
}),
filesize(),
],
},
];
export default createConfig();
13 changes: 1 addition & 12 deletions packages/components-react/calendar-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "7.24.7",
"@babel/preset-react": "7.24.7",
"@rollup/plugin-babel": "6.0.4",
"@rollup/plugin-commonjs": "26.0.1",
"@rollup/plugin-json": "6.1.0",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-typescript": "12.1.0",
"@testing-library/dom": "8.20.1",
"@testing-library/jest-dom": "6.5.0",
"@testing-library/react": "16.0.1",
Expand All @@ -34,15 +27,11 @@
"@types/lodash-es": "4.17.12",
"@types/react": "18.3.3",
"@types/testing-library__jest-dom": "5.14.9",
"@utrecht/build-utils-react": "workspace:*",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"react": "18.3.1",
"rollup": "4.23.0",
"rollup-plugin-filesize": "10.0.0",
"rollup-plugin-node-externals": "7.1.2",
"rollup-plugin-peer-deps-external": "2.2.4",
"rollup-plugin-postcss": "4.0.2",
"rollup-plugin-typescript2": "0.36.0",
"typescript": "5.6.2"
},
"keywords": [
Expand Down
88 changes: 2 additions & 86 deletions packages/components-react/calendar-react/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,87 +1,3 @@
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import { readFileSync } from 'fs';
import filesize from 'rollup-plugin-filesize';
import nodeExternal from 'rollup-plugin-node-externals';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import postcss from 'rollup-plugin-postcss';
import { createConfig } from '@utrecht/build-utils-react/src/rollup.mjs';

const packagePath = new URL('./package.json', import.meta.url).pathname;
const packageJson = JSON.parse(readFileSync(packagePath, 'utf8'));

/**
* @type {import('rollup').RollupOptions}
*/
export default [
{
input: './src/index.tsx',
output: [
{
file: packageJson.main,
format: 'cjs',
sourcemap: true,
},
{
file: packageJson.module,
format: 'es',
sourcemap: true,
},
],
plugins: [
peerDepsExternal(),
commonjs(),
nodeExternal(),
resolve({ browser: true }),
json(),
typescript({ tsconfig: './tsconfig.build.json', outputToFilesystem: false }),
babel({
presets: ['@babel/preset-react'],
babelHelpers: 'runtime',
exclude: ['node_modules/**', 'dist/**'],
extensions: ['.ts', '.tsx'],
inputSourceMap: true,
plugins: ['@babel/plugin-transform-runtime'],
}),
filesize(),
],
},
{
input: './src/css.tsx',
output: [
{
file: './dist/css.cjs',
format: 'cjs',
sourcemap: true,
},
{
file: './dist/css.mjs',
format: 'es',
sourcemap: true,
},
],
plugins: [
peerDepsExternal(),
commonjs(),
nodeExternal(),
resolve({ browser: true }),
json(),
postcss({
extensions: ['.css', '.scss'],
minimize: true,
}),
typescript({ tsconfig: './tsconfig.build.json', outputToFilesystem: false }),
babel({
presets: ['@babel/preset-react'],
babelHelpers: 'runtime',
exclude: ['node_modules/**', 'dist/**'],
extensions: ['.ts', '.tsx'],
inputSourceMap: true,
plugins: ['@babel/plugin-transform-runtime'],
}),
filesize(),
],
},
];
export default createConfig();
14 changes: 1 addition & 13 deletions packages/components-react/checkbox-group-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,19 @@
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "7.24.7",
"@babel/preset-env": "7.24.7",
"@babel/preset-react": "7.24.7",
"@babel/preset-typescript": "7.24.7",
"@rollup/plugin-babel": "6.0.4",
"@rollup/plugin-commonjs": "26.0.1",
"@rollup/plugin-json": "6.1.0",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-typescript": "12.1.0",
"@testing-library/dom": "8.20.1",
"@testing-library/jest-dom": "6.5.0",
"@testing-library/react": "16.0.1",
"@testing-library/user-event": "14.5.1",
"@types/jest": "29.5.13",
"@types/react": "18.3.3",
"@types/testing-library__jest-dom": "5.14.9",
"@utrecht/build-utils-react": "workspace:*",
"@utrecht/form-field-css": "workspace:*",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"react": "18.3.1",
"rollup": "4.23.0",
"rollup-plugin-filesize": "10.0.0",
"rollup-plugin-node-externals": "7.1.2",
"rollup-plugin-peer-deps-external": "2.2.4",
"rollup-plugin-postcss": "4.0.2",
"typescript": "5.6.2"
},
"keywords": [
Expand Down
88 changes: 2 additions & 86 deletions packages/components-react/checkbox-group-react/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,87 +1,3 @@
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import { readFileSync } from 'fs';
import filesize from 'rollup-plugin-filesize';
import nodeExternal from 'rollup-plugin-node-externals';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import postcss from 'rollup-plugin-postcss';
import { createConfig } from '@utrecht/build-utils-react/src/rollup.mjs';

const packagePath = new URL('./package.json', import.meta.url).pathname;
const packageJson = JSON.parse(readFileSync(packagePath, 'utf8'));

/**
* @type {import('rollup').RollupOptions}
*/
export default [
{
input: './src/index.tsx',
output: [
{
file: packageJson.main,
format: 'cjs',
sourcemap: true,
},
{
file: packageJson.module,
format: 'es',
sourcemap: true,
},
],
plugins: [
peerDepsExternal(),
commonjs(),
nodeExternal(),
resolve({ browser: true }),
json(),
typescript({ tsconfig: './tsconfig.build.json' }),
babel({
presets: ['@babel/preset-react'],
babelHelpers: 'runtime',
exclude: ['node_modules/**', 'dist/**'],
extensions: ['.ts', '.tsx'],
inputSourceMap: true,
plugins: ['@babel/plugin-transform-runtime'],
}),
filesize(),
],
},
{
input: './src/css.tsx',
output: [
{
file: './dist/css.cjs',
format: 'cjs',
sourcemap: true,
},
{
file: './dist/css.mjs',
format: 'es',
sourcemap: true,
},
],
plugins: [
peerDepsExternal(),
commonjs(),
nodeExternal(),
resolve({ browser: true }),
json(),
postcss({
extensions: ['.css', '.scss'],
minimize: true,
}),
typescript({ tsconfig: './tsconfig.build.json' }),
babel({
presets: ['@babel/preset-react'],
babelHelpers: 'runtime',
exclude: ['node_modules/**', 'dist/**'],
extensions: ['.ts', '.tsx'],
inputSourceMap: true,
plugins: ['@babel/plugin-transform-runtime'],
}),
filesize(),
],
},
];
export default createConfig();
Loading

0 comments on commit 3d14f92

Please sign in to comment.