From a1321098360d28488e9910f2c9edfd77690b539a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 28 Aug 2021 06:02:18 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Configure=20rollup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 14 +++++++++----- rollup.config.js | 39 +++++++++++++++++++++++++++++++++++++++ yarn.lock | 24 ++++++++++++++++++++++-- 3 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 rollup.config.js diff --git a/package.json b/package.json index 25a6132..3d5cd33 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ }, "license": "AGPL-3.0-or-later", "dependencies": { + "@babel/runtime": "^7.15.3", "classnames": "^2.3.1", "color": "https://github.com/Steffo99/color", "uuid": "^8.3.2" @@ -34,15 +35,15 @@ "react-dom": "^17.0.2" }, "devDependencies": { - "rollup": "^2.56.3", - "rollup-plugin-postcss": "^4.0.1", - "@rollup/plugin-babel": "^5.3.0", - "@rollup/plugin-commonjs": "^20.0.0", - "@rollup/plugin-node-resolve": "^13.0.4", "@babel/core": "^7.15.0", + "@babel/plugin-transform-runtime": "^7.15.0", "@babel/preset-env": "^7.15.0", "@babel/preset-react": "^7.14.5", "@babel/preset-typescript": "^7.15.0", + "@rollup/plugin-babel": "^5.3.0", + "@rollup/plugin-commonjs": "^20.0.0", + "@rollup/plugin-node-resolve": "^13.0.4", + "@rollup/plugin-typescript": "^8.2.5", "@storybook/addon-actions": "^6.3.7", "@storybook/addon-docs": "^6.3.7", "@storybook/addon-essentials": "^6.3.7", @@ -62,9 +63,12 @@ "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", "@types/uuid": "^8.3.1", + "postcss": "^8.3.6", "react": "^17.0.2", "react-dom": "^17.0.2", "react-scripts": "4.0.3", + "rollup": "^2.56.3", + "rollup-plugin-postcss": "^4.0.1", "typescript": "^4.1.2" }, "resolutions": { diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..9c0ec61 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,39 @@ +import babel from '@rollup/plugin-babel' +import commonjs from '@rollup/plugin-commonjs' +import resolve from '@rollup/plugin-node-resolve' +import postcss from 'rollup-plugin-postcss' +import typescript from "@rollup/plugin-typescript" +import pkg from './package.json' + + +export default { + input: 'src/index.ts', + output: { + file: pkg.main, + format: 'cjs', + exports: 'named' + }, + external: [ + "@babel/runtime", + "react", + "react-dom", + "classnames", + "color", + "uuid", + ], + plugins: [ + postcss({ + modules: true, + }), + typescript(), + babel({ + babelHelpers: "runtime", + presets: ["@babel/preset-env", "@babel/preset-react"], + plugins: ["@babel/plugin-transform-runtime"], + extensions: [".tsx", ".ts", ".jsx", ".js", ".mjs"], + exclude: 'node_modules/**', + }), + resolve(), + commonjs(), + ] +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 0fb719d..aeb6d3e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -976,6 +976,18 @@ resolve "^1.8.1" semver "^5.5.1" +"@babel/plugin-transform-runtime@^7.15.0": + version "7.15.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.15.0.tgz#d3aa650d11678ca76ce294071fda53d7804183b3" + integrity sha512-sfHYkLGjhzWTq6xsuQ01oEsUYjkHRux9fW1iUA68dC7Qd8BS1Unq4aZ8itmQp95zUzIcyR2EbNMTzAicFj+guw== + dependencies: + "@babel/helper-module-imports" "^7.14.5" + "@babel/helper-plugin-utils" "^7.14.5" + babel-plugin-polyfill-corejs2 "^0.2.2" + babel-plugin-polyfill-corejs3 "^0.2.2" + babel-plugin-polyfill-regenerator "^0.2.2" + semver "^6.3.0" + "@babel/plugin-transform-shorthand-properties@^7.12.1", "@babel/plugin-transform-shorthand-properties@^7.14.5": version "7.14.5" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.14.5.tgz#97f13855f1409338d8cadcbaca670ad79e091a58" @@ -1275,7 +1287,7 @@ dependencies: regenerator-runtime "^0.13.4" -"@babel/runtime@^7.0.0", "@babel/runtime@^7.10.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.14.0", "@babel/runtime@^7.14.8", "@babel/runtime@^7.3.1", "@babel/runtime@^7.5.0", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2": +"@babel/runtime@^7.0.0", "@babel/runtime@^7.10.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.14.0", "@babel/runtime@^7.14.8", "@babel/runtime@^7.15.3", "@babel/runtime@^7.3.1", "@babel/runtime@^7.5.0", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2": version "7.15.3" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.15.3.tgz#2e1c2880ca118e5b2f9988322bd8a7656a32502b" integrity sha512-OvwMLqNXkCXSz1kSm58sEsNuhqOx/fKpnUnKnFB5v8uDda5bLNEHNgKPvhDN6IU0LDcnHQ90LlJ0Q6jnyBSIBA== @@ -1868,6 +1880,14 @@ "@rollup/pluginutils" "^3.1.0" magic-string "^0.25.7" +"@rollup/plugin-typescript@^8.2.5": + version "8.2.5" + resolved "https://registry.yarnpkg.com/@rollup/plugin-typescript/-/plugin-typescript-8.2.5.tgz#e0319761b2b5105615e5a0c371ae05bc2984b7de" + integrity sha512-QL/LvDol/PAGB2O0S7/+q2HpSUNodpw7z6nGn9BfoVCPOZ0r4EALrojFU29Bkoi2Hr2jgTocTejJ5GGWZfOxbQ== + dependencies: + "@rollup/pluginutils" "^3.1.0" + resolve "^1.17.0" + "@rollup/pluginutils@^3.0.8", "@rollup/pluginutils@^3.1.0": version "3.1.0" resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b" @@ -11739,7 +11759,7 @@ postcss@7.0.36, postcss@^7, postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, pos source-map "^0.6.1" supports-color "^6.1.0" -postcss@^8.1.0: +postcss@^8.1.0, postcss@^8.3.6: version "8.3.6" resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.3.6.tgz#2730dd76a97969f37f53b9a6096197be311cc4ea" integrity sha512-wG1cc/JhRgdqB6WHEuyLTedf3KIRuD0hG6ldkFEZNCjRxiC+3i6kkWUUbiJQayP28iwG35cEmAbe98585BYV0A==