From 4a8c9ef7c9b3b7b26930ebbdbf4ec668a6db0b18 Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Sat, 8 Jan 2022 22:53:19 -0500 Subject: [PATCH] Use rollup for react-base16-styling --- packages/react-base16-styling/.babelrc | 10 +++++++- packages/react-base16-styling/.eslintignore | 2 +- packages/react-base16-styling/.eslintrc.js | 14 +++++++---- packages/react-base16-styling/package.json | 17 ++++++++----- .../react-base16-styling/rollup.config.js | 24 +++++++++++++++++++ yarn.lock | 8 ++++++- 6 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 packages/react-base16-styling/rollup.config.js diff --git a/packages/react-base16-styling/.babelrc b/packages/react-base16-styling/.babelrc index 3313ff9e..39557e14 100644 --- a/packages/react-base16-styling/.babelrc +++ b/packages/react-base16-styling/.babelrc @@ -1,3 +1,11 @@ { - "presets": ["@babel/preset-env", "@babel/preset-typescript"] + "presets": [ + [ + "@babel/preset-env", + { + "targets": "defaults" + } + ], + "@babel/preset-typescript" + ] } diff --git a/packages/react-base16-styling/.eslintignore b/packages/react-base16-styling/.eslintignore index a65b4177..1521c8b7 100644 --- a/packages/react-base16-styling/.eslintignore +++ b/packages/react-base16-styling/.eslintignore @@ -1 +1 @@ -lib +dist diff --git a/packages/react-base16-styling/.eslintrc.js b/packages/react-base16-styling/.eslintrc.js index 4de5f294..e392d421 100644 --- a/packages/react-base16-styling/.eslintrc.js +++ b/packages/react-base16-styling/.eslintrc.js @@ -1,10 +1,14 @@ module.exports = { - extends: '../../eslintrc.ts.base.json', - parserOptions: { - tsconfigRootDir: __dirname, - project: ['./tsconfig.json'], - }, + extends: '../../eslintrc.js.base.json', overrides: [ + { + files: ['*.ts'], + extends: '../../eslintrc.ts.jest.base.json', + parserOptions: { + tsconfigRootDir: __dirname, + project: ['./test/tsconfig.json'], + }, + }, { files: ['test/**/*.ts'], extends: '../../eslintrc.ts.jest.base.json', diff --git a/packages/react-base16-styling/package.json b/packages/react-base16-styling/package.json index a50b9dd4..9cb03984 100644 --- a/packages/react-base16-styling/package.json +++ b/packages/react-base16-styling/package.json @@ -18,16 +18,15 @@ "lib", "src" ], - "main": "lib/index.js", - "types": "lib/index.d.ts", + "main": "dist/react-base16-styling.cjs.js", + "module": "dist/react-base16-styling.esm.js", + "types": "dist/index.d.ts", "repository": { "type": "git", "url": "git+https://github.com/reduxjs/redux-devtools.git" }, "scripts": { - "build": "yarn run build:types && yarn run build:js", - "build:types": "tsc --emitDeclarationOnly", - "build:js": "babel src --out-dir lib --extensions \".ts\" --source-maps inline", + "build": "rollup -c", "clean": "rimraf lib", "test": "jest", "lint": "eslint . --ext .ts", @@ -36,6 +35,7 @@ "prepublish": "yarn run type-check && yarn run lint && yarn run test" }, "dependencies": { + "@babel/runtime": "^7.16.7", "@types/base16": "^1.0.2", "@types/lodash": "^4.14.178", "base16": "^1.0.0", @@ -44,10 +44,12 @@ "lodash.curry": "^4.1.1" }, "devDependencies": { - "@babel/cli": "^7.16.7", "@babel/core": "^7.16.7", + "@babel/eslint-parser": "^7.16.5", + "@babel/plugin-transform-runtime": "^7.16.7", "@babel/preset-env": "^7.16.7", "@babel/preset-typescript": "^7.16.7", + "@rollup/plugin-babel": "^5.3.0", "@types/color": "^3.0.2", "@types/jest": "^27.4.0", "@types/lodash.curry": "^4.1.6", @@ -58,7 +60,10 @@ "eslint-plugin-jest": "^25.3.4", "jest": "^27.4.5", "rimraf": "^3.0.2", + "rollup": "^2.63.0", + "rollup-plugin-typescript2": "^0.31.1", "ts-jest": "^27.1.2", + "tslib": "^2.3.1", "typescript": "~4.5.4" } } diff --git a/packages/react-base16-styling/rollup.config.js b/packages/react-base16-styling/rollup.config.js new file mode 100644 index 00000000..be7b052a --- /dev/null +++ b/packages/react-base16-styling/rollup.config.js @@ -0,0 +1,24 @@ +import typescript from 'rollup-plugin-typescript2'; +import babel from '@rollup/plugin-babel'; + +const config = [ + { + input: 'src/index.ts', + output: [ + { file: 'dist/react-base16-styling.cjs.js', format: 'cjs' }, + { file: 'dist/react-base16-styling.esm.js', format: 'esm' }, + ], + plugins: [ + typescript(), + babel({ + exclude: 'node_modules/**', + babelHelpers: 'runtime', + extensions: ['.ts'], + plugins: ['@babel/plugin-transform-runtime'], + }), + ], + external: [/@babel\/runtime/, 'base16', 'color', 'lodash.curry'], + }, +]; + +export default config; diff --git a/yarn.lock b/yarn.lock index dacc10db..f87e8ad0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -23856,10 +23856,13 @@ __metadata: version: 0.0.0-use.local resolution: "react-base16-styling@workspace:packages/react-base16-styling" dependencies: - "@babel/cli": ^7.16.7 "@babel/core": ^7.16.7 + "@babel/eslint-parser": ^7.16.5 + "@babel/plugin-transform-runtime": ^7.16.7 "@babel/preset-env": ^7.16.7 "@babel/preset-typescript": ^7.16.7 + "@babel/runtime": ^7.16.7 + "@rollup/plugin-babel": ^5.3.0 "@types/base16": ^1.0.2 "@types/color": ^3.0.2 "@types/jest": ^27.4.0 @@ -23876,7 +23879,10 @@ __metadata: jest: ^27.4.5 lodash.curry: ^4.1.1 rimraf: ^3.0.2 + rollup: ^2.63.0 + rollup-plugin-typescript2: ^0.31.1 ts-jest: ^27.1.2 + tslib: ^2.3.1 typescript: ~4.5.4 languageName: unknown linkType: soft