From 98caecd5cc367e08b6ad358fdcd0a8251671bb2a Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Sat, 8 Jan 2022 16:49:06 -0500 Subject: [PATCH] Use rollup for map2tree --- packages/d3tooltip/.eslintignore | 2 - packages/d3tooltip/rollup.config.js | 2 +- packages/map2tree/.babelrc | 10 +++- packages/map2tree/.eslintignore | 2 - packages/map2tree/.eslintrc.js | 22 ++++----- packages/map2tree/package.json | 26 +++++----- packages/map2tree/rollup.config.js | 66 +++++++++++++++++++++++++ packages/map2tree/tsconfig.webpack.json | 4 -- packages/map2tree/webpack.config.umd.ts | 27 ---------- yarn.lock | 14 ++++-- 10 files changed, 110 insertions(+), 65 deletions(-) create mode 100644 packages/map2tree/rollup.config.js delete mode 100644 packages/map2tree/tsconfig.webpack.json delete mode 100644 packages/map2tree/webpack.config.umd.ts diff --git a/packages/d3tooltip/.eslintignore b/packages/d3tooltip/.eslintignore index 1d149abd..1521c8b7 100644 --- a/packages/d3tooltip/.eslintignore +++ b/packages/d3tooltip/.eslintignore @@ -1,3 +1 @@ -examples -lib dist diff --git a/packages/d3tooltip/rollup.config.js b/packages/d3tooltip/rollup.config.js index 848a27b2..1f8408ff 100644 --- a/packages/d3tooltip/rollup.config.js +++ b/packages/d3tooltip/rollup.config.js @@ -59,7 +59,7 @@ const config = [ plugins: ['@babel/plugin-transform-runtime'], }), ], - external: ['ramda', /@babel\/runtime/], + external: [/@babel\/runtime/, 'ramda'], }, ]; diff --git a/packages/map2tree/.babelrc b/packages/map2tree/.babelrc index 3313ff9e..39557e14 100755 --- a/packages/map2tree/.babelrc +++ b/packages/map2tree/.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/map2tree/.eslintignore b/packages/map2tree/.eslintignore index 1d149abd..1521c8b7 100644 --- a/packages/map2tree/.eslintignore +++ b/packages/map2tree/.eslintignore @@ -1,3 +1 @@ -examples -lib dist diff --git a/packages/map2tree/.eslintrc.js b/packages/map2tree/.eslintrc.js index 436bc853..e392d421 100644 --- a/packages/map2tree/.eslintrc.js +++ b/packages/map2tree/.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', @@ -13,13 +17,5 @@ module.exports = { project: ['./test/tsconfig.json'], }, }, - { - files: ['webpack.config.umd.ts'], - extends: '../../eslintrc.ts.base.json', - parserOptions: { - tsconfigRootDir: __dirname, - project: ['./tsconfig.webpack.json'], - }, - }, ], }; diff --git a/packages/map2tree/package.json b/packages/map2tree/package.json index 36b4716e..8f379349 100755 --- a/packages/map2tree/package.json +++ b/packages/map2tree/package.json @@ -20,18 +20,16 @@ "dist", "src" ], - "main": "lib/index.js", - "types": "lib/index.d.ts", + "main": "dist/map2tree.cjs.js", + "module": "dist/map2tree.esm.js", + "types": "dist/index.d.ts", + "unpkg": "dist/map2tree.umd.js", "repository": { "type": "git", "url": "https://github.com/reduxjs/redux-devtools.git" }, "scripts": { - "build": "yarn run build:types && yarn run build:js && yarn run build:umd && yarn run build:umd:min", - "build:types": "tsc --emitDeclarationOnly", - "build:js": "babel src --out-dir lib --extensions \".ts\" --source-maps inline", - "build:umd": "webpack --progress --config webpack.config.umd.ts", - "build:umd:min": "webpack --env production --progress --config webpack.config.umd.ts", + "build": "rollup -c", "clean": "rimraf lib dist", "test": "jest", "lint": "eslint . --ext .ts", @@ -40,27 +38,33 @@ "prepublish": "yarn run type-check && yarn run lint && yarn run test" }, "dependencies": { + "@babel/runtime": "^7.16.7", "lodash": "^4.17.21" }, "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", + "@rollup/plugin-commonjs": "^21.0.1", + "@rollup/plugin-node-resolve": "^13.1.3", "@types/jest": "^27.4.0", "@types/lodash": "^4.14.178", - "@types/node": "^16.11.17", "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", - "babel-loader": "^8.2.3", "eslint": "^8.6.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-jest": "^25.3.4", "immutable": "^4.0.0", "jest": "^27.4.5", "rimraf": "^3.0.2", + "rollup": "^2.63.0", + "rollup-plugin-terser": "^7.0.2", + "rollup-plugin-typescript2": "^0.31.1", "ts-jest": "^27.1.2", - "ts-node": "^10.4.0", + "tslib": "^2.3.1", "typescript": "~4.5.4", "webpack": "^5.65.0", "webpack-cli": "^4.9.1" diff --git a/packages/map2tree/rollup.config.js b/packages/map2tree/rollup.config.js new file mode 100644 index 00000000..3c4bce74 --- /dev/null +++ b/packages/map2tree/rollup.config.js @@ -0,0 +1,66 @@ +import typescript from 'rollup-plugin-typescript2'; +import resolve from '@rollup/plugin-node-resolve'; +import commonjs from '@rollup/plugin-commonjs'; +import babel from '@rollup/plugin-babel'; +import { terser } from 'rollup-plugin-terser'; + +const config = [ + { + input: 'src/index.ts', + output: { + name: 'map2tree', + file: 'dist/map2tree.umd.js', + format: 'umd', + }, + plugins: [ + typescript(), + resolve(), + commonjs(), + babel({ + exclude: 'node_modules/**', + babelHelpers: 'runtime', + extensions: ['.ts'], + plugins: ['@babel/plugin-transform-runtime'], + }), + ], + }, + { + input: 'src/index.ts', + output: { + name: 'map2tree', + file: 'dist/map2tree.umd.min.js', + format: 'umd', + }, + plugins: [ + typescript(), + resolve(), + commonjs(), + babel({ + exclude: 'node_modules/**', + babelHelpers: 'runtime', + extensions: ['.ts'], + plugins: ['@babel/plugin-transform-runtime'], + }), + terser(), + ], + }, + { + input: 'src/index.ts', + output: [ + { file: 'dist/map2tree.cjs.js', format: 'cjs', exports: 'auto' }, + { file: 'dist/map2tree.esm.js', format: 'esm' }, + ], + plugins: [ + typescript(), + babel({ + exclude: 'node_modules/**', + babelHelpers: 'runtime', + extensions: ['.ts'], + plugins: ['@babel/plugin-transform-runtime'], + }), + ], + external: [/@babel\/runtime/, /lodash/], + }, +]; + +export default config; diff --git a/packages/map2tree/tsconfig.webpack.json b/packages/map2tree/tsconfig.webpack.json deleted file mode 100644 index 655c4644..00000000 --- a/packages/map2tree/tsconfig.webpack.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["webpack.config.umd.ts"] -} diff --git a/packages/map2tree/webpack.config.umd.ts b/packages/map2tree/webpack.config.umd.ts deleted file mode 100644 index 272ec0fe..00000000 --- a/packages/map2tree/webpack.config.umd.ts +++ /dev/null @@ -1,27 +0,0 @@ -import * as path from 'path'; -import * as webpack from 'webpack'; - -export default (env: { production?: boolean } = {}): webpack.Configuration => ({ - mode: env.production ? 'production' : 'development', - entry: { - app: ['./src/index'], - }, - output: { - library: 'map2tree', - libraryTarget: 'umd', - path: path.resolve(__dirname, 'dist'), - filename: env.production ? 'map2tree.min.js' : 'map2tree.js', - }, - module: { - rules: [ - { - test: /\.(js|ts)$/, - loader: 'babel-loader', - exclude: /node_modules/, - }, - ], - }, - resolve: { - extensions: ['.js', '.jsx', '.ts', '.tsx'], - }, -}); diff --git a/yarn.lock b/yarn.lock index 03fc6ebb..813380f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -20066,16 +20066,19 @@ __metadata: version: 0.0.0-use.local resolution: "map2tree@workspace:packages/map2tree" 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 + "@rollup/plugin-commonjs": ^21.0.1 + "@rollup/plugin-node-resolve": ^13.1.3 "@types/jest": ^27.4.0 "@types/lodash": ^4.14.178 - "@types/node": ^16.11.17 "@typescript-eslint/eslint-plugin": ^5.8.1 "@typescript-eslint/parser": ^5.8.1 - babel-loader: ^8.2.3 eslint: ^8.6.0 eslint-config-prettier: ^8.3.0 eslint-plugin-jest: ^25.3.4 @@ -20083,8 +20086,11 @@ __metadata: jest: ^27.4.5 lodash: ^4.17.21 rimraf: ^3.0.2 + rollup: ^2.63.0 + rollup-plugin-terser: ^7.0.2 + rollup-plugin-typescript2: ^0.31.1 ts-jest: ^27.1.2 - ts-node: ^10.4.0 + tslib: ^2.3.1 typescript: ~4.5.4 webpack: ^5.65.0 webpack-cli: ^4.9.1