From f0e529ebef2da212c3ae1a56b979406d09b6cf00 Mon Sep 17 00:00:00 2001 From: Colin de Roos Date: Tue, 22 Jan 2019 15:57:23 +0100 Subject: [PATCH 1/7] Clean dependencies Changes: * Update dependencies * `babel-preset-stage0` is now deprecated. I think it's best to let users just add what they need themselves. * warning about rollup postcss plugin using the onwrite hook: https://github.com/egoist/rollup-plugin-postcss/pull/148 * move prop-types dependency from example to lib. It's weird to put this as a peer dependency, because we only import it in the library and a user may choose to not use prop-types or something different. * the specific versions babel-eslint and eslint are required by the latest version of react-scripts. * remove `react-dom` dependency from library (still used in example). It doesn't look like this is actually used. * add eslint-import-resolver-node (doesn't result in build error, but eslint does give an error without it) --- template/default/.babelrc | 4 +- template/default/example/package.json | 13 +++-- template/default/package.json | 75 +++++++++++---------------- template/default/rollup.config.js | 9 +--- template/default/src/index.js | 8 +-- 5 files changed, 46 insertions(+), 63 deletions(-) diff --git a/template/default/.babelrc b/template/default/.babelrc index eeb6d8c..5276c01 100644 --- a/template/default/.babelrc +++ b/template/default/.babelrc @@ -5,5 +5,5 @@ }], "@babel/preset-react" ], - "plugins": ["@babel/plugin-proposal-class-properties"] -} \ No newline at end of file + "exclude": "node_modules/**" +} diff --git a/template/default/example/package.json b/template/default/example/package.json index 001944b..59f78f5 100644 --- a/template/default/example/package.json +++ b/template/default/example/package.json @@ -5,16 +5,21 @@ "license": "MIT", "private": true, "dependencies": { - "prop-types": "^15.6.2", "react": "^16.4.1", "react-dom": "^16.4.1", - "react-scripts": "^1.1.4", + "react-scripts": "^2.1.3", "{{name}}": "{{#if yarn}}link:..{{else}}file:..{{/if}}" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", - "test": "react-scripts test --env=jsdom", + "test": "react-scripts test", "eject": "react-scripts eject" - } + }, + "browserslist": [ + ">0.2%", + "not dead", + "not ie <= 11", + "not op_mini all" + ] } diff --git a/template/default/package.json b/template/default/package.json index 85977b6..3cb295d 100644 --- a/template/default/package.json +++ b/template/default/package.json @@ -13,8 +13,8 @@ "npm": ">=5" }, "scripts": { - "test": "cross-env CI=1 react-scripts test --env=jsdom", - "test:watch": "react-scripts test --env=jsdom", + "test": "cross-env CI=1 react-scripts test", + "test:watch": "react-scripts test", "build": "rollup -c", "start": "rollup -c -w", "prepare": "{{manager}} run build", @@ -22,55 +22,38 @@ "deploy": "gh-pages -d example/build" }, "peerDependencies": { - "prop-types": "^15.5.4", - "react": "^15.0.0 || ^16.0.0", - "react-dom": "^15.0.0 || ^16.0.0" + "react": "^15.0.0 || ^16.0.0" }, "devDependencies": { - "@babel/core": "^7.0.0", - "@babel/plugin-external-helpers": "^7.0.0", - "@babel/plugin-proposal-class-properties": "^7.0.0", - "@babel/plugin-proposal-decorators": "^7.0.0", - "@babel/plugin-proposal-do-expressions": "^7.0.0", - "@babel/plugin-proposal-export-default-from": "^7.0.0", - "@babel/plugin-proposal-export-namespace-from": "^7.0.0", - "@babel/plugin-proposal-function-bind": "^7.0.0", - "@babel/plugin-proposal-function-sent": "^7.0.0", - "@babel/plugin-proposal-json-strings": "^7.0.0", - "@babel/plugin-proposal-logical-assignment-operators": "^7.0.0", - "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0", - "@babel/plugin-proposal-numeric-separator": "^7.0.0", - "@babel/plugin-proposal-optional-chaining": "^7.0.0", - "@babel/plugin-proposal-pipeline-operator": "^7.0.0", - "@babel/plugin-proposal-throw-expressions": "^7.0.0", - "@babel/plugin-syntax-dynamic-import": "^7.0.0", - "@babel/plugin-syntax-import-meta": "^7.0.0", - "@babel/preset-env": "^7.0.0", + "@babel/core": "^7.2.2", + "@babel/preset-env": "^7.3.0", "@babel/preset-react": "^7.0.0", - "@svgr/rollup": "^2.4.1", - "babel-eslint": "^10.0.1", - "cross-env": "^5.1.4", - "eslint": "^5.0.1", - "eslint-config-standard": "^11.0.0", - "eslint-config-standard-react": "^6.0.0", - "eslint-plugin-import": "^2.13.0", - "eslint-plugin-node": "^7.0.1", - "eslint-plugin-promise": "^4.0.0", - "eslint-plugin-react": "^7.10.0", - "eslint-plugin-standard": "^3.1.0", - "gh-pages": "^1.2.0", - "react": "^16.4.1", - "react-dom": "^16.4.1", - "react-scripts": "^1.1.4", - "rollup": "^0.64.1", - "rollup-plugin-babel": "^4.0.1", - "rollup-plugin-commonjs": "^9.1.3", - "rollup-plugin-node-resolve": "^3.3.0", + "babel-eslint": "9.0.0", + "cross-env": "^5.2.0", + "eslint": "5.6.0", + "eslint-config-standard": "^12.0.0", + "eslint-config-standard-react": "^7.0.2", + "eslint-import-resolver-node": "^0.3.2", + "eslint-plugin-import": "^2.14.0", + "eslint-plugin-node": "^8.0.1", + "eslint-plugin-promise": "^4.0.1", + "eslint-plugin-react": "^7.12.4", + "eslint-plugin-standard": "^4.0.0", + "gh-pages": "^2.0.1", + "react": "^16.7.0", + "react-scripts": "^2.1.3", + "rollup": "^1.1.2", + "rollup-plugin-babel": "^4.3.2", + "rollup-plugin-commonjs": "^9.2.0", + "rollup-plugin-node-resolve": "^4.0.0", "rollup-plugin-peer-deps-external": "^2.2.0", - "rollup-plugin-postcss": "^1.6.2", - "rollup-plugin-url": "^1.4.0" + "rollup-plugin-postcss": "^1.6.3", + "rollup-plugin-url": "^2.1.0" }, "files": [ "dist" - ] + ], + "dependencies": { + "prop-types": "^15.6.2" + } } diff --git a/template/default/rollup.config.js b/template/default/rollup.config.js index d41aae3..c6dbc49 100644 --- a/template/default/rollup.config.js +++ b/template/default/rollup.config.js @@ -4,7 +4,6 @@ import external from 'rollup-plugin-peer-deps-external' import postcss from 'rollup-plugin-postcss' import resolve from 'rollup-plugin-node-resolve' import url from 'rollup-plugin-url' -import svgr from '@svgr/rollup' import pkg from './package.json' @@ -27,12 +26,8 @@ export default { postcss({ modules: true }), - url({ exclude: ['**/*.svg'] }), - svgr(), - babel({ - exclude: 'node_modules/**', - plugins: [ '@babel/external-helpers' ] - }), + url(), + babel(), resolve(), commonjs() ] diff --git a/template/default/src/index.js b/template/default/src/index.js index dabc5bf..d3c7691 100644 --- a/template/default/src/index.js +++ b/template/default/src/index.js @@ -4,10 +4,6 @@ import PropTypes from 'prop-types' import styles from './styles.css' export default class ExampleComponent extends Component { - static propTypes = { - text: PropTypes.string - } - render() { const { text @@ -20,3 +16,7 @@ export default class ExampleComponent extends Component { ) } } + +ExampleComponent.propTypes = { + text: PropTypes.string +} From 2b14127f85644db05ce6914a7e74c2cfb73e3030 Mon Sep 17 00:00:00 2001 From: Colin de Roos Date: Tue, 22 Jan 2019 16:12:57 +0100 Subject: [PATCH 2/7] Add babel proposal plugins back in I merged the previous changes from my own repo where I had updated the dependencies from the 2.6.7 version of the dependencies, in which babel 6 was still used. --- template/default/package.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/template/default/package.json b/template/default/package.json index 3cb295d..7e202c5 100644 --- a/template/default/package.json +++ b/template/default/package.json @@ -28,6 +28,23 @@ "@babel/core": "^7.2.2", "@babel/preset-env": "^7.3.0", "@babel/preset-react": "^7.0.0", + "@babel/plugin-external-helpers": "^7.0.0", + "@babel/plugin-proposal-class-properties": "^7.0.0", + "@babel/plugin-proposal-decorators": "^7.0.0", + "@babel/plugin-proposal-do-expressions": "^7.0.0", + "@babel/plugin-proposal-export-default-from": "^7.0.0", + "@babel/plugin-proposal-export-namespace-from": "^7.0.0", + "@babel/plugin-proposal-function-bind": "^7.0.0", + "@babel/plugin-proposal-function-sent": "^7.0.0", + "@babel/plugin-proposal-json-strings": "^7.0.0", + "@babel/plugin-proposal-logical-assignment-operators": "^7.0.0", + "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0", + "@babel/plugin-proposal-numeric-separator": "^7.0.0", + "@babel/plugin-proposal-optional-chaining": "^7.0.0", + "@babel/plugin-proposal-pipeline-operator": "^7.0.0", + "@babel/plugin-proposal-throw-expressions": "^7.0.0", + "@babel/plugin-syntax-dynamic-import": "^7.0.0", + "@babel/plugin-syntax-import-meta": "^7.0.0", "babel-eslint": "9.0.0", "cross-env": "^5.2.0", "eslint": "5.6.0", From 0d555b3a7e94e28dde504114a654611ac96f66c9 Mon Sep 17 00:00:00 2001 From: Colin de Roos Date: Tue, 22 Jan 2019 16:14:32 +0100 Subject: [PATCH 3/7] Undo removing `svgr` I removed this in the library I created with this starter, because I don't need it, but forgot to remove it from the commit on this repo. --- template/default/package.json | 1 + template/default/rollup.config.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/template/default/package.json b/template/default/package.json index 7e202c5..a48c4c7 100644 --- a/template/default/package.json +++ b/template/default/package.json @@ -45,6 +45,7 @@ "@babel/plugin-proposal-throw-expressions": "^7.0.0", "@babel/plugin-syntax-dynamic-import": "^7.0.0", "@babel/plugin-syntax-import-meta": "^7.0.0", + "@svgr/rollup": "^4.1.0", "babel-eslint": "9.0.0", "cross-env": "^5.2.0", "eslint": "5.6.0", diff --git a/template/default/rollup.config.js b/template/default/rollup.config.js index c6dbc49..3732d55 100644 --- a/template/default/rollup.config.js +++ b/template/default/rollup.config.js @@ -4,6 +4,7 @@ import external from 'rollup-plugin-peer-deps-external' import postcss from 'rollup-plugin-postcss' import resolve from 'rollup-plugin-node-resolve' import url from 'rollup-plugin-url' +import svgr from '@svgr/rollup' import pkg from './package.json' @@ -26,7 +27,8 @@ export default { postcss({ modules: true }), - url(), + url({ exclude: ['**/*.svg'] }), + svgr(), babel(), resolve(), commonjs() From 6312eb42eebbbde40570816e06414e4fc048e73c Mon Sep 17 00:00:00 2001 From: Colin de Roos Date: Tue, 22 Jan 2019 16:32:03 +0100 Subject: [PATCH 4/7] Reorder dependencies I don't know why this didn't happen automatically --- template/default/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/default/package.json b/template/default/package.json index a48c4c7..fcba783 100644 --- a/template/default/package.json +++ b/template/default/package.json @@ -26,8 +26,6 @@ }, "devDependencies": { "@babel/core": "^7.2.2", - "@babel/preset-env": "^7.3.0", - "@babel/preset-react": "^7.0.0", "@babel/plugin-external-helpers": "^7.0.0", "@babel/plugin-proposal-class-properties": "^7.0.0", "@babel/plugin-proposal-decorators": "^7.0.0", @@ -45,6 +43,8 @@ "@babel/plugin-proposal-throw-expressions": "^7.0.0", "@babel/plugin-syntax-dynamic-import": "^7.0.0", "@babel/plugin-syntax-import-meta": "^7.0.0", + "@babel/preset-env": "^7.3.0", + "@babel/preset-react": "^7.0.0", "@svgr/rollup": "^4.1.0", "babel-eslint": "9.0.0", "cross-env": "^5.2.0", From d649431139daba956ecd3d8658eab5a5023f9399 Mon Sep 17 00:00:00 2001 From: Colin de Roos Date: Tue, 22 Jan 2019 16:35:26 +0100 Subject: [PATCH 5/7] revert making library independent of babel proposal plugins --- template/default/src/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/template/default/src/index.js b/template/default/src/index.js index d3c7691..dabc5bf 100644 --- a/template/default/src/index.js +++ b/template/default/src/index.js @@ -4,6 +4,10 @@ import PropTypes from 'prop-types' import styles from './styles.css' export default class ExampleComponent extends Component { + static propTypes = { + text: PropTypes.string + } + render() { const { text @@ -16,7 +20,3 @@ export default class ExampleComponent extends Component { ) } } - -ExampleComponent.propTypes = { - text: PropTypes.string -} From 4b5937c3b1d36ab360fc5cc9a6d173c157d4193b Mon Sep 17 00:00:00 2001 From: Colin de Roos Date: Tue, 22 Jan 2019 16:53:38 +0100 Subject: [PATCH 6/7] Remove @babel/external-helpers Using "external-helpers" plugin with rollup-plugin-babel is deprecated, as it now automatically deduplicates your Babel helpers. --- template/default/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/template/default/package.json b/template/default/package.json index fcba783..28a6d51 100644 --- a/template/default/package.json +++ b/template/default/package.json @@ -26,7 +26,6 @@ }, "devDependencies": { "@babel/core": "^7.2.2", - "@babel/plugin-external-helpers": "^7.0.0", "@babel/plugin-proposal-class-properties": "^7.0.0", "@babel/plugin-proposal-decorators": "^7.0.0", "@babel/plugin-proposal-do-expressions": "^7.0.0", From 767f380baf577b952b13d441fd6ac4ebef885d65 Mon Sep 17 00:00:00 2001 From: Colin de Roos Date: Tue, 22 Jan 2019 17:28:26 +0100 Subject: [PATCH 7/7] Add all installed plugins to babel config This should have been done right when upgrading to babel 7 --- template/default/.babelrc | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/template/default/.babelrc b/template/default/.babelrc index 5276c01..e3197ca 100644 --- a/template/default/.babelrc +++ b/template/default/.babelrc @@ -5,5 +5,30 @@ }], "@babel/preset-react" ], - "exclude": "node_modules/**" + "exclude": "node_modules/**", + "plugins": [ + // Stage 0 + "@babel/plugin-proposal-function-bind", + + // Stage 1 + "@babel/plugin-proposal-export-default-from", + "@babel/plugin-proposal-logical-assignment-operators", + ["@babel/plugin-proposal-optional-chaining", { "loose": false }], + ["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }], + ["@babel/plugin-proposal-nullish-coalescing-operator", { "loose": false }], + "@babel/plugin-proposal-do-expressions", + + // Stage 2 + ["@babel/plugin-proposal-decorators", { "legacy": true }], + "@babel/plugin-proposal-function-sent", + "@babel/plugin-proposal-export-namespace-from", + "@babel/plugin-proposal-numeric-separator", + "@babel/plugin-proposal-throw-expressions", + + // Stage 3 + "@babel/plugin-syntax-dynamic-import", + "@babel/plugin-syntax-import-meta", + ["@babel/plugin-proposal-class-properties", { "loose": false }], + "@babel/plugin-proposal-json-strings" + ] }