From 130592553ded94af3c363310cd5d42aa559453d3 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Thu, 9 Aug 2018 12:15:43 +1000 Subject: [PATCH 01/66] Update dependencies --- CHANGES.md | 11 +++++++++++ package.json | 12 ++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 2029d0cd..14066bee 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,14 @@ +# Unreleased (in `master`) + +## Dependencies + +- autoprefixer: v9.0.2 → [v9.1.0](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#91-equality-before-the-law) +- babel-plugin-inferno: v5.0.1 → [v5.1.0](https://github.com/infernojs/babel-plugin-inferno/releases) +- inquirer: v6.0.0 → [v6.1.0](https://github.com/SBoudrias/Inquirer.js/releases/tag/inquirer%406.1.0) +- postcss-loader: v2.1.6 → [v3.0.0](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#300-2018-08-08) - dropped Node.js 4 support +- style-loader: v0.21.0 → [v0.22.1](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0221-2018-08-08) +- webpack: v4.16.4 → [v4.16.5](https://github.com/webpack/webpack/releases/tag/v4.16.5) + # 0.23.0 / 2018-08-03 ## Breaking Changes diff --git a/package.json b/package.json index 57a6ddff..45df0e9e 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "filesize": "3.6.1", "fs-extra": "7.0.0", "gzip-size": "5.0.0", - "inquirer": "6.0.0", + "inquirer": "6.1.0", "minimist": "1.2.0", "ora": "3.0.0", "resolve": "1.8.1", @@ -49,7 +49,7 @@ "babel-cli": "6.26.0", "babel-core": "6.26.3", "babel-plugin-add-module-exports": "0.2.1", - "babel-plugin-inferno": "5.0.1", + "babel-plugin-inferno": "5.1.0", "babel-plugin-istanbul": "4.1.6", "babel-plugin-lodash": "3.2.11", "babel-plugin-react-transform": "3.0.0", @@ -91,8 +91,8 @@ "promise": "8.0.1", "whatwg-fetch": "2.0.4", - "webpack": "4.16.4", - "autoprefixer": "9.0.2", + "webpack": "4.16.5", + "autoprefixer": "9.1.0", "babel-loader": "7.1.5", "case-sensitive-paths-webpack-plugin": "2.1.2", "copy-webpack-plugin": "4.5.2", @@ -103,8 +103,8 @@ "mini-css-extract-plugin": "0.4.1", "@insin/npm-install-webpack-plugin": "5.0.0", "opn": "5.3.0", - "postcss-loader": "2.1.6", - "style-loader": "0.21.0", + "postcss-loader": "3.0.0", + "style-loader": "0.22.1", "uglifyjs-webpack-plugin": "1.2.7", "url-loader": "1.0.1", "webpack-dev-middleware": "3.1.3", From 47d9e0ce4db77eee297aaddf63592fb52d1a7b70 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Wed, 15 Aug 2018 15:24:04 +1000 Subject: [PATCH 02/66] Update dependencies --- CHANGES.md | 4 +++- package.json | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 14066bee..8425fa6b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,11 +2,13 @@ ## Dependencies -- autoprefixer: v9.0.2 → [v9.1.0](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#91-equality-before-the-law) +- autoprefixer: v9.0.2 → [v9.1.1](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#911) - babel-plugin-inferno: v5.0.1 → [v5.1.0](https://github.com/infernojs/babel-plugin-inferno/releases) - inquirer: v6.0.0 → [v6.1.0](https://github.com/SBoudrias/Inquirer.js/releases/tag/inquirer%406.1.0) +- karma: v2.0.0 → [v3.0.0](https://github.com/karma-runner/karma/releases/tag/v3.0.0) - postcss-loader: v2.1.6 → [v3.0.0](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#300-2018-08-08) - dropped Node.js 4 support - style-loader: v0.21.0 → [v0.22.1](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0221-2018-08-08) +- uglifyjs-webpack-plugin: v1.2.7 → [v1.3.0](https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/CHANGELOG.md#130-2018-08-14) - webpack: v4.16.4 → [v4.16.5](https://github.com/webpack/webpack/releases/tag/v4.16.5) # 0.23.0 / 2018-08-03 diff --git a/package.json b/package.json index 45df0e9e..5b6f16df 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "react-transform-hmr": "1.0.4", "redbox-noreact": "1.1.0", - "karma": "2.0.5", + "karma": "3.0.0", "karma-chrome-launcher": "2.2.0", "karma-coverage": "1.1.2", "karma-mocha": "1.3.0", @@ -92,7 +92,7 @@ "whatwg-fetch": "2.0.4", "webpack": "4.16.5", - "autoprefixer": "9.1.0", + "autoprefixer": "9.1.1", "babel-loader": "7.1.5", "case-sensitive-paths-webpack-plugin": "2.1.2", "copy-webpack-plugin": "4.5.2", @@ -105,8 +105,8 @@ "opn": "5.3.0", "postcss-loader": "3.0.0", "style-loader": "0.22.1", - "uglifyjs-webpack-plugin": "1.2.7", "url-loader": "1.0.1", + "uglifyjs-webpack-plugin": "1.3.0", "webpack-dev-middleware": "3.1.3", "webpack-dev-server": "3.1.5", "webpack-hot-middleware": "2.22.3" From fa2e0acc60ac1d4b2535b8b3296fd0a10a2ff3a6 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Thu, 16 Aug 2018 21:31:29 +1000 Subject: [PATCH 03/66] Update Flow and add new justshutuptypesystem annotations --- package.json | 2 +- src/createWebpackConfig.js | 6 +++--- src/inferno/index.js | 4 ++-- src/preact/index.js | 4 ++-- src/react/index.js | 2 +- src/utils.js | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 5b6f16df..dc3216d5 100644 --- a/package.json +++ b/package.json @@ -117,7 +117,7 @@ "cross-env": "5.2.0", "eslint-config-jonnybuchanan": "6.0.0", "eventsource": "1.0.5", - "flow-bin": "0.68.0", + "flow-bin": "0.78.0", "glob": "7.1.2", "nyc": "12.0.2", "rimraf": "2.6.2", diff --git a/src/createWebpackConfig.js b/src/createWebpackConfig.js index 8e4c182d..f0d1ec4b 100644 --- a/src/createWebpackConfig.js +++ b/src/createWebpackConfig.js @@ -328,7 +328,7 @@ export function createRules( buildConfig: Object = {}, userWebpackConfig: Object = {}, pluginConfig: Object = {} -) { +): RuleConfig[] { let createRule = createRuleConfigFactory(buildConfig, userWebpackConfig.rules) let createLoader = createLoaderConfigFactory(buildConfig, userWebpackConfig.rules) @@ -394,7 +394,7 @@ export function createRules( )) } - return rules.filter(rule => rule != null) + return rules.filter(Boolean) } /** @@ -468,7 +468,7 @@ export function createPlugins( server: ServerConfig, buildConfig: Object = {}, userConfig: Object = {} -) { +): {optimization: Object, plugins: Object[]} { let production = process.env.NODE_ENV === 'production' let optimization = {} diff --git a/src/inferno/index.js b/src/inferno/index.js index 8aab9b9e..42faf0e7 100644 --- a/src/inferno/index.js +++ b/src/inferno/index.js @@ -50,7 +50,7 @@ export default (args: Object) => ({ getProjectDefaults() { return {compat: false} }, - getProjectDependencies(answers: Object) { + getProjectDependencies(answers: Object): string[] { let deps = getDependencies() if (answers.compat) { deps = deps.concat(getCompatDependencies()) @@ -70,7 +70,7 @@ export default (args: Object) => ({ getBuildDependencies: () => [], getBuildConfig: getBaseConfig, getServeConfig: getBaseConfig, - getQuickDependencies: () => getDependencies().concat(getCompatDependencies()), + getQuickDependencies: (): string[] => getDependencies().concat(getCompatDependencies()), getQuickBuildConfig: getQuickConfig, getQuickServeConfig: getQuickConfig, getKarmaTestConfig: getBaseConfig, diff --git a/src/preact/index.js b/src/preact/index.js index e1f66843..cd19eeab 100644 --- a/src/preact/index.js +++ b/src/preact/index.js @@ -41,7 +41,7 @@ export default (args: Object) => ({ getProjectDefaults() { return {compat: false} }, - getProjectDependencies(answers: Object) { + getProjectDependencies(answers: Object): string[] { let deps = getDependencies() if (answers.compat) { deps = deps.concat(getCompatDependencies()) @@ -61,7 +61,7 @@ export default (args: Object) => ({ getBuildDependencies: () => [], getBuildConfig: getBaseConfig, getServeConfig: getBaseConfig, - getQuickDependencies: () => getDependencies().concat(getCompatDependencies()), + getQuickDependencies: (): string[] => getDependencies().concat(getCompatDependencies()), getQuickBuildConfig: getQuickConfig, getQuickServeConfig: getQuickConfig, getKarmaTestConfig: getBaseConfig, diff --git a/src/react/index.js b/src/react/index.js index 280c8d9c..56b198b2 100644 --- a/src/react/index.js +++ b/src/react/index.js @@ -126,7 +126,7 @@ class ReactConfig { return config } - getQuickDependencies = () => { + getQuickDependencies = (): string[] => { let deps = getBaseDependencies() if (/^build/.test(this._args._[0])) { deps = deps.concat(this._getCompatDependencies()) diff --git a/src/utils.js b/src/utils.js index 58908310..acd275e9 100644 --- a/src/utils.js +++ b/src/utils.js @@ -229,7 +229,7 @@ export function typeOf(o: any) { /** * @param {Array} strings */ -export function unique(strings: string[]) { +export function unique(strings: string[]): string[] { // eslint-disable-next-line return Object.keys(strings.reduce((o, s) => (o[s] = true, o), {})) } From a098ea99c03b8f63ebd4934a16f1b9427b417f84 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Fri, 17 Aug 2018 19:27:48 +1000 Subject: [PATCH 04/66] Update flow --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dc3216d5..1fa4c166 100644 --- a/package.json +++ b/package.json @@ -117,7 +117,7 @@ "cross-env": "5.2.0", "eslint-config-jonnybuchanan": "6.0.0", "eventsource": "1.0.5", - "flow-bin": "0.78.0", + "flow-bin": "0.79.0", "glob": "7.1.2", "nyc": "12.0.2", "rimraf": "2.6.2", From 0074028c13570ebec4ceb2bed7ca943221f663eb Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Fri, 17 Aug 2018 20:24:22 +1000 Subject: [PATCH 05/66] Update url-loader --- CHANGES.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 8425fa6b..08dc8c67 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,7 @@ - postcss-loader: v2.1.6 → [v3.0.0](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#300-2018-08-08) - dropped Node.js 4 support - style-loader: v0.21.0 → [v0.22.1](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0221-2018-08-08) - uglifyjs-webpack-plugin: v1.2.7 → [v1.3.0](https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/CHANGELOG.md#130-2018-08-14) +- url-loader: v1.0.1 → [v1.1.1](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md#111-2018-08-17) - webpack: v4.16.4 → [v4.16.5](https://github.com/webpack/webpack/releases/tag/v4.16.5) # 0.23.0 / 2018-08-03 diff --git a/package.json b/package.json index 1fa4c166..43918434 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,7 @@ "opn": "5.3.0", "postcss-loader": "3.0.0", "style-loader": "0.22.1", - "url-loader": "1.0.1", + "url-loader": "1.1.1", "uglifyjs-webpack-plugin": "1.3.0", "webpack-dev-middleware": "3.1.3", "webpack-dev-server": "3.1.5", From 44773d936cf46d2ba013505234607add7888b5eb Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Mon, 20 Aug 2018 12:42:12 +1000 Subject: [PATCH 06/66] Update dependencies --- CHANGES.md | 2 +- package.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 08dc8c67..f7b31ebb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,7 +2,7 @@ ## Dependencies -- autoprefixer: v9.0.2 → [v9.1.1](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#911) +- autoprefixer: v9.0.2 → [v9.1.2](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#912) - babel-plugin-inferno: v5.0.1 → [v5.1.0](https://github.com/infernojs/babel-plugin-inferno/releases) - inquirer: v6.0.0 → [v6.1.0](https://github.com/SBoudrias/Inquirer.js/releases/tag/inquirer%406.1.0) - karma: v2.0.0 → [v3.0.0](https://github.com/karma-runner/karma/releases/tag/v3.0.0) diff --git a/package.json b/package.json index 43918434..10d48312 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "ora": "3.0.0", "resolve": "1.8.1", "run-series": "1.1.8", - "semver": "5.5.0", + "semver": "5.5.1", "webpack-merge": "4.1.4", "babel-cli": "6.26.0", @@ -92,7 +92,7 @@ "whatwg-fetch": "2.0.4", "webpack": "4.16.5", - "autoprefixer": "9.1.1", + "autoprefixer": "9.1.2", "babel-loader": "7.1.5", "case-sensitive-paths-webpack-plugin": "2.1.2", "copy-webpack-plugin": "4.5.2", @@ -117,7 +117,7 @@ "cross-env": "5.2.0", "eslint-config-jonnybuchanan": "6.0.0", "eventsource": "1.0.5", - "flow-bin": "0.79.0", + "flow-bin": "0.79.1", "glob": "7.1.2", "nyc": "12.0.2", "rimraf": "2.6.2", From f25110e2c1fd9171d4dbefa04f99cd52d29e5e7d Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Wed, 22 Aug 2018 19:32:00 +1000 Subject: [PATCH 07/66] Update dependencies --- CHANGES.md | 7 +++++-- package.json | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f7b31ebb..d2e4c6d9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,15 +2,17 @@ ## Dependencies -- autoprefixer: v9.0.2 → [v9.1.2](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#912) +- autoprefixer: v9.0.2 → [v9.1.3](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#913) - babel-plugin-inferno: v5.0.1 → [v5.1.0](https://github.com/infernojs/babel-plugin-inferno/releases) +- file-loader: v1.1.11 → [v2.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#200-2018-08-21) - inquirer: v6.0.0 → [v6.1.0](https://github.com/SBoudrias/Inquirer.js/releases/tag/inquirer%406.1.0) - karma: v2.0.0 → [v3.0.0](https://github.com/karma-runner/karma/releases/tag/v3.0.0) +- mini-css-extract-plugin v0.4.1 → [v0.4.2](https://github.com/webpack-contrib/mini-css-extract-plugin/releases) - postcss-loader: v2.1.6 → [v3.0.0](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#300-2018-08-08) - dropped Node.js 4 support - style-loader: v0.21.0 → [v0.22.1](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0221-2018-08-08) - uglifyjs-webpack-plugin: v1.2.7 → [v1.3.0](https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/CHANGELOG.md#130-2018-08-14) - url-loader: v1.0.1 → [v1.1.1](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md#111-2018-08-17) -- webpack: v4.16.4 → [v4.16.5](https://github.com/webpack/webpack/releases/tag/v4.16.5) +- webpack: v4.16.4 → [v4.17.0](https://github.com/webpack/webpack/releases) # 0.23.0 / 2018-08-03 @@ -118,6 +120,7 @@ - cross-spawn: v6.0.4 → [v6.0.5](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md#605-2018-03-02) - css-loader: v0.28.9 → [v0.28.10](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#02810-2018-02-22) - extract-text-webpack-plugin v3.0.0 → [mini-css-extract-plugin v0.2.0](https://github.com/webpack-contrib/mini-css-extract-plugin) +- file-loader: v1.1.6 → [v1.1.11](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#1111-2018-03-01) - filesize: v3.5.11 → [v3.6.0](https://github.com/avoidwork/filesize.js/compare/3.5.11...3.6.0) - html-webpack-plugin: v2.30.1 → [v3.0.6](https://github.com/jantimon/html-webpack-plugin/blob/master/CHANGELOG.md#306-2018-03-06) - inquirer: v3.3.0 → [v5.1.0](https://github.com/SBoudrias/Inquirer.js/releases) - latest version requires Node.js 6 diff --git a/package.json b/package.json index 10d48312..e9cf39b8 100644 --- a/package.json +++ b/package.json @@ -91,16 +91,16 @@ "promise": "8.0.1", "whatwg-fetch": "2.0.4", - "webpack": "4.16.5", - "autoprefixer": "9.1.2", + "webpack": "4.17.0", + "autoprefixer": "9.1.3", "babel-loader": "7.1.5", "case-sensitive-paths-webpack-plugin": "2.1.2", "copy-webpack-plugin": "4.5.2", "css-loader": "1.0.0", "eventsource-polyfill": "0.9.6", - "file-loader": "1.1.11", + "file-loader": "2.0.0", "html-webpack-plugin": "3.2.0", - "mini-css-extract-plugin": "0.4.1", + "mini-css-extract-plugin": "0.4.2", "@insin/npm-install-webpack-plugin": "5.0.0", "opn": "5.3.0", "postcss-loader": "3.0.0", From 3b545b5f6abebd0d2b6f8c4241a1abe03aede3cf Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Fri, 24 Aug 2018 13:52:52 +1000 Subject: [PATCH 08/66] Update dependencies --- CHANGES.md | 5 +++-- package.json | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d2e4c6d9..013872d4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,14 +5,15 @@ - autoprefixer: v9.0.2 → [v9.1.3](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#913) - babel-plugin-inferno: v5.0.1 → [v5.1.0](https://github.com/infernojs/babel-plugin-inferno/releases) - file-loader: v1.1.11 → [v2.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#200-2018-08-21) -- inquirer: v6.0.0 → [v6.1.0](https://github.com/SBoudrias/Inquirer.js/releases/tag/inquirer%406.1.0) +- inquirer: v6.0.0 → [v6.2.0](https://github.com/SBoudrias/Inquirer.js/releases) - karma: v2.0.0 → [v3.0.0](https://github.com/karma-runner/karma/releases/tag/v3.0.0) - mini-css-extract-plugin v0.4.1 → [v0.4.2](https://github.com/webpack-contrib/mini-css-extract-plugin/releases) - postcss-loader: v2.1.6 → [v3.0.0](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#300-2018-08-08) - dropped Node.js 4 support - style-loader: v0.21.0 → [v0.22.1](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0221-2018-08-08) - uglifyjs-webpack-plugin: v1.2.7 → [v1.3.0](https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/CHANGELOG.md#130-2018-08-14) - url-loader: v1.0.1 → [v1.1.1](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md#111-2018-08-17) -- webpack: v4.16.4 → [v4.17.0](https://github.com/webpack/webpack/releases) +- webpack: v4.16.4 → [v4.17.1](https://github.com/webpack/webpack/releases) +- webpack-dev-middleware: v3.1.3 → [v3.2.0](https://github.com/webpack/webpack-dev-middleware/releases/tag/v3.2.0) # 0.23.0 / 2018-08-03 diff --git a/package.json b/package.json index e9cf39b8..03a2dda1 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "filesize": "3.6.1", "fs-extra": "7.0.0", "gzip-size": "5.0.0", - "inquirer": "6.1.0", + "inquirer": "6.2.0", "minimist": "1.2.0", "ora": "3.0.0", "resolve": "1.8.1", @@ -91,7 +91,7 @@ "promise": "8.0.1", "whatwg-fetch": "2.0.4", - "webpack": "4.17.0", + "webpack": "4.17.1", "autoprefixer": "9.1.3", "babel-loader": "7.1.5", "case-sensitive-paths-webpack-plugin": "2.1.2", @@ -107,7 +107,7 @@ "style-loader": "0.22.1", "url-loader": "1.1.1", "uglifyjs-webpack-plugin": "1.3.0", - "webpack-dev-middleware": "3.1.3", + "webpack-dev-middleware": "3.2.0", "webpack-dev-server": "3.1.5", "webpack-hot-middleware": "2.22.3" }, @@ -116,7 +116,7 @@ "babel-register": "6.26.0", "cross-env": "5.2.0", "eslint-config-jonnybuchanan": "6.0.0", - "eventsource": "1.0.5", + "eventsource": "1.0.6", "flow-bin": "0.79.1", "glob": "7.1.2", "nyc": "12.0.2", From 95952e8bc3e56383602d9e70cfbf3a34e757a6ea Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Wed, 29 Aug 2018 01:56:07 +1000 Subject: [PATCH 09/66] Update dependencies --- CHANGES.md | 3 ++- package.json | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 013872d4..bb2fd29c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,11 +9,12 @@ - karma: v2.0.0 → [v3.0.0](https://github.com/karma-runner/karma/releases/tag/v3.0.0) - mini-css-extract-plugin v0.4.1 → [v0.4.2](https://github.com/webpack-contrib/mini-css-extract-plugin/releases) - postcss-loader: v2.1.6 → [v3.0.0](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#300-2018-08-08) - dropped Node.js 4 support -- style-loader: v0.21.0 → [v0.22.1](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0221-2018-08-08) +- style-loader: v0.21.0 → [v0.23.0](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0230-2018-08-27) - uglifyjs-webpack-plugin: v1.2.7 → [v1.3.0](https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/CHANGELOG.md#130-2018-08-14) - url-loader: v1.0.1 → [v1.1.1](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md#111-2018-08-17) - webpack: v4.16.4 → [v4.17.1](https://github.com/webpack/webpack/releases) - webpack-dev-middleware: v3.1.3 → [v3.2.0](https://github.com/webpack/webpack-dev-middleware/releases/tag/v3.2.0) +- webpack-dev-server: v3.1.5 → [v3.1.6](https://github.com/webpack/webpack-dev-server/releases/tag/v3.1.6) # 0.23.0 / 2018-08-03 diff --git a/package.json b/package.json index 03a2dda1..e0442f06 100644 --- a/package.json +++ b/package.json @@ -104,11 +104,11 @@ "@insin/npm-install-webpack-plugin": "5.0.0", "opn": "5.3.0", "postcss-loader": "3.0.0", - "style-loader": "0.22.1", + "style-loader": "0.23.0", "url-loader": "1.1.1", "uglifyjs-webpack-plugin": "1.3.0", "webpack-dev-middleware": "3.2.0", - "webpack-dev-server": "3.1.5", + "webpack-dev-server": "3.1.6", "webpack-hot-middleware": "2.22.3" }, "devDependencies": { @@ -116,9 +116,9 @@ "babel-register": "6.26.0", "cross-env": "5.2.0", "eslint-config-jonnybuchanan": "6.0.0", - "eventsource": "1.0.6", + "eventsource": "1.0.7", "flow-bin": "0.79.1", - "glob": "7.1.2", + "glob": "7.1.3", "nyc": "12.0.2", "rimraf": "2.6.2", "temp": "0.8.3", From 3630d5659f13aff63e836113f6c224331fdd0356 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Mon, 3 Sep 2018 08:36:53 +1000 Subject: [PATCH 10/66] Update dependencies --- CHANGES.md | 4 +++- package.json | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index bb2fd29c..970a1a18 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ - file-loader: v1.1.11 → [v2.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#200-2018-08-21) - inquirer: v6.0.0 → [v6.2.0](https://github.com/SBoudrias/Inquirer.js/releases) - karma: v2.0.0 → [v3.0.0](https://github.com/karma-runner/karma/releases/tag/v3.0.0) +- karma-webpack: v3.0.0 → [v3.0.1](https://github.com/webpack-contrib/karma-webpack/releases/tag/v3.0.1) - mini-css-extract-plugin v0.4.1 → [v0.4.2](https://github.com/webpack-contrib/mini-css-extract-plugin/releases) - postcss-loader: v2.1.6 → [v3.0.0](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#300-2018-08-08) - dropped Node.js 4 support - style-loader: v0.21.0 → [v0.23.0](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0230-2018-08-27) @@ -14,7 +15,8 @@ - url-loader: v1.0.1 → [v1.1.1](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md#111-2018-08-17) - webpack: v4.16.4 → [v4.17.1](https://github.com/webpack/webpack/releases) - webpack-dev-middleware: v3.1.3 → [v3.2.0](https://github.com/webpack/webpack-dev-middleware/releases/tag/v3.2.0) -- webpack-dev-server: v3.1.5 → [v3.1.6](https://github.com/webpack/webpack-dev-server/releases/tag/v3.1.6) +- webpack-dev-server: v3.1.5 → [v3.1.7](https://github.com/webpack/webpack-dev-server/releases) +- webpack-hot-middleware: v2.22.3 → [v2.23.0](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.22.3...v2.23.0) # 0.23.0 / 2018-08-03 diff --git a/package.json b/package.json index e0442f06..d441a8ba 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "karma-mocha-reporter": "2.2.5", "karma-phantomjs-launcher": "1.0.4", "karma-sourcemap-loader": "0.3.7", - "karma-webpack": "3.0.0", + "karma-webpack": "3.0.1", "phantomjs-prebuilt": "2.1.16", "mocha": "5.2.0", @@ -108,8 +108,8 @@ "url-loader": "1.1.1", "uglifyjs-webpack-plugin": "1.3.0", "webpack-dev-middleware": "3.2.0", - "webpack-dev-server": "3.1.6", - "webpack-hot-middleware": "2.22.3" + "webpack-dev-server": "3.1.7", + "webpack-hot-middleware": "2.23.0" }, "devDependencies": { "babel-preset-flow": "6.23.0", @@ -117,7 +117,7 @@ "cross-env": "5.2.0", "eslint-config-jonnybuchanan": "6.0.0", "eventsource": "1.0.7", - "flow-bin": "0.79.1", + "flow-bin": "0.80.0", "glob": "7.1.3", "nyc": "12.0.2", "rimraf": "2.6.2", From ed9680ea199cac82cd27794c1c76520a54bee56b Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Mon, 3 Sep 2018 12:59:00 +1000 Subject: [PATCH 11/66] Update dependencies --- CHANGES.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 970a1a18..66500395 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,7 +7,7 @@ - file-loader: v1.1.11 → [v2.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#200-2018-08-21) - inquirer: v6.0.0 → [v6.2.0](https://github.com/SBoudrias/Inquirer.js/releases) - karma: v2.0.0 → [v3.0.0](https://github.com/karma-runner/karma/releases/tag/v3.0.0) -- karma-webpack: v3.0.0 → [v3.0.1](https://github.com/webpack-contrib/karma-webpack/releases/tag/v3.0.1) +- karma-webpack: v3.0.0 → [v3.0.2](https://github.com/webpack-contrib/karma-webpack/releases) - mini-css-extract-plugin v0.4.1 → [v0.4.2](https://github.com/webpack-contrib/mini-css-extract-plugin/releases) - postcss-loader: v2.1.6 → [v3.0.0](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#300-2018-08-08) - dropped Node.js 4 support - style-loader: v0.21.0 → [v0.23.0](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0230-2018-08-27) diff --git a/package.json b/package.json index d441a8ba..b3f8e3e4 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "karma-mocha-reporter": "2.2.5", "karma-phantomjs-launcher": "1.0.4", "karma-sourcemap-loader": "0.3.7", - "karma-webpack": "3.0.1", + "karma-webpack": "3.0.2", "phantomjs-prebuilt": "2.1.16", "mocha": "5.2.0", From 91ef6a06aeb988a72b7d22bf6c4e49ead36c1aa6 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Tue, 4 Sep 2018 12:14:54 +1000 Subject: [PATCH 12/66] Update dependencies --- CHANGES.md | 5 ++--- package.json | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 66500395..585711c7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,16 +7,15 @@ - file-loader: v1.1.11 → [v2.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#200-2018-08-21) - inquirer: v6.0.0 → [v6.2.0](https://github.com/SBoudrias/Inquirer.js/releases) - karma: v2.0.0 → [v3.0.0](https://github.com/karma-runner/karma/releases/tag/v3.0.0) -- karma-webpack: v3.0.0 → [v3.0.2](https://github.com/webpack-contrib/karma-webpack/releases) - mini-css-extract-plugin v0.4.1 → [v0.4.2](https://github.com/webpack-contrib/mini-css-extract-plugin/releases) - postcss-loader: v2.1.6 → [v3.0.0](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#300-2018-08-08) - dropped Node.js 4 support - style-loader: v0.21.0 → [v0.23.0](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0230-2018-08-27) - uglifyjs-webpack-plugin: v1.2.7 → [v1.3.0](https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/CHANGELOG.md#130-2018-08-14) - url-loader: v1.0.1 → [v1.1.1](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md#111-2018-08-17) -- webpack: v4.16.4 → [v4.17.1](https://github.com/webpack/webpack/releases) +- webpack: v4.16.4 → [v4.17.2](https://github.com/webpack/webpack/releases) - webpack-dev-middleware: v3.1.3 → [v3.2.0](https://github.com/webpack/webpack-dev-middleware/releases/tag/v3.2.0) - webpack-dev-server: v3.1.5 → [v3.1.7](https://github.com/webpack/webpack-dev-server/releases) -- webpack-hot-middleware: v2.22.3 → [v2.23.0](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.22.3...v2.23.0) +- webpack-hot-middleware: v2.22.3 → [v2.23.1](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.22.3...v2.23.1) # 0.23.0 / 2018-08-03 diff --git a/package.json b/package.json index b3f8e3e4..5f992937 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "karma-mocha-reporter": "2.2.5", "karma-phantomjs-launcher": "1.0.4", "karma-sourcemap-loader": "0.3.7", - "karma-webpack": "3.0.2", + "karma-webpack": "3.0.0", "phantomjs-prebuilt": "2.1.16", "mocha": "5.2.0", @@ -91,7 +91,7 @@ "promise": "8.0.1", "whatwg-fetch": "2.0.4", - "webpack": "4.17.1", + "webpack": "4.17.2", "autoprefixer": "9.1.3", "babel-loader": "7.1.5", "case-sensitive-paths-webpack-plugin": "2.1.2", @@ -109,7 +109,7 @@ "uglifyjs-webpack-plugin": "1.3.0", "webpack-dev-middleware": "3.2.0", "webpack-dev-server": "3.1.7", - "webpack-hot-middleware": "2.23.0" + "webpack-hot-middleware": "2.23.1" }, "devDependencies": { "babel-preset-flow": "6.23.0", From d66162f94a23b2ba78eaa2973923f5a72bec4a0b Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Tue, 2 Oct 2018 14:03:27 +1000 Subject: [PATCH 13/66] Replace use of UglifyJsPlugin with TerserWebpackPlugin --- CHANGES.md | 7 ++++++- docs/Configuration.md | 16 ++++++++-------- flow-typed/libdefs.js | 2 +- src/config/webpack.js | 29 ++++++++++++++++++++++++----- src/createWebpackConfig.js | 30 +++++++++++++++--------------- src/moduleBuild.js | 6 +++--- tests/config-test.js | 4 ++-- tests/fixtures/worst-config.js | 2 +- 8 files changed, 60 insertions(+), 36 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 585711c7..0e2a7461 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ # Unreleased (in `master`) +## Changes + +- Replaced use of `UglifyJsPlugin` with `TerserWebpackPlugin`. + - Deprecated `webpack.uglify` config, which has been renamed to [`webpack.terser`](https://github.com/insin/nwb/blob/master/docs/Configuration.md#uglify-object--false). + ## Dependencies - autoprefixer: v9.0.2 → [v9.1.3](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#913) @@ -10,7 +15,7 @@ - mini-css-extract-plugin v0.4.1 → [v0.4.2](https://github.com/webpack-contrib/mini-css-extract-plugin/releases) - postcss-loader: v2.1.6 → [v3.0.0](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#300-2018-08-08) - dropped Node.js 4 support - style-loader: v0.21.0 → [v0.23.0](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0230-2018-08-27) -- uglifyjs-webpack-plugin: v1.2.7 → [v1.3.0](https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/CHANGELOG.md#130-2018-08-14) +- uglifyjs-webpack-plugin v1.2.7 → [terser-webpack-plugin v1.1.0](https://github.com/webpack-contrib/terser-webpack-plugin#readme) - url-loader: v1.0.1 → [v1.1.1](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md#111-2018-08-17) - webpack: v4.16.4 → [v4.17.2](https://github.com/webpack/webpack/releases) - webpack-dev-middleware: v3.1.3 → [v3.2.0](https://github.com/webpack/webpack-dev-middleware/releases/tag/v3.2.0) diff --git a/docs/Configuration.md b/docs/Configuration.md index fe1e070f..9efb40b0 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -98,7 +98,7 @@ The configuration object can include the following properties: - [Customising loaders](#customising-loaders) - [Disabling default rules](#disabling-default-rules) - [`webpack.styles`](#styles-object--false) - customise creation of Webpack rules for stylesheets - - [`webpack.uglify`](#uglify-object--false) - configure use of Webpack's `UglifyJsPlugin` + - [`webpack.terser`](#terser-object--false) - configure use of `TerserWebpackPlugin` - [`webpack.extra`](#extra-object) - an escape hatch for extra Webpack config, which will be merged into the generated config - [`webpack.config`](#config-function-1) - an escape hatch for manually editing the generated Webpack config - [Dev Server Configuration](#dev-server-configuration) @@ -492,7 +492,7 @@ nwb preact build app.js --webpack.debug If you set `debug` in your config file, nwb will always display a hint to remind you to remove it later. -> **Note:** if you've customised `UglifyJsPlugin` settings via [`webpack.uglify` config](#uglify-object--false), only `webpack.uglify.compress` will be used when a debug build is enabled. +> **Note:** if you've customised `TerserWebpackPlugin` settings via [`webpack.terser` config](#terser-object--false), only `webpack.terser.compress` will be used when a debug build is enabled. ##### `define`: `Object` @@ -731,9 +731,9 @@ Configures how nwb creates Webpack config for importing stylesheets. See the [Stylesheets documentation](/docs/Stylesheets.md#stylesheets) for details. -##### `uglify`: `Object | false` +##### `terser`: `Object | false` -Configures [options for Webpack's `UglifyJsPlugin`](https://github.com/webpack-contrib/uglifyjs-webpack-plugin#readme), which will be used when creating production builds. +Configures [options for `TerserWebpackPlugin`](https://github.com/webpack-contrib/terser-webpack-plugin#readme), which will be used when creating production builds. Any additional options provided will be merged into nwb's defaults, which are: @@ -750,8 +750,8 @@ For example, if you want to strip development-only code but keep the output read ```js module.exports = { webpack: { - uglify: { - uglifyOptions: { + terser: { + terserOptions: { mangle: false, beautify: true } @@ -760,12 +760,12 @@ module.exports = { } ``` -To completely disable use of UglifyJS, set `uglify` to false: +To completely disable use of Terser, set `terser` to false: ```js module.exports = { webpack: { - uglify: false + terser: false } } ``` diff --git a/flow-typed/libdefs.js b/flow-typed/libdefs.js index a7cebfcb..8ad531ae 100644 --- a/flow-typed/libdefs.js +++ b/flow-typed/libdefs.js @@ -9,7 +9,7 @@ declare module 'mini-css-extract-plugin' { declare module.exports: any; } declare module '@insin/npm-install-webpack-plugin' { declare module.exports: any; } declare module 'ora' { declare module.exports: any; } declare module 'resolve' { declare module.exports: any; } -declare module 'uglifyjs-webpack-plugin' { declare module.exports: any; } +declare module 'terser-webpack-plugin' { declare module.exports: any; } declare module 'webpack' { declare module.exports: any; } declare module 'webpack-dev-middleware' { declare module.exports: any; } declare module 'webpack-hot-middleware' { declare module.exports: any; } diff --git a/src/config/webpack.js b/src/config/webpack.js index f4dd7d8e..0f11c5ef 100644 --- a/src/config/webpack.js +++ b/src/config/webpack.js @@ -6,6 +6,8 @@ import {joinAnd, pluralise as s, typeOf} from '../utils' const DEFAULT_STYLE_LOADERS = new Set(['css', 'postcss']) +let warnedAboutUglify = false + export function processWebpackConfig({pluginConfig, report, userConfig}) { let { aliases, @@ -20,6 +22,7 @@ export function processWebpackConfig({pluginConfig, report, userConfig}) { publicPath, rules, styles, + terser, uglify, extra, config, @@ -330,14 +333,30 @@ export function processWebpackConfig({pluginConfig, report, userConfig}) { } } + // TODO Deprecated - remove // uglify if ('uglify' in userConfig.webpack) { - if (uglify !== false && typeOf(uglify) !== 'object') { + if (!warnedAboutUglify) { + report.deprecated( + 'webpack.uglify', + `This setting has been renamed to ${chalk.cyan('webpack.terser')} as of nwb v0.24` + ) + warnedAboutUglify = true + if (!('terser' in userConfig.webpack)) { + userConfig.webpack.terser = uglify + terser = uglify + } + } + } + + // terser + if ('terser' in userConfig.webpack) { + if (terser !== false && typeOf(terser) !== 'object') { report.error( - `webpack.uglify`, - uglify, - `Must be ${chalk.cyan('false')} (to disable UglifyJsPlugin) or ` + - `an ${chalk.cyan('Object')} (to configure UglifyJsPlugin)` + `webpack.terser`, + terser, + `Must be ${chalk.cyan('false')} (to disable terser-webpack-plugin) or ` + + `an ${chalk.cyan('Object')} (to configure terser-webpack-plugin)` ) } } diff --git a/src/createWebpackConfig.js b/src/createWebpackConfig.js index f0d1ec4b..8a7d676c 100644 --- a/src/createWebpackConfig.js +++ b/src/createWebpackConfig.js @@ -38,18 +38,18 @@ type RuleConfigFactory = (?string, RuleConfig) => ?RuleConfig; type ServerConfig = boolean | Object; -const DEFAULT_UGLIFY_CONFIG = { +const DEFAULT_TERSER_CONFIG = { cache: true, parallel: true, sourceMap: true, } -function createUglifyConfig(userWebpackConfig) { +function createTerserConfig(userWebpackConfig) { if (userWebpackConfig.debug) { return merge( - DEFAULT_UGLIFY_CONFIG, + DEFAULT_TERSER_CONFIG, { - uglifyOptions: { + terserOptions: { output: { beautify: true, }, @@ -58,16 +58,16 @@ function createUglifyConfig(userWebpackConfig) { }, // Preserve user 'compress' config if present, as it affects what gets // removed from the production build. - typeof userWebpackConfig.uglify === 'object' && - typeof userWebpackConfig.uglify.uglifyConfig === 'object' && - 'compress' in userWebpackConfig.uglify.uglifyConfig - ? {uglifyOptions: {compress: userWebpackConfig.uglify.uglifyConfig.compress}} + typeof userWebpackConfig.terser === 'object' && + typeof userWebpackConfig.terser.terserConfig === 'object' && + 'compress' in userWebpackConfig.terser.terserConfig + ? {terserOptions: {compress: userWebpackConfig.terser.terserConfig.compress}} : {} ) } return merge( - DEFAULT_UGLIFY_CONFIG, - typeof userWebpackConfig.uglify === 'object' ? userWebpackConfig.uglify : {} + DEFAULT_TERSER_CONFIG, + typeof userWebpackConfig.terser === 'object' ? userWebpackConfig.terser : {} ) } @@ -532,13 +532,13 @@ export function createPlugins( debug: false, minimize: true, })) - optimization.minimize = buildConfig.uglify !== false && userConfig.uglify !== false - if (buildConfig.uglify !== false && userConfig.uglify !== false) { + optimization.minimize = buildConfig.terser !== false && userConfig.terser !== false + if (buildConfig.terser !== false && userConfig.terser !== false) { optimization.minimizer = [{ apply(compiler: any) { - // Lazy load the uglifyjs plugin - let UglifyJsPlugin = require('uglifyjs-webpack-plugin') - new UglifyJsPlugin(createUglifyConfig(userConfig)).apply(compiler) + // Lazy load the terser plugin + let TerserPlugin = require('terser-webpack-plugin') + new TerserPlugin(createTerserConfig(userConfig)).apply(compiler) } }] } diff --git a/src/moduleBuild.js b/src/moduleBuild.js index b3c9f07e..6d7ba96d 100644 --- a/src/moduleBuild.js +++ b/src/moduleBuild.js @@ -81,7 +81,7 @@ function buildUMD(args, buildConfig, userConfig, cb) { polyfill: false, plugins: { banner: createBanner(pkg), - uglify: false, + terser: false, }, } @@ -92,7 +92,7 @@ function buildUMD(args, buildConfig, userConfig, cb) { return cb(err) } - if (userConfig.uglify === false) { + if (userConfig.terser === false) { spinner.succeed() console.log() logGzippedFileSizes(stats1) @@ -102,7 +102,7 @@ function buildUMD(args, buildConfig, userConfig, cb) { webpackBuildConfig.babel = merge(buildConfig.babel, buildConfig.babelProd || {}) webpackBuildConfig.devtool = 'source-map' webpackBuildConfig.output.filename = `${pkg.name}.min.js` - webpackBuildConfig.plugins.uglify = true + webpackBuildConfig.plugins.terser = true webpackBuild(null, args, webpackBuildConfig, (err, stats2) => { if (err) { spinner.fail() diff --git a/tests/config-test.js b/tests/config-test.js index 1625a997..0c3668fc 100644 --- a/tests/config-test.js +++ b/tests/config-test.js @@ -176,8 +176,8 @@ describe('processUserConfig()', () => { it('webpack.styles style type config object contains an invalid property', () => { check({webpack: {styles: {css: [{invalid: true}]}}}, 'webpack.styles.css[0]', /Must be/) }) - it('webpack.uglify is an invalid type', () => { - check({webpack: {uglify: /text/}}, 'webpack.uglify', /Must be/) + it('webpack.terser is an invalid type', () => { + check({webpack: {terser: /text/}}, 'webpack.terser', /Must be/) }) it('webpack.extra is not an object', () => { check({webpack: {extra: []}}, 'webpack.extra', /Must be/) diff --git a/tests/fixtures/worst-config.js b/tests/fixtures/worst-config.js index 9bf6e7b8..1d408554 100644 --- a/tests/fixtures/worst-config.js +++ b/tests/fixtures/worst-config.js @@ -60,7 +60,7 @@ module.exports = { publicPath: 45, rules: 45, styles: 45, - uglify: 45, + terser: 45, extra: 45, config: 45, } From ac2bf0b6f892c04342340c2d7582cb91f8b47453 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Tue, 2 Oct 2018 14:03:34 +1000 Subject: [PATCH 14/66] Update dependencies --- CHANGES.md | 16 ++++++++++------ package.json | 26 +++++++++++++------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 0e2a7461..a0958ae6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,20 +7,24 @@ ## Dependencies -- autoprefixer: v9.0.2 → [v9.1.3](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#913) +- autoprefixer: v9.0.2 → [v9.1.5](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#913) - babel-plugin-inferno: v5.0.1 → [v5.1.0](https://github.com/infernojs/babel-plugin-inferno/releases) - file-loader: v1.1.11 → [v2.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#200-2018-08-21) - inquirer: v6.0.0 → [v6.2.0](https://github.com/SBoudrias/Inquirer.js/releases) - karma: v2.0.0 → [v3.0.0](https://github.com/karma-runner/karma/releases/tag/v3.0.0) -- mini-css-extract-plugin v0.4.1 → [v0.4.2](https://github.com/webpack-contrib/mini-css-extract-plugin/releases) +- karma-webpack: v3.0.0 → [v3.0.5](https://github.com/webpack-contrib/karma-webpack/releases) +- mini-css-extract-plugin v0.4.1 → [v0.4.3](https://github.com/webpack-contrib/mini-css-extract-plugin/releases) +- opn: v5.3.0 → [v5.4.0](https://github.com/sindresorhus/opn/compare/v5.3.0...v5.4.0) - postcss-loader: v2.1.6 → [v3.0.0](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#300-2018-08-08) - dropped Node.js 4 support +- promise: v8.0.1 → v8.0.2 - style-loader: v0.21.0 → [v0.23.0](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0230-2018-08-27) - uglifyjs-webpack-plugin v1.2.7 → [terser-webpack-plugin v1.1.0](https://github.com/webpack-contrib/terser-webpack-plugin#readme) - url-loader: v1.0.1 → [v1.1.1](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md#111-2018-08-17) -- webpack: v4.16.4 → [v4.17.2](https://github.com/webpack/webpack/releases) -- webpack-dev-middleware: v3.1.3 → [v3.2.0](https://github.com/webpack/webpack-dev-middleware/releases/tag/v3.2.0) -- webpack-dev-server: v3.1.5 → [v3.1.7](https://github.com/webpack/webpack-dev-server/releases) -- webpack-hot-middleware: v2.22.3 → [v2.23.1](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.22.3...v2.23.1) +- webpack: v4.16.4 → [v4.20.2](https://github.com/webpack/webpack/releases) +- webpack-dev-middleware: v3.1.3 → [v3.4.0](https://github.com/webpack/webpack-dev-middleware/releases) +- webpack-dev-server: v3.1.5 → [v3.1.9](https://github.com/webpack/webpack-dev-server/releases) +- webpack-hot-middleware: v2.22.3 → [v2.24.2](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.22.3...v2.24.2) +- whatwg-fetch: v2.0.4 → [v3.0.0](https://github.com/github/fetch/releases/tag/v3.0.0) # 0.23.0 / 2018-08-03 diff --git a/package.json b/package.json index 5f992937..e5e78507 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "chalk": "2.4.1", "copy-template-dir": "1.4.0", "cross-spawn": "6.0.5", - "debug": "3.1.0", + "debug": "4.0.1", "detect-port": "1.2.3", "figures": "2.0.0", "filesize": "3.6.1", @@ -81,18 +81,18 @@ "karma-mocha-reporter": "2.2.5", "karma-phantomjs-launcher": "1.0.4", "karma-sourcemap-loader": "0.3.7", - "karma-webpack": "3.0.0", + "karma-webpack": "3.0.5", "phantomjs-prebuilt": "2.1.16", "mocha": "5.2.0", "expect": "1.20.2", "object-assign": "4.1.1", - "promise": "8.0.1", - "whatwg-fetch": "2.0.4", + "promise": "8.0.2", + "whatwg-fetch": "3.0.0", - "webpack": "4.17.2", - "autoprefixer": "9.1.3", + "webpack": "4.20.2", + "autoprefixer": "9.1.5", "babel-loader": "7.1.5", "case-sensitive-paths-webpack-plugin": "2.1.2", "copy-webpack-plugin": "4.5.2", @@ -100,16 +100,16 @@ "eventsource-polyfill": "0.9.6", "file-loader": "2.0.0", "html-webpack-plugin": "3.2.0", - "mini-css-extract-plugin": "0.4.2", + "mini-css-extract-plugin": "0.4.3", "@insin/npm-install-webpack-plugin": "5.0.0", - "opn": "5.3.0", + "opn": "5.4.0", "postcss-loader": "3.0.0", "style-loader": "0.23.0", "url-loader": "1.1.1", - "uglifyjs-webpack-plugin": "1.3.0", - "webpack-dev-middleware": "3.2.0", - "webpack-dev-server": "3.1.7", - "webpack-hot-middleware": "2.23.1" + "terser-webpack-plugin": "1.1.0", + "webpack-dev-middleware": "3.4.0", + "webpack-dev-server": "3.1.9", + "webpack-hot-middleware": "2.24.2" }, "devDependencies": { "babel-preset-flow": "6.23.0", @@ -117,7 +117,7 @@ "cross-env": "5.2.0", "eslint-config-jonnybuchanan": "6.0.0", "eventsource": "1.0.7", - "flow-bin": "0.80.0", + "flow-bin": "0.82.0", "glob": "7.1.3", "nyc": "12.0.2", "rimraf": "2.6.2", From 7f04c6af5fcc47472f8189517cd5365efa89480c Mon Sep 17 00:00:00 2001 From: Robert Rapiteanu Date: Sat, 29 Dec 2018 06:18:00 +0200 Subject: [PATCH 15/66] added formatPackageName to remove scope from pkg.name for umd builds --- src/moduleBuild.js | 6 +++--- src/utils.js | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/moduleBuild.js b/src/moduleBuild.js index 6d7ba96d..de940870 100644 --- a/src/moduleBuild.js +++ b/src/moduleBuild.js @@ -11,7 +11,7 @@ import {getPluginConfig, getUserConfig} from './config' import createBabelConfig from './createBabelConfig' import debug from './debug' import {UserError} from './errors' -import {deepToString} from './utils' +import {deepToString, formatPackageName} from './utils' import webpackBuild from './webpackBuild' import {createBanner, createExternals, logGzippedFileSizes} from './webpackUtils' @@ -71,7 +71,7 @@ function buildUMD(args, buildConfig, userConfig, cb) { babel: buildConfig.babel, entry: [userConfig.npm.umd.entry || entry], output: { - filename: `${pkg.name}.js`, + filename: `${formatPackageName(pkg.name)}.js`, library: userConfig.npm.umd.global, libraryExport: 'default', libraryTarget: 'umd', @@ -101,7 +101,7 @@ function buildUMD(args, buildConfig, userConfig, cb) { webpackBuildConfig.babel = merge(buildConfig.babel, buildConfig.babelProd || {}) webpackBuildConfig.devtool = 'source-map' - webpackBuildConfig.output.filename = `${pkg.name}.min.js` + webpackBuildConfig.output.filename = `${formatPackageName(pkg.name)}.min.js` webpackBuildConfig.plugins.terser = true webpackBuild(null, args, webpackBuildConfig, (err, stats2) => { if (err) { diff --git a/src/utils.js b/src/utils.js index acd275e9..bb09160f 100644 --- a/src/utils.js +++ b/src/utils.js @@ -233,3 +233,14 @@ export function unique(strings: string[]): string[] { // eslint-disable-next-line return Object.keys(strings.reduce((o, s) => (o[s] = true, o), {})) } + +/** + * Removes npm package scope from package name + */ +export function formatPackageName(name: string) { + const scopedPackageRegex = new RegExp(`^@[a-z0-9][\\w-.]+/[a-z0-9][\\w-.]*`, 'i') + if (scopedPackageRegex.test(name)) { + return name.split('/')[1] + } + return name +} From f49e775ceef297bdca76d997e687e289fa88bee5 Mon Sep 17 00:00:00 2001 From: Robert Rapiteanu Date: Thu, 10 Jan 2019 05:07:52 +0200 Subject: [PATCH 16/66] added tests --- tests/utils-test.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/utils-test.js b/tests/utils-test.js index 8d69d6d2..473e7921 100644 --- a/tests/utils-test.js +++ b/tests/utils-test.js @@ -1,7 +1,7 @@ // @flow import expect from 'expect' -import {joinAnd} from '../src/utils' +import {joinAnd, formatPackageName} from '../src/utils' import {createBanner, createExternals} from '../src/webpackUtils' describe('utils', () => { @@ -19,6 +19,15 @@ describe('utils', () => { expect(joinAnd(['one', 'two', 'three'])).toEqual('one, two and three') }) }) + + describe('formatPackageName()', () => { + it('returns the name without the npm scope', () => { + expect(formatPackageName("@org/component")).toEqual("component") + }) + it('returns the name as is', () => { + expect(formatPackageName("component")).toEqual("component") + }) + }) }) describe('webpackUtils', () => { From a9dd6f34221ba79e12337e85b270a4bb856a775c Mon Sep 17 00:00:00 2001 From: Robert Rapiteanu Date: Thu, 10 Jan 2019 05:11:18 +0200 Subject: [PATCH 17/66] single quotes --- tests/utils-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/utils-test.js b/tests/utils-test.js index 473e7921..af378efe 100644 --- a/tests/utils-test.js +++ b/tests/utils-test.js @@ -22,10 +22,10 @@ describe('utils', () => { describe('formatPackageName()', () => { it('returns the name without the npm scope', () => { - expect(formatPackageName("@org/component")).toEqual("component") + expect(formatPackageName('@org/component')).toEqual('component') }) it('returns the name as is', () => { - expect(formatPackageName("component")).toEqual("component") + expect(formatPackageName('component')).toEqual('component') }) }) }) From 71befb3b9fc289da98a8a9b61bc2018b5fd2d4e4 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Mon, 11 Mar 2019 12:22:17 +1000 Subject: [PATCH 18/66] Update dependencies & drop support for Node.js 6 --- .travis.yml | 1 - CHANGES.md | 46 ++++++++++++++++++------ package.json | 62 ++++++++++++++++----------------- tests/commands/projects-test.js | 14 ++++---- 4 files changed, 73 insertions(+), 50 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3382ef13..b5c01869 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ sudo: false language: node_js node_js: - - 6 - 8 - 10 diff --git a/CHANGES.md b/CHANGES.md index a0958ae6..815b977a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,16 @@ # Unreleased (in `master`) +## Breaking Changes + +- Node.js 6 is no longer supported; Node.js 8.9.0 is now the minimum required version, as per nwb's dependencies. +- Dependencies with (documented) breaking changes: + - [copy-webpack-plugin@5.0.0](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#breaking-changes) + - [css-loader@2.0.0](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#breaking-changes) + - [file-loader@2.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#breaking-changes-1) + - [file-loader@3.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#breaking-changes) + - [karma@4.0.0](https://github.com/karma-runner/karma/releases/tag/v4.0.0) + - [mocha@6.0.0](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#boom-breaking-changes) + ## Changes - Replaced use of `UglifyJsPlugin` with `TerserWebpackPlugin`. @@ -7,23 +18,36 @@ ## Dependencies -- autoprefixer: v9.0.2 → [v9.1.5](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#913) +- autoprefixer: v9.0.2 → [v9.4.10](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#9410) +- babel-plugin-add-module-exports: v0.2.1 → [v1.0.0](https://github.com/59naga/babel-plugin-add-module-exports/releases) - babel-plugin-inferno: v5.0.1 → [v5.1.0](https://github.com/infernojs/babel-plugin-inferno/releases) -- file-loader: v1.1.11 → [v2.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#200-2018-08-21) -- inquirer: v6.0.0 → [v6.2.0](https://github.com/SBoudrias/Inquirer.js/releases) -- karma: v2.0.0 → [v3.0.0](https://github.com/karma-runner/karma/releases/tag/v3.0.0) +- case-sensitive-paths-webpack-plugin: v2.1.2 → [v2.2.0](https://github.com/Urthen/case-sensitive-paths-webpack-plugin/blob/master/CHANGELOG.md#v220) +- chalk: v2.4.1 → [v2.4.2](https://github.com/chalk/chalk/compare/v2.4.1...v2.4.2) +- copy-webpack-plugin: v4.5.2 → [v5.0.0](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#500-2019-02-20) +- css-loader: v1.0.0 → [v2.1.1](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#211-2019-03-07) +- detect-port: v1.2.3 → [v1.3.0](https://github.com/node-modules/detect-port/releases) +- filesize: v3.6.1 → [v4.1.2](https://github.com/avoidwork/filesize.js/compare/3.6.1...4.1.2) +- file-loader: v1.1.11 → [v3.0.1](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#301-2018-12-20) +- fs-extra: v7.0.0 → [v7.0.1](https://github.com/jprichardson/node-fs-extra/blob/master/CHANGELOG.md#701--2018-11-07) +- inquirer: v6.0.0 → [v6.2.2](https://github.com/SBoudrias/Inquirer.js/releases) +- karma: v2.0.0 → [v4.0.1](https://github.com/karma-runner/karma/releases) - karma-webpack: v3.0.0 → [v3.0.5](https://github.com/webpack-contrib/karma-webpack/releases) -- mini-css-extract-plugin v0.4.1 → [v0.4.3](https://github.com/webpack-contrib/mini-css-extract-plugin/releases) +- mini-css-extract-plugin v0.4.1 → [v0.5.0](https://github.com/webpack-contrib/mini-css-extract-plugin/releases) +- mocha: v5.2.0 → [v6.0.2](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#602--2019-02-25) - opn: v5.3.0 → [v5.4.0](https://github.com/sindresorhus/opn/compare/v5.3.0...v5.4.0) +- ora: v3.0.0 → [v3.2.0](https://github.com/sindresorhus/ora/compare/v3.0.0...v3.2.0) - postcss-loader: v2.1.6 → [v3.0.0](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#300-2018-08-08) - dropped Node.js 4 support - promise: v8.0.1 → v8.0.2 -- style-loader: v0.21.0 → [v0.23.0](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0230-2018-08-27) -- uglifyjs-webpack-plugin v1.2.7 → [terser-webpack-plugin v1.1.0](https://github.com/webpack-contrib/terser-webpack-plugin#readme) -- url-loader: v1.0.1 → [v1.1.1](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md#111-2018-08-17) -- webpack: v4.16.4 → [v4.20.2](https://github.com/webpack/webpack/releases) -- webpack-dev-middleware: v3.1.3 → [v3.4.0](https://github.com/webpack/webpack-dev-middleware/releases) +- resolve: v1.8.1 → [v1.10.0](https://github.com/browserify/resolve/compare/v1.8.1...v1.10.0) +- semver: v5.5.1 → [v5.6.0](https://github.com/npm/node-semver/compare/v5.5.1...v5.6.0) +- style-loader: v0.21.0 → [v0.23.1](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0231-2018-10-08) +- uglifyjs-webpack-plugin v1.2.7 → [terser-webpack-plugin v1.2.3](https://github.com/webpack-contrib/terser-webpack-plugin#readme) +- url-loader: v1.0.1 → [v1.1.2](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md#112-2018-10-10) +- webpack: v4.16.4 → [v4.29.6](https://github.com/webpack/webpack/releases) +- webpack-dev-middleware: v3.1.3 → [v3.6.1](https://github.com/webpack/webpack-dev-middleware/releases) - webpack-dev-server: v3.1.5 → [v3.1.9](https://github.com/webpack/webpack-dev-server/releases) -- webpack-hot-middleware: v2.22.3 → [v2.24.2](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.22.3...v2.24.2) +- webpack-hot-middleware: v2.22.3 → [v2.24.3](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.22.3...v2.24.3) +- webpack-merge: v4.1.4 → [v4.2.1](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#421--2019-01-04) - whatwg-fetch: v2.0.4 → [v3.0.0](https://github.com/github/fetch/releases/tag/v3.0.0) # 0.23.0 / 2018-08-03 diff --git a/package.json b/package.json index e5e78507..47fdb9d9 100644 --- a/package.json +++ b/package.json @@ -26,29 +26,29 @@ "polyfills.js" ], "engines": { - "node": ">=6.11.5" + "node": ">=8.9.0" }, "dependencies": { - "chalk": "2.4.1", + "chalk": "2.4.2", "copy-template-dir": "1.4.0", "cross-spawn": "6.0.5", - "debug": "4.0.1", - "detect-port": "1.2.3", + "debug": "4.1.1", + "detect-port": "1.3.0", "figures": "2.0.0", - "filesize": "3.6.1", - "fs-extra": "7.0.0", + "filesize": "4.1.2", + "fs-extra": "7.0.1", "gzip-size": "5.0.0", - "inquirer": "6.2.0", + "inquirer": "6.2.2", "minimist": "1.2.0", - "ora": "3.0.0", - "resolve": "1.8.1", + "ora": "3.2.0", + "resolve": "1.10.0", "run-series": "1.1.8", - "semver": "5.5.1", - "webpack-merge": "4.1.4", + "semver": "5.6.0", + "webpack-merge": "4.2.1", "babel-cli": "6.26.0", "babel-core": "6.26.3", - "babel-plugin-add-module-exports": "0.2.1", + "babel-plugin-add-module-exports": "1.0.0", "babel-plugin-inferno": "5.1.0", "babel-plugin-istanbul": "4.1.6", "babel-plugin-lodash": "3.2.11", @@ -74,7 +74,7 @@ "react-transform-hmr": "1.0.4", "redbox-noreact": "1.1.0", - "karma": "3.0.0", + "karma": "4.0.1", "karma-chrome-launcher": "2.2.0", "karma-coverage": "1.1.2", "karma-mocha": "1.3.0", @@ -84,32 +84,32 @@ "karma-webpack": "3.0.5", "phantomjs-prebuilt": "2.1.16", - "mocha": "5.2.0", + "mocha": "6.0.2", "expect": "1.20.2", "object-assign": "4.1.1", "promise": "8.0.2", "whatwg-fetch": "3.0.0", - "webpack": "4.20.2", - "autoprefixer": "9.1.5", + "webpack": "4.29.6", + "autoprefixer": "9.4.10", "babel-loader": "7.1.5", - "case-sensitive-paths-webpack-plugin": "2.1.2", - "copy-webpack-plugin": "4.5.2", - "css-loader": "1.0.0", + "case-sensitive-paths-webpack-plugin": "2.2.0", + "copy-webpack-plugin": "5.0.0", + "css-loader": "2.1.1", "eventsource-polyfill": "0.9.6", - "file-loader": "2.0.0", + "file-loader": "3.0.1", "html-webpack-plugin": "3.2.0", - "mini-css-extract-plugin": "0.4.3", + "mini-css-extract-plugin": "0.5.0", "@insin/npm-install-webpack-plugin": "5.0.0", "opn": "5.4.0", "postcss-loader": "3.0.0", - "style-loader": "0.23.0", - "url-loader": "1.1.1", - "terser-webpack-plugin": "1.1.0", - "webpack-dev-middleware": "3.4.0", - "webpack-dev-server": "3.1.9", - "webpack-hot-middleware": "2.24.2" + "style-loader": "0.23.1", + "url-loader": "1.1.2", + "terser-webpack-plugin": "1.2.3", + "webpack-dev-middleware": "3.6.1", + "webpack-dev-server": "3.2.1", + "webpack-hot-middleware": "2.24.3" }, "devDependencies": { "babel-preset-flow": "6.23.0", @@ -119,10 +119,10 @@ "eventsource": "1.0.7", "flow-bin": "0.82.0", "glob": "7.1.3", - "nyc": "12.0.2", - "rimraf": "2.6.2", - "temp": "0.8.3", - "tree-kill": "1.2.0" + "nyc": "13.3.0", + "rimraf": "2.6.3", + "temp": "0.9.0", + "tree-kill": "1.2.1" }, "repository": { "type": "git", diff --git a/tests/commands/projects-test.js b/tests/commands/projects-test.js index 9c1e39d5..a2fb0a7c 100644 --- a/tests/commands/projects-test.js +++ b/tests/commands/projects-test.js @@ -215,7 +215,7 @@ describe('sample projects', function() { expect(es5).toInclude('CherryPicker.propTypes = process.env.NODE_ENV !== "production" ? {') }) it('ES5 build includes a CommonJS interop export', () => { - expect(es5).toInclude("module.exports = exports['default']") + expect(es5).toInclude('module.exports = exports.default') }) it('ES5 build ignores co-located test files and directories', () => { expect(glob.sync('*', {cwd: path.resolve('lib')})).toEqual([ @@ -272,12 +272,12 @@ describe('sample projects', function() { it('creates split bundles, vendor bundles, copies public subdirs and includes font resources', () => { let files = stripHashes((glob.sync('**/*', {cwd: path.resolve('dist')}))).sort() expect(files).toEqual([ - '1.js', - '1.js.map', - '2.css', - '2.css.map', - '2.js', - '2.js.map', + '3.css', + '3.css.map', + '3.js', + '3.js.map', + '4.js', + '4.js.map', 'app.css', 'app.css.map', 'app.js', From 3dbc36cca68464874e8e6f29c0850c9eead48c96 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Mon, 11 Mar 2019 14:29:12 +1000 Subject: [PATCH 19/66] Don't ignore devServer.host config when building the dev server URL Fixes #524 --- src/webpackServer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webpackServer.js b/src/webpackServer.js index 6d38d16b..4a4c2fdf 100644 --- a/src/webpackServer.js +++ b/src/webpackServer.js @@ -83,7 +83,7 @@ export default function webpackServer(args, buildConfig, cb) { // Open a browser with --open (default browser) or --open="browser name" if (args.open) serverConfig.open = args.open - let url = `http${serverConfig.https ? 's' : ''}://${args.host || 'localhost'}:${port}/` + let url = `http${serverConfig.https ? 's' : ''}://${serverConfig.host || 'localhost'}:${port}/` if (!('status' in buildConfig.plugins)) { buildConfig.plugins.status = { From 92a04c8b4b0329c7b2520092ba3d4e0fb6a8719d Mon Sep 17 00:00:00 2001 From: Adam Weeks Date: Tue, 9 Apr 2019 11:20:14 -0400 Subject: [PATCH 20/66] docs(FAQ): fix links The links for debugging with vs code and copy files were incorrect. --- docs/FAQ.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/FAQ.md b/docs/FAQ.md index b25a4181..da1aab43 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -4,9 +4,9 @@ - [How can I view the configuration nwb generates?](#how-can-i-view-the-configuration-nwb-generates) - [How do I enable CSS Modules?](#how-do-i-enable-css-modules) - [What can I configure to reduce bundle size?](#what-can-i-configure-to-reduce-bundle-size) -- [How can I copy non-JavaScript files when building a React component/library?](#how-can-i-copy-non-javascript-files-when-building-a-react-component-library) +- [How can I copy non-JavaScript files when building a React component/library?](#how-can-i-copy-non-javascript-files-when-building-a-react-componentlibrary) - [How can I use React Hot Loader instead of React Transform?](#how-can-i-use-react-hot-loader-instead-of-react-transform) -- [How can I debug using VS Code when running an app with nwb?](#how-can-i-debug-using-vs-code-when-running-an-app-with-nwb) +- [How can I debug using VS Code when using nwb?](#how-can-i-debug-using-vs-code-when-using-nwb) --- From ee6063d749a22158ab375419c65052560cc523cf Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Fri, 6 Mar 2020 11:31:03 +1000 Subject: [PATCH 21/66] Update dependencies --- CHANGES.md | 64 ++++++++++++++++++--------------- docs/Configuration.md | 4 +-- package.json | 74 +++++++++++++++++++------------------- src/appCommands.js | 4 +-- src/config/webpack.js | 2 +- src/createWebpackConfig.js | 17 ++++----- src/devServer.js | 6 ++-- tests/config-test.js | 2 +- 8 files changed, 86 insertions(+), 87 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 815b977a..2544b5e1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,49 +5,55 @@ - Node.js 6 is no longer supported; Node.js 8.9.0 is now the minimum required version, as per nwb's dependencies. - Dependencies with (documented) breaking changes: - [copy-webpack-plugin@5.0.0](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#breaking-changes) - - [css-loader@2.0.0](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#breaking-changes) - - [file-loader@2.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#breaking-changes-1) - - [file-loader@3.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#breaking-changes) + - [css-loader@3.0.0](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#breaking-changes) + - [file-loader@4.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#400-2019-06-05) - [karma@4.0.0](https://github.com/karma-runner/karma/releases/tag/v4.0.0) - [mocha@6.0.0](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#boom-breaking-changes) ## Changes - Replaced use of `UglifyJsPlugin` with `TerserWebpackPlugin`. - - Deprecated `webpack.uglify` config, which has been renamed to [`webpack.terser`](https://github.com/insin/nwb/blob/master/docs/Configuration.md#uglify-object--false). + - Deprecated `webpack.uglify` config, which has been renamed to [`webpack.terser`](https://github.com/insin/nwb/blob/master/docs/Configuration.md#terser-object--false). +- Autoprefixer renamed its `browsers` option to `overrideBrowserslist`, so you will get deprecation warnings if you were using `{browsers: ...}` in [`webpack.autoprefixer` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#autoprefixer-string--object). ## Dependencies -- autoprefixer: v9.0.2 → [v9.4.10](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#9410) +- autoprefixer: v9.0.2 → [v9.7.4](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#974) - babel-plugin-add-module-exports: v0.2.1 → [v1.0.0](https://github.com/59naga/babel-plugin-add-module-exports/releases) - babel-plugin-inferno: v5.0.1 → [v5.1.0](https://github.com/infernojs/babel-plugin-inferno/releases) -- case-sensitive-paths-webpack-plugin: v2.1.2 → [v2.2.0](https://github.com/Urthen/case-sensitive-paths-webpack-plugin/blob/master/CHANGELOG.md#v220) -- chalk: v2.4.1 → [v2.4.2](https://github.com/chalk/chalk/compare/v2.4.1...v2.4.2) -- copy-webpack-plugin: v4.5.2 → [v5.0.0](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#500-2019-02-20) -- css-loader: v1.0.0 → [v2.1.1](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#211-2019-03-07) +- case-sensitive-paths-webpack-plugin: v2.1.2 → [v2.3.0](https://github.com/Urthen/case-sensitive-paths-webpack-plugin/blob/master/CHANGELOG.md#v230) +- chalk: v2.4.1 → [v3.0.0](https://github.com/chalk/chalk/releases/tag/v3.0.0) +- copy-webpack-plugin: v4.5.2 → [v5.1.1]https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#511-2019-12-12) +- cross-spawn: v6.0.5 → [v7.0.1](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md#701-2019-10-07) +- css-loader: v1.0.0 → [v3.4.2](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#342-2020-01-10) - detect-port: v1.2.3 → [v1.3.0](https://github.com/node-modules/detect-port/releases) -- filesize: v3.6.1 → [v4.1.2](https://github.com/avoidwork/filesize.js/compare/3.6.1...4.1.2) -- file-loader: v1.1.11 → [v3.0.1](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#301-2018-12-20) -- fs-extra: v7.0.0 → [v7.0.1](https://github.com/jprichardson/node-fs-extra/blob/master/CHANGELOG.md#701--2018-11-07) -- inquirer: v6.0.0 → [v6.2.2](https://github.com/SBoudrias/Inquirer.js/releases) -- karma: v2.0.0 → [v4.0.1](https://github.com/karma-runner/karma/releases) -- karma-webpack: v3.0.0 → [v3.0.5](https://github.com/webpack-contrib/karma-webpack/releases) -- mini-css-extract-plugin v0.4.1 → [v0.5.0](https://github.com/webpack-contrib/mini-css-extract-plugin/releases) -- mocha: v5.2.0 → [v6.0.2](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#602--2019-02-25) -- opn: v5.3.0 → [v5.4.0](https://github.com/sindresorhus/opn/compare/v5.3.0...v5.4.0) -- ora: v3.0.0 → [v3.2.0](https://github.com/sindresorhus/ora/compare/v3.0.0...v3.2.0) +- figures: v2.0.0 → v3.2.0 +- filesize: v3.6.1 → [v6.1.0](https://github.com/avoidwork/filesize.js/blob/master/CHANGELOG.md#610) +- file-loader: v1.1.11 → [v4.3.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#430-2019-11-21) +- fs-extra: v7.0.0 → [v8.1.0](https://github.com/jprichardson/node-fs-extra/blob/master/CHANGELOG.md#810--2019-06-28) +- glob: v7.1.3 → [v7.1.6](https://github.com/isaacs/node-glob/compare/v7.1.3...v7.1.6) +- gzip-size: v5.0.0 → [v5.1.1](https://github.com/sindresorhus/gzip-size/compare/v5.0.0...v5.1.1) +- inquirer: v6.0.0 → [v7.0.6](https://github.com/SBoudrias/Inquirer.js/releases) +- karma: v2.0.0 → [v4.4.1](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md#441-2019-10-18) +- karma-chrome-launcher: v2.2.0 → [v3.1.0](https://github.com/karma-runner/karma-chrome-launcher/blob/master/CHANGELOG.md#310-2019-08-13) +- karma-coverage: v1.1.2 → [v2.0.1](https://github.com/karma-runner/karma-coverage/blob/master/CHANGELOG.md#201-2019-08-20) +- karma-webpack: v3.0.0 → [v4.0.2](https://github.com/webpack-contrib/karma-webpack/blob/master/CHANGELOG.md#402-2019-06-08) +- mini-css-extract-plugin v0.4.1 → [v0.9.0](https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/CHANGELOG.md#090-2019-12-20) +- mocha: v5.2.0 → [v7.1.0](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#710--2020-02-26) +- opn: v5.3.0 → [open v7.0.2](https://github.com/sindresorhus/open/releases) +- ora: v3.0.0 → [v4.0.3](https://github.com/sindresorhus/ora/compare/v3.0.0...v4.0.3) - postcss-loader: v2.1.6 → [v3.0.0](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#300-2018-08-08) - dropped Node.js 4 support -- promise: v8.0.1 → v8.0.2 -- resolve: v1.8.1 → [v1.10.0](https://github.com/browserify/resolve/compare/v1.8.1...v1.10.0) -- semver: v5.5.1 → [v5.6.0](https://github.com/npm/node-semver/compare/v5.5.1...v5.6.0) -- style-loader: v0.21.0 → [v0.23.1](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0231-2018-10-08) +- promise: v8.0.1 → v8.1.0 +- resolve: v1.8.1 → [v1.15.1](https://github.com/browserify/resolve/compare/v1.8.1...v1.15.1) +- semver: v5.5.1 → [v7.1.3](https://github.com/npm/node-semver/compare/v5.5.1...v7.1.3) +- style-loader: v0.21.0 → [v1.1.3](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0231-2018-10-08) - uglifyjs-webpack-plugin v1.2.7 → [terser-webpack-plugin v1.2.3](https://github.com/webpack-contrib/terser-webpack-plugin#readme) -- url-loader: v1.0.1 → [v1.1.2](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md#112-2018-10-10) -- webpack: v4.16.4 → [v4.29.6](https://github.com/webpack/webpack/releases) -- webpack-dev-middleware: v3.1.3 → [v3.6.1](https://github.com/webpack/webpack-dev-middleware/releases) -- webpack-dev-server: v3.1.5 → [v3.1.9](https://github.com/webpack/webpack-dev-server/releases) -- webpack-hot-middleware: v2.22.3 → [v2.24.3](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.22.3...v2.24.3) -- webpack-merge: v4.1.4 → [v4.2.1](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#421--2019-01-04) +- url-loader: v1.0.1 → [v2.3.0](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md#230-2019-11-21) +- webpack: v4.16.4 → [v4.42.0](https://github.com/webpack/webpack/releases) +- webpack-dev-middleware: v3.1.3 → [v3.7.2](https://github.com/webpack/webpack-dev-middleware/blob/master/CHANGELOG.md#372-2019-09-28) +- webpack-dev-server: v3.1.5 → [v3.10.3](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md#3103-2020-02-05) +- webpack-hot-middleware: v2.22.3 → [v2.25.0](https://github.com/webpack-contrib/webpack-hot-middleware/compare/v2.22.3...v2.25.0) +- webpack-merge: v4.1.4 → [v4.2.2](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#422--2019-08-27) - whatwg-fetch: v2.0.4 → [v3.0.0](https://github.com/github/fetch/releases/tag/v3.0.0) # 0.23.0 / 2018-08-03 diff --git a/docs/Configuration.md b/docs/Configuration.md index 9efb40b0..8c50d46c 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -739,9 +739,7 @@ Any additional options provided will be merged into nwb's defaults, which are: ```js { - cache: true, - parallel: true, - sourceMap: true + extractComments: false } ``` diff --git a/package.json b/package.json index 47fdb9d9..1c19989f 100644 --- a/package.json +++ b/package.json @@ -29,22 +29,22 @@ "node": ">=8.9.0" }, "dependencies": { - "chalk": "2.4.2", + "chalk": "3.0.0", "copy-template-dir": "1.4.0", - "cross-spawn": "6.0.5", + "cross-spawn": "7.0.1", "debug": "4.1.1", "detect-port": "1.3.0", - "figures": "2.0.0", - "filesize": "4.1.2", - "fs-extra": "7.0.1", - "gzip-size": "5.0.0", - "inquirer": "6.2.2", + "figures": "3.2.0", + "filesize": "6.1.0", + "fs-extra": "8.1.0", + "gzip-size": "5.1.1", + "inquirer": "7.0.6", "minimist": "1.2.0", - "ora": "3.2.0", - "resolve": "1.10.0", + "ora": "4.0.3", + "resolve": "1.15.1", "run-series": "1.1.8", - "semver": "5.6.0", - "webpack-merge": "4.2.1", + "semver": "7.1.3", + "webpack-merge": "4.2.2", "babel-cli": "6.26.0", "babel-core": "6.26.3", @@ -74,55 +74,55 @@ "react-transform-hmr": "1.0.4", "redbox-noreact": "1.1.0", - "karma": "4.0.1", - "karma-chrome-launcher": "2.2.0", - "karma-coverage": "1.1.2", + "karma": "4.4.1", + "karma-chrome-launcher": "3.1.0", + "karma-coverage": "2.0.1", "karma-mocha": "1.3.0", "karma-mocha-reporter": "2.2.5", "karma-phantomjs-launcher": "1.0.4", "karma-sourcemap-loader": "0.3.7", - "karma-webpack": "3.0.5", + "karma-webpack": "4.0.2", "phantomjs-prebuilt": "2.1.16", - "mocha": "6.0.2", + "mocha": "7.1.0", "expect": "1.20.2", "object-assign": "4.1.1", - "promise": "8.0.2", + "promise": "8.1.0", "whatwg-fetch": "3.0.0", - "webpack": "4.29.6", - "autoprefixer": "9.4.10", + "webpack": "4.42.0", + "autoprefixer": "9.7.4", "babel-loader": "7.1.5", - "case-sensitive-paths-webpack-plugin": "2.2.0", - "copy-webpack-plugin": "5.0.0", - "css-loader": "2.1.1", + "case-sensitive-paths-webpack-plugin": "2.3.0", + "copy-webpack-plugin": "5.1.1", + "css-loader": "3.4.2", "eventsource-polyfill": "0.9.6", - "file-loader": "3.0.1", + "file-loader": "4.3.0", "html-webpack-plugin": "3.2.0", - "mini-css-extract-plugin": "0.5.0", + "mini-css-extract-plugin": "0.9.0", "@insin/npm-install-webpack-plugin": "5.0.0", - "opn": "5.4.0", + "open": "7.0.2", "postcss-loader": "3.0.0", - "style-loader": "0.23.1", - "url-loader": "1.1.2", - "terser-webpack-plugin": "1.2.3", - "webpack-dev-middleware": "3.6.1", - "webpack-dev-server": "3.2.1", - "webpack-hot-middleware": "2.24.3" + "style-loader": "1.1.3", + "url-loader": "2.3.0", + "terser-webpack-plugin": "2.3.5", + "webpack-dev-middleware": "3.7.2", + "webpack-dev-server": "3.10.3", + "webpack-hot-middleware": "2.25.0" }, "devDependencies": { "babel-preset-flow": "6.23.0", "babel-register": "6.26.0", - "cross-env": "5.2.0", + "cross-env": "7.0.2", "eslint-config-jonnybuchanan": "6.0.0", "eventsource": "1.0.7", "flow-bin": "0.82.0", - "glob": "7.1.3", - "nyc": "13.3.0", - "rimraf": "2.6.3", - "temp": "0.9.0", - "tree-kill": "1.2.1" + "glob": "7.1.6", + "nyc": "15.0.0", + "rimraf": "3.0.2", + "temp": "0.9.1", + "tree-kill": "1.2.2" }, "repository": { "type": "git", diff --git a/src/appCommands.js b/src/appCommands.js index 559817dc..71c2460f 100644 --- a/src/appCommands.js +++ b/src/appCommands.js @@ -75,7 +75,7 @@ export function createBuildConfig(args: Object, extra: Object = {}) { } if (directoryExists('public')) { - config.plugins.copy = [{from: path.resolve('public'), to: dist, ignore: '.gitkeep'}] + config.plugins.copy = [{from: path.resolve('public'), to: dist, ignore: ['.gitkeep']}] } if (args.polyfill === false || args.polyfills === false) { @@ -106,7 +106,7 @@ export function createServeConfig(args: Object, ...extra: Object[]) { } if (directoryExists('public')) { - config.plugins.copy = [{from: path.resolve('public'), to: dist, ignore: '.gitkeep'}] + config.plugins.copy = [{from: path.resolve('public'), to: dist, ignore: ['.gitkeep']}] } return merge(config, ...extra) diff --git a/src/config/webpack.js b/src/config/webpack.js index 0f11c5ef..98ee9f8f 100644 --- a/src/config/webpack.js +++ b/src/config/webpack.js @@ -63,7 +63,7 @@ export function processWebpackConfig({pluginConfig, report, userConfig}) { if ('autoprefixer' in userConfig.webpack) { // Convenience: allow Autoprefixer browsers config to be configured as a String if (typeOf(autoprefixer) === 'string') { - userConfig.webpack.autoprefixer = {browsers: autoprefixer} + userConfig.webpack.autoprefixer = {overrideBrowserslist: autoprefixer} } else if (typeOf(autoprefixer) !== 'object') { report.error( diff --git a/src/createWebpackConfig.js b/src/createWebpackConfig.js index 8a7d676c..46d2cc26 100644 --- a/src/createWebpackConfig.js +++ b/src/createWebpackConfig.js @@ -39,9 +39,7 @@ type RuleConfigFactory = (?string, RuleConfig) => ?RuleConfig; type ServerConfig = boolean | Object; const DEFAULT_TERSER_CONFIG = { - cache: true, - parallel: true, - sourceMap: true, + extractComments: false, } function createTerserConfig(userWebpackConfig) { @@ -198,10 +196,6 @@ export function createStyleLoaders( let name = loaderConfigName(prefix) let styleLoader = createLoader(name('style'), { loader: require.resolve('style-loader'), - options: { - // Only enable style-loader HMR when we're serving a development build - hmr: Boolean(server), - } }) let loaders = [ createLoader(name('css'), { @@ -561,9 +555,10 @@ export function createPlugins( // Copy static resources if (buildConfig.copy || userConfig.copy) { - plugins.push(new CopyPlugin( - ...getCopyPluginArgs(buildConfig.copy, userConfig.copy) - )) + const [patterns, options] = getCopyPluginArgs(buildConfig.copy, userConfig.copy) + if (patterns.length > 0) { + plugins.push(new CopyPlugin(patterns, options)) + } } // Automatically install missing npm dependencies and add them to package.json @@ -593,7 +588,7 @@ export function createPlugins( function createDefaultPostCSSPlugins(userWebpackConfig) { return [ autoprefixer({ - browsers: [ + overrideBrowserslist: [ '>1%', 'last 4 versions', 'Firefox ESR', diff --git a/src/devServer.js b/src/devServer.js index af1b0785..0ce39fb7 100644 --- a/src/devServer.js +++ b/src/devServer.js @@ -1,4 +1,4 @@ -import opn from 'opn' +import opn from 'open' import webpack from 'webpack' import WebpackDevServer from 'webpack-dev-server' import merge from 'webpack-merge' @@ -38,9 +38,9 @@ export default function devServer(webpackConfig, serverConfig, url, cb) { if (err) return cb(err) if (open) { // --open - if (typeOf(open) === 'boolean') opn(url) + if (typeOf(open) === 'boolean') opn(url, {url: true}) // --open=firefox - else opn(url, {app: open}) + else opn(url, {app: open, url: true}) } }) } diff --git a/tests/config-test.js b/tests/config-test.js index 0c3668fc..73cd630a 100644 --- a/tests/config-test.js +++ b/tests/config-test.js @@ -201,7 +201,7 @@ describe('processUserConfig()', () => { }) it('allows webpack.autoprefixer to be a browser string', () => { let config = process({webpack: {autoprefixer: 'test'}}) - expect(config.webpack.autoprefixer).toEqual({browsers: 'test'}) + expect(config.webpack.autoprefixer).toEqual({overrideBrowserslist: 'test'}) }) it('allows webpack.copy to be an array', () => { let config = process({webpack: {copy: ['test']}}) From 44530220491c4ba3483d0f2b4abca8db3e6286cd Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Sat, 13 Jan 2018 02:43:10 +1000 Subject: [PATCH 22/66] Update to Babel 7 - Breaking: use transform-runtime's defaults instead of providing our own - babel.runtime config now only takes an Object or false - Since `helpers` is enabled by default, it's now disabled by module build config to avoid needing a dependency/peerDependency on @babel/runtime by default - Breaking: Remove support for *-test.js files, as @babel-core doesn't support pattern matching them to ignore them when co-located in src/ - use *.test.js instead - Switch to scoped @babel/* packages - @babel/preset-react now has a `development` option which handles using jsx-self/jsx-source - Use new `useESModules` option for @babel/plugin-transform-runtime for smaller webpack builds - @babel/plugin-transform-runtime's `moduleName` option was removed - replace it with the new `absoluteRuntime` option - babel-preset-proposals replaces stage presets, which have been removed - Add babel.proposals config - Deprecate babel.stage config React - Switch from babel-plugin-react-transform to react-refresh via react-refresh-webpack-plugin for React HMR Internal - Dropped constructor hack for UserError, as Babel 7's wrapper should handle instanceof - Preset modules must now export a function - UserConfigReport errors no longer need to provide a value - UserConfigReport errors can have multiple messages - Use double quotes in test assertions against generated code --- .github/CONTRIBUTING.md | 2 +- .travis.yml | 1 + CHANGES.md | 24 ++- docs/Commands.md | 2 +- docs/Configuration.md | 111 +++++++---- docs/FAQ.md | 37 ---- docs/Features.md | 14 +- docs/Middleware.md | 2 +- docs/Testing.md | 3 +- docs/guides/QuickDevelopment.md | 20 +- docs/guides/ReactApps.md | 12 +- docs/guides/ReactComponents.md | 10 +- flow-typed/libdefs.js | 1 + package.json | 76 ++++--- src/cli.js | 4 +- src/commands/build-demo.js | 3 +- src/commands/build-react-component.js | 6 +- src/commands/build-web-module.js | 4 +- src/commands/init.js | 2 +- src/commands/new.js | 2 +- src/commands/react.js | 2 +- src/commands/serve-react-demo.js | 10 +- src/commands/test-react-component.js | 6 +- src/commands/test-web-module.js | 6 +- src/config/UserConfigReport.js | 10 +- src/config/babel.js | 101 ++++++++-- src/config/webpack.js | 6 +- src/createBabelConfig.js | 85 ++++---- src/createKarmaConfig.js | 4 +- src/createProject.js | 4 +- src/createWebpackConfig.js | 8 + src/errors.js | 12 +- src/expressMiddleware.js | 2 +- src/inferno/inferno-preset.js | 12 +- src/moduleBuild.js | 40 ++-- src/preact/preact-preset.js | 10 +- src/quickCommands.js | 8 +- src/react/index.js | 16 +- src/react/react-dev-preset.js | 6 - src/react/react-hmre-preset.js | 18 -- src/utils.js | 4 + .../tests/{App-test.js => App.test.js} | 0 .../tests/{App-test.js => App.test.js} | 0 .../tests/{App-test.js => App.test.js} | 0 .../tests/{index-test.js => index.test.js} | 0 .../tests/{index-test.js => index.test.js} | 0 .../tests/{index-test.js => index.test.js} | 0 tests/commands/new-init-test.js | 8 +- tests/commands/projects-test.js | 12 +- tests/commands/test-test.js | 8 +- tests/config-test.js | 9 +- tests/createBabelConfig-test.js | 187 ++++++++++-------- tests/createKarmaConfig-test.js | 4 +- .../tests/{index-test.js => index.test.js} | 0 .../projects/cherry-pick/src/index-test.js | 2 - tests/fixtures/worst-config.js | 2 + tests/utils-test.js | 8 +- 57 files changed, 520 insertions(+), 426 deletions(-) delete mode 100644 src/react/react-dev-preset.js delete mode 100644 src/react/react-hmre-preset.js rename templates/inferno-app/tests/{App-test.js => App.test.js} (100%) rename templates/preact-app/tests/{App-test.js => App.test.js} (100%) rename templates/react-app/tests/{App-test.js => App.test.js} (100%) rename templates/react-component/tests/{index-test.js => index.test.js} (100%) rename templates/web-app/tests/{index-test.js => index.test.js} (100%) rename templates/web-module/tests/{index-test.js => index.test.js} (100%) rename tests/fixtures/projects/async-await/tests/{index-test.js => index.test.js} (100%) delete mode 100644 tests/fixtures/projects/cherry-pick/src/index-test.js diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 5abe05b2..73621af1 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -24,7 +24,7 @@ See the [`eslint-config-jonnybuchanan` README](https://github.com/insin/eslint-c This takes a few minutes to run and requires network access to install dependencies for tests which create projects. - The last set of tests check that nwb exits correctly when tests will fail, so you'll see *expected* error output at the end of the run. On a successful test run, the last line will be something along the lines of `147 passing (3m)`. + The last set of tests check that nwb exits correctly when tests fail, so you'll see *expected* error output at the end of the run. On a successful test run, the last line will be something along the lines of `147 passing (3m)`. - `npm run test:coverage` is the same as the above, plus creation of a code coverage report. diff --git a/.travis.yml b/.travis.yml index b5c01869..12e6906e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ language: node_js node_js: - 8 - 10 + - 12 cache: directories: diff --git a/CHANGES.md b/CHANGES.md index 2544b5e1..0c676006 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,17 +9,37 @@ - [file-loader@4.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#400-2019-06-05) - [karma@4.0.0](https://github.com/karma-runner/karma/releases/tag/v4.0.0) - [mocha@6.0.0](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#boom-breaking-changes) +- Updated to [Babel 7](https://babeljs.io/blog/2018/08/27/7.0.0) + - [`babel.runtime` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#runtime-object--false) no longer accepts a `String` to enable an additional, named feature. -## Changes + Pass an `Object` with plugin options instead. + - Support for tests in `*-test.js` files has been removed, as `@babel-core` no longer supports pattern matching them to ignore them when co-located in `src/`. + + Rename these to `*.test.js` instead. +- Dropped support for old `--no-hmre` alias to disable Hot Module Replacement, just use `--no-hmr` instead. + +## Added + +- Added [`babel.proposals` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#proposals-object--false) to configure use of Babel's proposal plugins. + +## Changed + +- [React Refresh Webpack Plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin) is now used to enable [Fast Refresh](https://github.com/facebook/react/issues/16604#issuecomment-528663101) for React apps, as babel-plugin-react-transform is deprecated and doesn't support Babel 7. - Replaced use of `UglifyJsPlugin` with `TerserWebpackPlugin`. - Deprecated `webpack.uglify` config, which has been renamed to [`webpack.terser`](https://github.com/insin/nwb/blob/master/docs/Configuration.md#terser-object--false). - Autoprefixer renamed its `browsers` option to `overrideBrowserslist`, so you will get deprecation warnings if you were using `{browsers: ...}` in [`webpack.autoprefixer` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#autoprefixer-string--object). +## Deprecated + +- `babel.stage` config is deprecated, as Babel's `stage-X` presets were/are being removed in Babel 7 - if you provide it, nwb will warn you and enable Babel proposal plugins equivalent to the current stage they're at. + + Use [`babel.proposals` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#proposals-object--false) instead if you want to toggle some or all additional proposal plugins on. + ## Dependencies - autoprefixer: v9.0.2 → [v9.7.4](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#974) -- babel-plugin-add-module-exports: v0.2.1 → [v1.0.0](https://github.com/59naga/babel-plugin-add-module-exports/releases) +- babel-plugin-add-module-exports: v0.2.1 → [v1.0.2](https://github.com/lijunle/babel-plugin-add-module-exports/releases/tag/v1.0.2) - babel-plugin-inferno: v5.0.1 → [v5.1.0](https://github.com/infernojs/babel-plugin-inferno/releases) - case-sensitive-paths-webpack-plugin: v2.1.2 → [v2.3.0](https://github.com/Urthen/case-sensitive-paths-webpack-plugin/blob/master/CHANGELOG.md#v230) - chalk: v2.4.1 → [v3.0.0](https://github.com/chalk/chalk/releases/tag/v3.0.0) diff --git a/docs/Commands.md b/docs/Commands.md index 72e80147..c1deeb0c 100644 --- a/docs/Commands.md +++ b/docs/Commands.md @@ -169,7 +169,7 @@ Passing an argument for `entry` allows you to customise the entry point for your **React app/component options:** -- `--no-hmre` - disable use of [React Transform](https://github.com/gaearon/babel-plugin-react-transform) to attempt to automatically handle Hot Module Replacement for React components and display an overlay with `render()` errors - if you want to use HMR, you will have to accept updates manually +- `--no-hmr` - disable use of [React Refresh Webpack Plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin/#react-refresh-webpack-plugin) to attempt to automatically handle Hot Module Replacement for React components - if you want to use HMR, you will have to accept updates manually **In Inferno and Preact apps:** diff --git a/docs/Configuration.md b/docs/Configuration.md index 8c50d46c..4c7e4c55 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -50,7 +50,7 @@ If a function is exported, it will be passed an object with the following proper Configuration for the `babel`, `webpack`, `devServer`, `karma` and `npm` properties documented below can also be provided via arguments using dotted paths, instead of tweaking your `nwb.config.js` file for a single run, or instead of needing to add a config file for [Quick Development commands](/docs/guides/QuickDevelopment.md#quick-development-with-nwb): ```sh -nwb build-react-app --babel.stage=2 +nwb build-react-app --babel.proposals.all ``` > **Note:** If you have a config file, these arguments will act as overrides. @@ -72,13 +72,14 @@ The configuration object can include the following properties: - [Babel Configuration](#babel-configuration) - [`babel`](#babel-object) - [`babel.cherryPick`](#cherrypick-string--arraystring) - enable cherry-picking for destructured `import` statements - - [`babel.env`](#env-object) - additional configuration for `babel-preset-env` + - [`babel.env`](#env-object) - additional configuration for `@babel/preset-env` - [`babel.loose`](#loose-boolean) - enable loose mode for Babel plugins which support it - [`babel.plugins`](#plugins-string--array) - extra Babel plugins to be used - [`babel.presets`](#presets-string--array) - extra Babel presets to be used - - [`babel.removePropTypes`](#removeproptypes-object--false) - disable or configure removal of React component `propTypes` in production builds + - [`babel.proposals`](#proposals-object--false) - configure or disable use of `babel-preset-proposals` + - [`babel.removePropTypes`](#removeproptypes-object--false) - configure or disable removal of React component `propTypes` in production builds - [`babel.reactConstantElements`](#reactconstantelements-false) - disable use of React constant element hoisting in production builds - - [`babel.runtime`](#runtime-string--boolean) - enable the `transform-runtime` plugin with different configurations + - [`babel.runtime`](#runtime-object--false) - configure or disable the Babel `transform-runtime` plugin - [`babel.stage`](#stage-number--false) - control which experimental and upcoming JavaScript features can be used - [`babel.config`](#config-function) - an escape hatch for manually editing the generated Babel config - [Webpack Configuration](#webpack-configuration) @@ -192,7 +193,7 @@ This is implemented using [babel-plugin-lodash](https://github.com/lodash/babel- ##### `env`: `Object` -Additional [options for `babel-preset-env`](https://github.com/babel/babel-preset-env#options) - nwb uses `babel-preset-env` to transpile ECMAScript features which aren't natively available in browsers yet. +Additional [options for `@babel/preset-env`](https://babeljs.io/docs/en/next/babel-preset-env#options) - nwb uses `@babel/preset-env` to transpile ECMAScript features which aren't natively available in all browsers yet. ##### `loose`: `Boolean` @@ -239,6 +240,55 @@ Additional Babel presets to use. A single additional preset which doesn't need a configuration object can be specified as a String, otherwise provide an Array. +##### `proposals`: `Object | false` + +*added in v0.24.0* + +Configures which experimental Babel plugins will be used via [`babel-preset-proposals`](https://github.com/insin/babel-preset-proposals#babel-preset-proposals). + +By default, nwb enables: +- class properties, which make ES classes more palatable, particularly for React-like components +- @decorators, as used in libraries such as MobX. +- namespace and default `export` extensions, which are useful for re-exporting modules from libraries + +nwb's [`babel.loose`](#loose-boolean) config is also passed to the preset, so proposal plugins are in loose mode by default. + +Provide an Object to configure the [preset's options](https://github.com/insin/babel-preset-proposals#options): + +```js +module.exports = { + babel: { + proposals: { + pipelineOperator: true + } + } +} +``` + +> **Note:** When running a Webpack build, `@babel/plugin-syntax-dynamic-import` will always be used independent of `babel.proposals`, to allow Babel to successfully parse dynamic `import()` statements so Webpack can handle them for code-splitting, so you probably never need to enable `dynamicImport` manually. + +If you want to turn one of the default proposal plugins offs, you can pass a `false` property: + +```js +module.exports = { + babel: { + proposals: { + decorators: false, + } + } +} +``` + +To disable use of `babel-preset-proposals`, configure `proposals = false`: + +```js +module.exports = { + babel: { + proposals: false + } +} +``` + ##### `removePropTypes`: `Object | false` Since React `propTypes` are only used in development mode, nwb removes them from React app production builds by default using the [react-remove-prop-types](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types) transform. @@ -271,64 +321,39 @@ module.exports = { Set this to `false` to disable use of the [React constant element hoisting transform](https://babeljs.io/docs/plugins/transform-react-constant-elements/) in React app production builds. -##### `runtime`: `String | Boolean` +##### `runtime`: `Object | false` -Babel's [runtime transform](https://babeljs.io/docs/plugins/transform-runtime/) does 3 things by default: +*changed in v0.24.0 - now only takes an `Object` to tweak config* -1. Imports helper modules from `babel-runtime` instead of duplicating **helpers** in every module which needs them. -2. Imports a local **polyfill** for new ES built-ins (`Promise`) and static methods (e.g. `Object.assign`) when they're used in your code. -3. Imports the **regenerator** runtime required to use `async`/`await` when needed. +Configure options for Babel's [runtime transform plugin](https://babeljs.io/docs/en/next/babel-plugin-transform-runtime.html), which by default imports helper modules from `@babel/runtime/helpers` instead of duplicating helper code at the top of every module which needs it, and imports the regenerator runtime from `@babel/runtime/regenerator` required to use `async`/`await` or generators when needed. -nwb's default config turns the regenerator runtime import on so you can use `async`/`await` and generators. +> **Note:** if you use `async`/`await` or generators in a React Component or Web Module project and are transpiling it to ES5 for publishing (which is the default), you will need to add `@babel/runtime` to your package.json `peerDependencies` to ensure it can be resolved when somebody else uses your module from npm. -To enable an additional feature, you can name it (either `'helpers'` or `'polyfill'`): +e.g. to enable importing of helper modules if you're publishing a large React Component library: ```js module.exports = { babel: { - runtime: 'helpers' + runtime: { + helpers: true + } } } ``` -To enable all features, set `runtime` to `true`. - To disable use of the runtime transform, set `runtime` to `false`. -> **Note:** if you use `async`/`await` or enable the runtime transform's other features in a React Component or Web Module project, you will need to add `babel-runtime` to your package.json `peerDependencies` to ensure it can be resolved when somebody else uses your module from npm. - -##### `stage`: `Number | false` - -> nwb implements its own equivalent of Babel 5's `stage` config for Babel 6 - -Controls which Babel preset will be used to enable use of experimental, proposed and upcoming JavaScript features in your code, grouped by the stage they're at in the TC39 process for proposing new JavaScript features: - -| Stage | TC39 Category | Features | -| ----- | ------------- | -------- | -| [0](https://babeljs.io/docs/plugins/preset-stage-0) | Strawman, just an idea |`do {...}` expressions, `::` function bind operator | -| [1](https://babeljs.io/docs/plugins/preset-stage-1) | Proposal: this is worth working on | export extensions | -| [2](https://babeljs.io/docs/plugins/preset-stage-2) | Draft: initial spec | class properties, `@decorator` syntax (using the [Babel Legacy Decorator plugin](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy)) - **enabled by default** | -| [3](https://babeljs.io/docs/plugins/preset-stage-3) | Candidate: complete spec and initial browser implementations | object rest/spread `...` syntax, `async`/`await`, `**` exponentiation operator, trailing function commas | - -e.g. if you want to use export extensions in your app, you should set `stage` to `1`: - ```js module.exports = { babel: { - stage: 1 + runtime: false } } ``` -Stage 2 is enabled by default - to disable use of a stage preset entirely, set `stage` to `false`: +##### `stage`: `Number | false` -```js -module.exports = { - babel: { - stage: false - } -} -``` +*deprecated in v0.24.0 - use [`babel.proposals` config](#proposals-object--false) instead* ##### `config`: `Function` @@ -1024,7 +1049,7 @@ If the default [`testFiles`](#testfiles-string--arraystring) config wouldn't hav ##### `testFiles`: `String | Array` -> Default: `.spec.js`, `.test.js` or `-test.js` files anywhere under `src/`, `test/` or `tests/` +> Default: `.spec.js` or `.test.js` files anywhere under `src/`, `test/` or `tests/` [Minimatch glob patterns](https://github.com/isaacs/minimatch) for test files. @@ -1163,7 +1188,7 @@ The name of the global variable the UMD build will export. A mapping from `peerDependency` module names to the global variables they're expected to be available as for use by the UMD build. -e.g. if you're creating a React component which also depends on [React Router](https://github.com/reactjs/react-router), this configuration would ensure they're not included in the UMD build: +e.g. if you're creating a React component which also depends on [React Router](https://github.com/ReactTraining/react-router), this configuration would ensure they're not included in the UMD build: ```js module.exports = { diff --git a/docs/FAQ.md b/docs/FAQ.md index b25a4181..918f1fb2 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -77,43 +77,6 @@ Try configuring [`babel.cherryPick`](/docs/Configuration.md#cherrypick-string--a Pass a [`--copy-files` flag](/docs/guides/ReactComponent.md#--copy-files) if you have other files which you want to copy to build directories, such as CSS and JSON files. -### How can I use [React Hot Loader](https://github.com/gaearon/react-hot-loader) instead of [React Transform](https://github.com/gaearon/babel-plugin-react-transform)? - -> [React Transform](https://github.com/gaearon/babel-plugin-react-transform) is deprecated in favour of [React Hot Loader](https://github.com/gaearon/react-hot-loader), but nwb is still using the former as it can be activated entirely via the configuration nwb manages, whereas React Hot Loader requires a component to be added to your app. - -- `npm install react-hot-loader` -- Disable use of React Transform by passing a [`--no-hmre` flag](https://github.com/insin/nwb/blob/master/docs/Commands.md#nwb-serve) to the `serve` command you're using. e.g. in your app's `package.json`: - - ```json - { - "scripts": { - "start": "nwb serve-react-app --no-hmre", - } - } - ``` -- Provide the Babel and Webpack config React Hot Loader requires in your `nwb.config.js`: - - ```js - module.exports = function({command}) { - let config = { - type: 'react-app' - } - // Only include react-hot-loader config when serving a development build - if (command.startsWith('serve')) { - config.babel = {plugins: 'react-hot-loader/babel'} - config.webpack = { - config(webpackConfig) { - // React Hot Loader's patch module needs to run before your app - webpackConfig.entry.unshift('react-hot-loader/patch') - return webpackConfig - } - } - } - return config - } - ``` -- Use React Hot Loader's `` component in your app's entry module (usually `src/index.js` in apps using nwb) as per its [Getting Started docs](https://github.com/gaearon/react-hot-loader#getting-started). - ### How can I debug using VS Code when using nwb? Ensure you have the [Debugger for Chrome extension](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) installed and add the following configurations to `.vscode/launch.json`: diff --git a/docs/Features.md b/docs/Features.md index acc99311..4cdbf07f 100644 --- a/docs/Features.md +++ b/docs/Features.md @@ -1,10 +1,10 @@ ## Features - **A toolkit, not a boilerplate.** -- Uses [Webpack](https://webpack.js.org/), [Babel](https://babeljs.io/) and [Karma](https://karma-runner.github.io/). +- Uses [Webpack 4](https://webpack.js.org/), [Babel 7](https://babeljs.io/) and [Karma 4](https://karma-runner.github.io/). - Provides tooling for [React](https://facebook.github.io/react/) apps and components, [Preact](https://preactjs.com/) apps, [Inferno](https://infernojs.org/) apps, and vanilla JS web apps and npm modules. -- Use the latest JavaScript features from ES2015-ES2017, and JSX. -- Use future JavaScript features like object spreading now; [TC39](https://exploringjs.com/es2016-es2017/ch_tc39-process.html) Stage 2 and above features are enabled by default. +- Use modern JavaScript features, and JSX. +- Use proposed JavaScript features now. - Default polyfills and configuration allow use of [`Promise`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise) (with [rejection tracking](https://www.2ality.com/2016/04/unhandled-rejections.html) enabled), [`fetch()`](https://developer.mozilla.org/en/docs/Web/API/Fetch_API), [`async`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function)/[`await`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await), [generators](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/function*) and [`Object.assign()`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) in any browser. - Import CSS (and font resources) and images to be managed by Webpack. - [Autoprefixed](https://github.com/postcss/autoprefixer#autoprefixer-) CSS, so you don't need to write browser prefixes; you can also configure your own [PostCSS](https://postcss.org/) plugins. @@ -14,7 +14,7 @@ - Quick development commands for React, Preact and Inferno which reduce the time from idea to running code. - Development server with Hot Module Replacement, and syntax error and React `render()` error overlays. -- User-friendly reporting of build status and errors in the CLI (based on [create-react-app](https://github.com/facebookincubator/create-react-app)'s). +- User-friendly reporting of build status and errors in the CLI. - Prompts to continue with a different port if the intended dev server port is not available. - Express middleware for serving the same development Webpack build from your own server. - **Experimental:** Automatically install dependencies from npm without restarting your development server by using an `--auto-install` flag. @@ -22,7 +22,7 @@ **Testing:** -- Run unit tests with Karma in PhantomJS, using Mocha and Expect, without any configuration. +- Run unit tests with Karma in PhantomJS, using [Mocha](https://mochajs.org/) and [Expect](https://github.com/mjackson/expect#expect1x-documentation), without any configuration. - Flexible defaults allow tests to be organised using a number of naming schemes, with tests in a separate directory, co-located with the code, or both. - Code coverage reporting. - Project skeletons ready to run tests on Travis CI and post code coverage results to Coveralls/codecov.io. @@ -33,11 +33,11 @@ - Optimised Webpack build prepares JS, CSS and images for production, with deterministic filename hashes for long-term caching, and sourcemaps for debugging. - Production optimisations for React apps: hoisting static elements and removing `propTypes` - Automatic creation of a separate vendor bundle. -- Flag to try a build which replaces React with Preact or Inferno via a compatibility layer, for a much smaller payload. +- Flags to try a build which replaces React with Preact or Inferno via a compatibility layer, for a much smaller payload. **Publishing:** -- Builds components and modules for publishing to npm with ES5 (including CommonJS exports interop), ES modules and UMD builds. +- Builds components and modules for publishing to npm with ES5 (including CommonJS export interop), ES modules and UMD builds. - Project skeletons include a package.json config `files` whitelist to avoid bloating your published package. - React component skeleton includes a demo app ready to develop and build using the same React app development setup. - React component `propTypes` are automatically wrapped with an environment check, for elimination from production builds. diff --git a/docs/Middleware.md b/docs/Middleware.md index 25dc3379..15cbc833 100644 --- a/docs/Middleware.md +++ b/docs/Middleware.md @@ -28,7 +28,7 @@ Your app's version of the Express module must be passed as the first argument. - `config` - path to a config file *[default: `'nwb.config.js'`]* - `entry` - entry point for the app *[default: `'src/index.js'`]* -- `hmre` - use [React Transform](https://github.com/gaearon/babel-plugin-react-transform#readme) to attempt to automatically handle Hot Module Replacement for React components and display an overlay with `render()` errors when serving a React app *[default: `true`]* +- `hmr` - use [React Refresh Webpack Plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin/#react-refresh-webpack-plugin) to enable Fast Refresh for React components *[default: `true`]* - `install` - automatically install missing npm dependencies *[default: `false`]* - `reload` - reload the page if Hot Module Replacement is unsuccessful *[default: `false`]* diff --git a/docs/Testing.md b/docs/Testing.md index 4c6bc732..73eeb4f8 100644 --- a/docs/Testing.md +++ b/docs/Testing.md @@ -50,7 +50,6 @@ In the project skeletons created by nwb's `new` and `init` commands, the sample However, the default configuration supports having tests in any file which ends with one of the following suffixes, anywhere underneath a `src/`, `test/` or `tests/` directory: -- `-test.js` - `.test.js` - `.spec.js` @@ -157,7 +156,7 @@ context.keys().forEach(context) A Webpack context module is also a suitable place for before/after hooks which should apply to all tests. -For example, if you want to make use of Expect's spies to fail tests by default if any unexpected error logging is performed, you could use a context module like this (based on [React Router's context module](https://github.com/reactjs/react-router/blob/master/tests.webpack.js)): +For example, if you want to make use of Expect's spies to fail tests by default if any unexpected error logging is performed, you could use a context module like this: ```js import expect from 'expect' diff --git a/docs/guides/QuickDevelopment.md b/docs/guides/QuickDevelopment.md index 54cf6bfa..ec5cf45e 100644 --- a/docs/guides/QuickDevelopment.md +++ b/docs/guides/QuickDevelopment.md @@ -171,17 +171,11 @@ Create a build of a React project which uses Inferno or Preact as the runtime vi ### Zero Configuration Setup -- Write JavaScript with ES2015-ES2017 features and JSX, transpiled down to ES5. -- Use new JavaScript features at Stage 2 and above in the TC39 process: - - [`async`/`await` syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function), for writing async code in a synchronous way. - - Class properties, for avoiding boilerplate when writing ES2015 classes. +- Write JavaScript with modern features and JSX, transpiled down to ES5. +- Use new JavaScript feature proposals in the TC39 process: + - Class properties, for avoiding boilerplate when writing classes. - Decorators. - - [Object rest/spread](https://github.com/sebmarkbage/ecmascript-rest-spread#object-restspread-properties-for-ecmascript), for shallow cloning, merging and partially destructuring objects as syntax. - -- Use experimental JavaScript feature proposals which are at Stages 0 and 1 in the TC39 process: - - [export extensions](http://babeljs.io/docs/plugins/transform-export-extensions/#example) - - [`do` expressions](http://babeljs.io/docs/plugins/transform-do-expressions/#detail) - - [`::` function binding operator](http://babeljs.io/docs/plugins/transform-function-bind/#detail) + - Export extensions. - Polyfills for `Promise`, `fetch()` and `Object.assign()`, which can be disabled with a `--no-polyfill` flag if you don’t need them or want to provide your own. - Import images and stylesheets into JavaScript like any other module, to be handled by Webpack as part of its build. @@ -354,9 +348,9 @@ When the rendering shim detects that one of these has been exported from the pro #### React Rendering Shim -`nwb react run`'s build configuration uses [react-transform-hmr](https://github.com/gaearon/react-transform-hmr), which automatically handles accepting HMR requests in modules which contain React components, patching them and re-rendering without losing state where possible. +`nwb react run`'s configuration uses [React Refresh Webpack Plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin/#react-refresh-webpack-plugin) to enable Fast Refresh for React components. -> To disable this, pass a `--no-hmre` flag. +> To disable this, pass a `--no-hmr` flag. For other HMR scenarios, such as an exported React Element, `nwb react run`'s rendering shim will re-render to the same root DOM node. @@ -364,7 +358,7 @@ For other HMR scenarios, such as an exported React Element, `nwb react run`'s re If you don't want to use a rendering shim, pass a `--force` flag the module you provide will be used as the entry point and you'll be responsible for rendering your app to the DOM. -You will also need to manually deal with HMR for Inferno and Preact if you want it, as they don't currently have equivalents of React Hot Loader, which does HMR at the component level. +You will also need to manually deal with HMR for Inferno and Preact if you want it, as they don't currently have Fast Refresh equivalents. ## Configuration diff --git a/docs/guides/ReactApps.md b/docs/guides/ReactApps.md index e5e555d7..842871fa 100644 --- a/docs/guides/ReactApps.md +++ b/docs/guides/ReactApps.md @@ -62,7 +62,7 @@ nwb-thinking-in-react/ react.svg tests/ .eslintrc - App-test.js + App.test.js ``` **dist/**: When you run a build, output will be generated in the `dist/` directory, ready for deployments. @@ -145,11 +145,9 @@ nwb generates a comprehensive default configuration for creating React apps usin Without any configuration, the main features you get are: - Write JavaScript with modern features and JSX, transpiled down to ES5. -- Use new JavaScript features which are at Stage 2 and above in the TC39 process: - - `async`/`await` syntax, for writing async code in a synchronous way. +- Use proposed JavaScript features which make writing React apps more convenient: - Class properties, for avoiding boilerplate when writing classes. - - Decorators. - - Object rest/spread, for shallow cloning, merging and partially destructuring objects as syntax. + - Decorators, for libraries which are intended to be used with them. - Polyfills for `Promise`, `fetch` and `Object.assign`. - Import stylesheets (and font resources), images and JSON into JavaScript, to be handled by Webpack. - Autoprefixed CSS, so you don't need to write browser prefixes. @@ -168,7 +166,7 @@ We'll start by splitting each of the main components from [the final Thinking in ### Palatable Class Components -Written as a vanilla ES classes, React components need to call `super()` setting anything on `this`, and need to [manually bind event handlers in the constructor](https://reactjs.org/docs/react-component.html#constructor): +Written as a vanilla ES classes, React components need to call `super()` before setting anything on `this`, and need to [manually bind event handlers in the constructor](https://reactjs.org/docs/react-component.html#constructor): ```js class FilterableProductTable extends Component { @@ -191,7 +189,7 @@ class FilterableProductTable extends Component { } ``` -Using experimental class property syntax avoids this constructor boilerplate - `=` assignment statements in the class body are actually *moved into a generated constructor*, so the event handler arrow function inherits the constructor's `this`: +Using proposed class property syntax avoids this constructor boilerplate - `=` assignment statements in the class body are actually *moved into a generated constructor*, so the event handler arrow function inherits the constructor's `this`: ```js class FilterableProductTable extends Component { diff --git a/docs/guides/ReactComponents.md b/docs/guides/ReactComponents.md index 30b97fe0..9faa88aa 100644 --- a/docs/guides/ReactComponents.md +++ b/docs/guides/ReactComponents.md @@ -183,9 +183,9 @@ If you're into README Driven Development, it also provides a place to play with Let's start by imagining how we'll use our `LoadingButton` component in the demo app: -> **Note:** This Demo component is implemented as a class extending React's `Component` class, but also using some [experimental language features](http://babeljs.io/docs/plugins/transform-class-properties/) which are part of Babel's [stage 2 preset](http://babeljs.io/docs/plugins/preset-stage-2/), which is enabled by default when using nwb. +> **Note:** This Demo component is implemented as a class extending React's `Component` class, but also uses a [proposed language feature - class properties](/docs/Configuration.md#proposals-object--false), which is enabled by default when using nwb. > -> Don't sweat the details of these if you're not familiar with them; the most important thing for this guide is the `render()` method. +> Don't sweat the details of if you're not familiar with this; the most important thing for this guide is the `render()` method. ```js import React, {Component} from 'react' @@ -356,13 +356,13 @@ npm publish ## Libraries -We've demonstrated using nwb to develop and publish a single reusable React component, but the same tooling also applies to developing component libraries (such as [React Bootstrap](http://react-bootstrap.github.io/)) and other React libraries (such as [React Router](https://github.com/reactjs/react-router)). +We've demonstrated using nwb to develop and publish a single reusable React component, but the same tooling also applies to developing component libraries (such as [React Bootstrap](http://react-bootstrap.github.io/)) and other React libraries (such as [React Router](https://github.com/ReactTraining/react-router)). The main difference with libraries is that the entry point (`src/index.js` by default when using nwb) usually imports and re-exports everything the library provides, for users performing top-level imports or using the UMD build. -To make this easier, nwb uses the Babel `stage-1` preset by default when building `react-component` projects, which allows you to use [export extensions](http://babeljs.io/docs/plugins/transform-export-extensions/) to import and re-export modules using a single `export` statement. +To make this easier, by default nwb enables Babel proposal plugins for export extensions, which allow you to use [`export default from`](https://github.com/tc39/proposal-export-default-from#readme) and `export * as ns from`(https://github.com/tc39/proposal-export-ns-from) statements to import and re-export modules. -For example, this is a snippet of how [React Bootstrap](https://github.com/react-bootstrap/react-bootstrap) re-exports its components using export extensions: +For example, this is a snippet of how [React Bootstrap](https://github.com/react-bootstrap/react-bootstrap) re-exports its components using `export default from` statements: ```js export Accordion from './Accordion' diff --git a/flow-typed/libdefs.js b/flow-typed/libdefs.js index 8ad531ae..80ed1568 100644 --- a/flow-typed/libdefs.js +++ b/flow-typed/libdefs.js @@ -1,3 +1,4 @@ +declare module '@pmmmwh/react-refresh-webpack-plugin' { declare module.exports: any; } declare module 'autoprefixer' { declare module.exports: any; } declare module 'case-sensitive-paths-webpack-plugin' { declare module.exports: any; } declare module 'chalk' { declare module.exports: any; } diff --git a/package.json b/package.json index 1c19989f..f2d71314 100644 --- a/package.json +++ b/package.json @@ -8,15 +8,15 @@ "nwb": "./lib/bin/nwb.js" }, "scripts": { - "build": "npm run flow && npm run lint && rimraf lib && babel src --out-dir lib --quiet", - "build:watch": "rimraf lib && babel src --watch --out-dir lib", + "build": "npm run flow && npm run lint && rimraf lib && babel src --out-dir lib --quiet --copy-files", + "build:watch": "rimraf lib && babel src --watch --out-dir lib --copy-files", "flow": "flow", "lint": "eslint *.js src tests", "lint:fix": "npm run lint -- --fix", "test": "npm run build && npm run test:all", "test:coverage": "npm run build && cross-env NODE_ENV=test NWB_TEST=true nyc mocha tests/*-test.js tests/commands/*-test.js", - "test:all": "cross-env NODE_ENV=test NWB_TEST=true mocha --require babel-register tests/*-test.js tests/commands/*-test.js", - "test:watch": "cross-env NODE_ENV=test NWB_TEST=true mocha --require babel-register --watch tests/*-test.js" + "test:all": "cross-env NODE_ENV=test NWB_TEST=true mocha --require @babel/register tests/*-test.js tests/commands/*-test.js", + "test:watch": "cross-env NODE_ENV=test NWB_TEST=true mocha --require @babel/register --watch tests/*-test.js" }, "files": [ "docs", @@ -46,33 +46,26 @@ "semver": "7.1.3", "webpack-merge": "4.2.2", - "babel-cli": "6.26.0", - "babel-core": "6.26.3", - "babel-plugin-add-module-exports": "1.0.0", - "babel-plugin-inferno": "5.1.0", - "babel-plugin-istanbul": "4.1.6", - "babel-plugin-lodash": "3.2.11", - "babel-plugin-react-transform": "3.0.0", - "babel-plugin-syntax-dynamic-import": "6.18.0", - "babel-plugin-syntax-jsx": "6.18.0", + "@babel/cli": "7.8.4", + "@babel/core": "7.8.7", + "@babel/plugin-syntax-dynamic-import": "7.8.3", + "@babel/plugin-syntax-jsx": "7.8.3", + "@babel/plugin-transform-react-constant-elements": "7.8.3", + "@babel/plugin-transform-react-jsx": "7.8.3", + "@babel/plugin-transform-runtime": "7.8.3", + "@babel/polyfill": "7.8.7", + "@babel/preset-env": "7.8.7", + "@babel/preset-react": "7.8.3", + "@babel/runtime": "7.8.7", + "@pmmmwh/react-refresh-webpack-plugin": "0.2.0", + "babel-plugin-add-module-exports": "1.0.2", + "babel-plugin-inferno": "6.1.0", + "babel-plugin-istanbul": "6.0.0", + "babel-plugin-lodash": "3.3.4", "babel-plugin-transform-decorators-legacy": "1.3.5", - "babel-plugin-transform-react-constant-elements": "6.23.0", - "babel-plugin-transform-react-jsx": "6.24.1", - "babel-plugin-transform-react-jsx-self": "6.22.0", - "babel-plugin-transform-react-jsx-source": "6.22.0", - "babel-plugin-transform-react-remove-prop-types": "0.4.10", - "babel-plugin-transform-runtime": "6.23.0", - "babel-polyfill": "6.26.0", - "babel-preset-env": "1.7.0", - "babel-preset-react": "6.24.1", - "babel-preset-stage-0": "6.24.1", - "babel-preset-stage-1": "6.24.1", - "babel-preset-stage-2": "6.24.1", - "babel-preset-stage-3": "6.24.1", - "babel-runtime": "6.26.0", - "react-transform-catch-errors": "1.0.2", - "react-transform-hmr": "1.0.4", - "redbox-noreact": "1.1.0", + "babel-plugin-transform-react-remove-prop-types": "0.4.24", + "babel-preset-proposals": "0.3.0", + "react-refresh": "0.8.0", "karma": "4.4.1", "karma-chrome-launcher": "3.1.0", @@ -93,7 +86,7 @@ "webpack": "4.42.0", "autoprefixer": "9.7.4", - "babel-loader": "7.1.5", + "babel-loader": "8.0.6", "case-sensitive-paths-webpack-plugin": "2.3.0", "copy-webpack-plugin": "5.1.1", "css-loader": "3.4.2", @@ -105,15 +98,15 @@ "open": "7.0.2", "postcss-loader": "3.0.0", "style-loader": "1.1.3", - "url-loader": "2.3.0", "terser-webpack-plugin": "2.3.5", + "url-loader": "2.3.0", "webpack-dev-middleware": "3.7.2", "webpack-dev-server": "3.10.3", "webpack-hot-middleware": "2.25.0" }, "devDependencies": { - "babel-preset-flow": "6.23.0", - "babel-register": "6.26.0", + "@babel/preset-flow": "7.8.3", + "@babel/register": "7.8.6", "cross-env": "7.0.2", "eslint-config-jonnybuchanan": "6.0.0", "eventsource": "1.0.7", @@ -137,14 +130,17 @@ ], "babel": { "presets": [ - "flow", - ["env", { - "loose": true, + "@babel/flow", + ["@babel/env", { "targets": { - "node": "6.11.5" + "node": "8.9.0" } }], - "stage-2" + ["babel-preset-proposals", { + "classProperties": { + "loose": true + } + }] ], "plugins": [ "add-module-exports" @@ -166,7 +162,7 @@ "text-summary" ], "require": [ - "babel-core/register" + "@babel/register" ], "sourceMap": false } diff --git a/src/cli.js b/src/cli.js index 69443a5b..32c3c711 100644 --- a/src/cli.js +++ b/src/cli.js @@ -147,13 +147,13 @@ Project type-specific commands: Serve a React app from ${opt('entry')} Options: - ${opt('--no-hmre')} disable use of React Transform for Hot Module Replacement & Errors + ${opt('--no-hmr')} disable use of Fast Refresh for Hot Module Replacement ${cmd('nwb serve-react-demo')} Serve a React demo app from demo/src/index.js. Options: - ${opt('--no-hmre')} disable use of React Transform for Hot Module Replacement & Errors + ${opt('--no-hmr')} disable use of Fast Refresh for Hot Module Replacement ${cmd('nwb serve-preact-app')} ${opt('[entry]')} Serve a Preact app from ${opt('entry')} diff --git a/src/commands/build-demo.js b/src/commands/build-demo.js index 129ff5dd..5c1970f7 100644 --- a/src/commands/build-demo.js +++ b/src/commands/build-demo.js @@ -15,8 +15,7 @@ function getCommandConfig(args) { let config = { babel: { - presets: [require.resolve('babel-preset-react')], - stage: 1, + presets: [require.resolve('@babel/preset-react')], }, devtool: 'source-map', entry: { diff --git a/src/commands/build-react-component.js b/src/commands/build-react-component.js index 5f363a60..a5f89171 100644 --- a/src/commands/build-react-component.js +++ b/src/commands/build-react-component.js @@ -11,8 +11,10 @@ import buildDemo from './build-demo' export default function buildModule(args, cb) { let config = { babel: { - presets: [require.resolve('babel-preset-react')], - stage: 1, + presets: [require.resolve('@babel/preset-react')], + runtime: { + helpers: false + } } } diff --git a/src/commands/build-web-module.js b/src/commands/build-web-module.js index ecd17056..4bf4e1fd 100644 --- a/src/commands/build-web-module.js +++ b/src/commands/build-web-module.js @@ -6,7 +6,9 @@ import moduleBuild from '../moduleBuild' export default function buildModule(args, cb) { moduleBuild(args, { babel: { - stage: 1, + runtime: { + helpers: false + } } }, cb) } diff --git a/src/commands/init.js b/src/commands/init.js index 147b3b79..e23499f8 100644 --- a/src/commands/init.js +++ b/src/commands/init.js @@ -6,7 +6,7 @@ import {UserError} from '../errors' export default function init(args, cb) { if (args._.length === 1) { - return cb(new UserError(`usage: nwb init [${[...PROJECT_TYPES].join('|')}] [name]`)) + return cb(new UserError(`usage: nwb init [${Array.from(PROJECT_TYPES).join('|')}] [name]`)) } let projectType = args._[1] diff --git a/src/commands/new.js b/src/commands/new.js index ae38bcc9..8ef6270c 100644 --- a/src/commands/new.js +++ b/src/commands/new.js @@ -7,7 +7,7 @@ import {directoryExists} from '../utils' export default function new_(args, cb) { if (args._.length === 1) { - return cb(new UserError(`usage: nwb new [${[...PROJECT_TYPES].join('|')}] `)) + return cb(new UserError(`usage: nwb new [${Array.from(PROJECT_TYPES).join('|')}] `)) } let projectType = args._[1] diff --git a/src/commands/react.js b/src/commands/react.js index eebf455d..587b7f88 100644 --- a/src/commands/react.js +++ b/src/commands/react.js @@ -55,7 +55,7 @@ Commands: ${opt('--host')} hostname to bind the dev server to ${opt('--mount-id')} id for the
the app will render into ${opt('[default: app]')} ${opt('--no-fallback')} disable serving of the index page from any path - ${opt('--no-hmre')} disable use of React Transform for Hot Module Replacement & Errors + ${opt('--no-hmr')} disable use of Fast Refresh for Hot Module Replacement ${opt('--no-polyfill')} disable inclusion of default polyfills ${opt('--port')} port to run the dev server on ${opt('[default: 3000]')} ${opt('--reload')} auto reload the page if hot reloading fails diff --git a/src/commands/serve-react-demo.js b/src/commands/serve-react-demo.js index b08d59bc..16cb15cc 100644 --- a/src/commands/serve-react-demo.js +++ b/src/commands/serve-react-demo.js @@ -13,8 +13,9 @@ export default function serveReactDemo(args, cb) { let config = { babel: { - presets: [require.resolve('babel-preset-react')], - stage: 1, + presets: [ + [require.resolve('@babel/preset-react'), {development: true}] + ], }, entry: [path.resolve('demo/src/index.js')], output: { @@ -30,8 +31,9 @@ export default function serveReactDemo(args, cb) { }, } - if (args.hmr !== false && args.hmre !== false) { - config.babel.presets.push(require.resolve('../react/react-hmre-preset')) + if (args.hmr !== false) { + config.babel.plugins = [require.resolve('react-refresh/babel')] + config.plugins = {reactRefresh: true} } if (directoryExists('demo/public')) { diff --git a/src/commands/test-react-component.js b/src/commands/test-react-component.js index 0190f814..1dd4a48d 100644 --- a/src/commands/test-react-component.js +++ b/src/commands/test-react-component.js @@ -7,9 +7,5 @@ import reactConfig from '../react' import type {ErrBack} from '../types' export default function testReactComponent(args: Object, cb: ErrBack) { - karmaServer(args, merge(reactConfig(args).getKarmaTestConfig(), { - babel: { - stage: 1 - } - }), cb) + karmaServer(args, merge(reactConfig(args).getKarmaTestConfig(), {}), cb) } diff --git a/src/commands/test-web-module.js b/src/commands/test-web-module.js index 867ce4b0..8f9355ae 100644 --- a/src/commands/test-web-module.js +++ b/src/commands/test-web-module.js @@ -4,9 +4,5 @@ import karmaServer from '../karmaServer' import type {ErrBack} from '../types' export default function testWebModule(args: Object, cb: ErrBack) { - karmaServer(args, { - babel: { - stage: 1 - } - }, cb) + karmaServer(args, {}, cb) } diff --git a/src/config/UserConfigReport.js b/src/config/UserConfigReport.js index 3cfd39b0..92bd1620 100644 --- a/src/config/UserConfigReport.js +++ b/src/config/UserConfigReport.js @@ -3,7 +3,7 @@ import util from 'util' import chalk from 'chalk' import figures from 'figures' -import {pluralise as s} from '../utils' +import {padLines, pluralise as s} from '../utils' export default class UserConfigReport { constructor({configFileExists, configPath} = {}) { @@ -19,8 +19,8 @@ export default class UserConfigReport { this.deprecations.push({path, messages}) } - error(path, value, message) { - this.errors.push({path, value, message}) + error(path, value, ...messages) { + this.errors.push({path, value, message: messages.join('\n')}) } hasErrors() { @@ -66,8 +66,8 @@ export default class UserConfigReport { report.push('') } this.errors.forEach(({path, value, message}) => { - report.push(`${chalk.red(`${figures.cross} ${path}`)} ${chalk.cyan('=')} ${util.inspect(value)}`) - report.push(` ${message}`) + report.push(`${chalk.red(`${figures.cross} ${path}`)}${value ? ` ${chalk.cyan('=')} ${util.inspect(value)}` : ''}`) + report.push(padLines(message)) report.push('') }) diff --git a/src/config/babel.js b/src/config/babel.js index 045d16c2..d56c7e9e 100644 --- a/src/config/babel.js +++ b/src/config/babel.js @@ -1,8 +1,37 @@ +import {validateOptions} from 'babel-preset-proposals' import chalk from 'chalk' -import {pluralise as s, typeOf} from '../utils' +import {padLines, pluralise as s, toSource, typeOf} from '../utils' -const BABEL_RUNTIME_OPTIONS = new Set(['helpers', 'polyfill']) +// TODO Remove - deprecated +let warnedAboutStageConfig = false +const STAGE_3_PROPOSALS = { + dynamicImport: true, + importMeta: true, + classProperties: true, + numericSeparator: true, + // Actually Stage 4, but still... + exportNamespaceFrom: true, +} +const STAGE_2_PROPOSALS = { + ...STAGE_3_PROPOSALS, + decorators: true, + functionSent: true, + logicalAssignmentOperators: true, + throwExpressions: true, +} +const STAGE_1_PROPOSALS = { + ...STAGE_2_PROPOSALS, + exportDefaultFrom: true, + pipelineOperator: true, + doExpressions: true, +} +const PROPOSALS_BY_STAGE = { + 0: {all: true}, + 1: STAGE_1_PROPOSALS, + 2: STAGE_2_PROPOSALS, + 3: STAGE_3_PROPOSALS, +} export function processBabelConfig({report, userConfig}) { let { @@ -11,6 +40,7 @@ export function processBabelConfig({report, userConfig}) { loose, plugins, presets, + proposals, removePropTypes, reactConstantElements, runtime, @@ -90,6 +120,24 @@ export function processBabelConfig({report, userConfig}) { } } + // proposals + if ('proposals' in userConfig.babel) { + if (typeOf(proposals) === 'object') { + let errors = validateOptions(proposals) + if (errors.length) { + report.error('babel.proposals', null, errors.join('\n')) + } + } + else if (proposals !== false) { + report.error( + 'babel.proposals', + proposals, + `Must be an ${chalk.cyan('Object')} (to configure proposal plugins) or ` + + `${chalk.cyan('false')} (to disable use of proposal plugins)` + ) + } + } + // removePropTypes if ('removePropTypes' in userConfig.babel) { if (removePropTypes !== false && typeOf(removePropTypes) !== 'object') { @@ -114,18 +162,26 @@ export function processBabelConfig({report, userConfig}) { } // runtime - if ('runtime' in userConfig.babel && - typeOf(runtime) !== 'boolean' && - !BABEL_RUNTIME_OPTIONS.has(runtime)) { - report.error( - 'babel.runtime', - runtime, - `Must be ${chalk.cyan('Boolean')}, ${chalk.cyan("'helpers'")} or ${chalk.cyan("'polyfill'")}` - ) + if ('runtime' in userConfig.babel) { + if (typeOf(runtime) !== 'object' && runtime !== false) { + report.error( + 'babel.runtime', + runtime, + `Must be an ${chalk.cyan('Object')} (to configure transform-runtime options) or ` + + `${chalk.cyan('false')} (to disable use of the runtime-transform plugin)` + ) + } } + // TODO Remove - deprecated // stage if ('stage' in userConfig.babel) { + let hasProposalsConfig = 'proposals' in userConfig.babel + let deprecationMessages = [ + 'Deprecated as of nwb v0.24.0, as Babel 7 no longer has preset-stage-X presets', + 'Use babel.proposals config instead to enable the required proposal plugins', + ] + if (typeOf(stage) === 'number') { if (stage < 0 || stage > 3) { report.error( @@ -134,15 +190,38 @@ export function processBabelConfig({report, userConfig}) { `Must be between ${chalk.cyan(0)} and ${chalk.cyan(3)}` ) } + else if (!hasProposalsConfig) { + deprecationMessages.push( + `For now, nwb will enable proposal plugins corresponding to the final version of preset-stage-${stage}`, + `This is equivalent to the following babel.proposals config:`, + '', + ...padLines(toSource(PROPOSALS_BY_STAGE[stage])).split('\n') + ) + userConfig.babel.proposals = {...PROPOSALS_BY_STAGE[stage]} + } } else if (stage !== false) { report.error( 'babel.stage', stage, - `Must be a ${chalk.cyan('Number')} between ${chalk.cyan('0')} and ${chalk.cyan('3')} (to choose a stage preset), ` + + `Must be a ${chalk.cyan('Number')} between ${chalk.cyan(0)} and ${chalk.cyan(3)} (to choose a stage preset), ` + `or ${chalk.cyan('false')} (to disable use of a stage preset)` ) } + else { + if (!hasProposalsConfig) { + deprecationMessages.push( + `For now, nwb will disable use of proposal plugins`, + `This is equivalent to configuring ${chalk.cyan('babel.proposals = false')}` + ) + userConfig.babel.proposals = false + } + } + + if (!warnedAboutStageConfig) { + report.deprecated('babel.stage', ...deprecationMessages) + warnedAboutStageConfig = true + } } // config diff --git a/src/config/webpack.js b/src/config/webpack.js index 98ee9f8f..b78bf4e4 100644 --- a/src/config/webpack.js +++ b/src/config/webpack.js @@ -307,11 +307,7 @@ export function processWebpackConfig({pluginConfig, report, userConfig}) { } = styleConfig Object.keys(loaderConfig).forEach(loaderId => { if (!DEFAULT_STYLE_LOADERS.has(loaderId) && loaderId !== styleType) { - // XXX Assumption: preprocessors provide a single loader which - // is configured with the same id as the style type id. - // XXX Using Array.from() manually as babel-preset-env with a - // Node 4 target is tranpiling Array spreads to concat() - // calls without ensuring Sets are converted to Arrays. + // XXX Assumption: preprocessors provide a single loader which is configured with the same id as the style type id let loaderIds = Array.from(new Set([ ...Array.from(DEFAULT_STYLE_LOADERS), styleType diff --git a/src/createBabelConfig.js b/src/createBabelConfig.js index 47462a5b..0a2e6a16 100644 --- a/src/createBabelConfig.js +++ b/src/createBabelConfig.js @@ -2,7 +2,6 @@ import path from 'path' import {UserError} from './errors' -import {typeOf} from './utils' type BabelPluginConfig = string | [string, Object]; @@ -12,14 +11,15 @@ type BabelConfig = { }; type BuildOptions = { + absoluteRuntime?: false, commonJSInterop?: boolean, env?: Object, modules?: false | string, plugins?: BabelPluginConfig[], - presets?: string[], + presets?: BabelPluginConfig[], + proposals?: Object, removePropTypes?: true | Object, - setRuntimePath?: false, - stage?: number, + runtime?: Object, webpack?: boolean, }; @@ -30,28 +30,26 @@ type UserOptions = { loose?: boolean, plugins?: BabelPluginConfig[], presets?: BabelPluginConfig[], + proposals?: false | Object, reactConstantElements?: boolean, removePropTypes?: false | Object, - runtime?: boolean | string, - stage?: false | number, + runtime?: false | Object, }; -const DEFAULT_STAGE = 2 -const RUNTIME_PATH = path.dirname(require.resolve('babel-runtime/package')) - export default function createBabelConfig( buildConfig: BuildOptions = {}, userConfig: UserOptions = {}, userConfigPath: string = '' ): BabelConfig { let { + absoluteRuntime, commonJSInterop, modules = false, plugins: buildPlugins = [], presets: buildPresets, + proposals: buildProposals = {}, removePropTypes: buildRemovePropTypes = false, - setRuntimePath, - stage: buildStage = DEFAULT_STAGE, + runtime: buildRuntime, webpack = true, } = buildConfig @@ -62,22 +60,22 @@ export default function createBabelConfig( loose, plugins: userPlugins = [], presets: userPresets, + proposals: userProposals = {}, reactConstantElements, removePropTypes: userRemovePropTypes, runtime: userRuntime, - stage: userStage, } = userConfig let presets: BabelPluginConfig[] = [] let plugins: BabelPluginConfig[] = [] // Default to loose mode unless explicitly configured - if (typeOf(loose) === 'undefined') { + if (typeof loose === 'undefined') { loose = true } presets.push( - [require.resolve('babel-preset-env'), {loose, modules, ...env}] + [require.resolve('@babel/preset-env'), {loose, modules, ...env}] ) // Additional build presets @@ -88,7 +86,7 @@ export default function createBabelConfig( if (preset === 'react-prod') { // Hoist static element subtrees up so React can skip them when reconciling if (reactConstantElements !== false) { - plugins.push(require.resolve('babel-plugin-transform-react-constant-elements')) + plugins.push(require.resolve('@babel/plugin-transform-react-constant-elements')) } // Remove or wrap propTypes and optionally remove prop-types imports if (userRemovePropTypes !== false) { @@ -98,22 +96,26 @@ export default function createBabelConfig( ]) } } - // All other presets are assumed to be paths to a preset module else { presets.push(preset) } }) } - // Stage preset - let stage = userStage != null ? userStage : buildStage - if (typeof stage == 'number') { - presets.push(require.resolve(`babel-preset-stage-${stage}`)) - // Decorators are stage 2 but not supported by Babel yet - add the legacy - // transform for support in the meantime. - if (stage <= 2) { - plugins.push(require.resolve('babel-plugin-transform-decorators-legacy')) - } + // Proposal plugins + if (userProposals !== false) { + presets.push([require.resolve('babel-preset-proposals'), { + // Pass on nwb's loose = true default + loose, + decorators: true, + classProperties: true, + exportDefaultFrom: true, + exportNamespaceFrom: true, + ...buildProposals, + ...userProposals, + // Required for non-local usage of nwb + absolutePaths: true + }]) } if (userPresets) { @@ -138,35 +140,20 @@ export default function createBabelConfig( } } - // The Runtime transform imports various things into a module based on usage. - // Turn regenerator on by default to enable use of async/await and generators - // without configuration. - let runtimeTransformOptions: Object = { - helpers: false, - polyfill: false, - regenerator: true, - } - if (setRuntimePath !== false) { - runtimeTransformOptions.moduleName = RUNTIME_PATH - } + // The Runtime transform imports helpers and the regenerator runtime when required + // See https://babeljs.io/docs/en/babel-plugin-transform-runtime.html if (userRuntime !== false) { - if (userRuntime === true) { - // Enable all features - runtimeTransformOptions = {} - if (setRuntimePath !== false) { - runtimeTransformOptions.moduleName = RUNTIME_PATH - } - } - else if (typeOf(userRuntime) === 'string') { - // Enable the named feature - runtimeTransformOptions[userRuntime] = true - } - plugins.push([require.resolve('babel-plugin-transform-runtime'), runtimeTransformOptions]) + plugins.push([require.resolve('@babel/plugin-transform-runtime'), { + absoluteRuntime: absoluteRuntime !== false ? path.resolve(__dirname, '..') : false, + useESModules: modules === false, + ...typeof buildRuntime === 'object' ? buildRuntime : {}, + ...typeof userRuntime === 'object' ? userRuntime : {} + }]) } // Allow Babel to parse (but not transform) import() when used with Webpack if (webpack) { - plugins.push(require.resolve('babel-plugin-syntax-dynamic-import')) + plugins.push(require.resolve('@babel/plugin-syntax-dynamic-import')) } // Provide CommonJS interop so users don't have to tag a .default onto their diff --git a/src/createKarmaConfig.js b/src/createKarmaConfig.js index ee31be3d..a42ae601 100644 --- a/src/createKarmaConfig.js +++ b/src/createKarmaConfig.js @@ -15,7 +15,7 @@ import {deepToString, typeOf} from './utils' const DEFAULT_EXCLUDE_FROM_COVERAGE = ['test/', 'tests/', 'src/**/__tests__/'] // Not every file in a test directory is a test and tests may also be co-located // with the code they test, so determine test files by suffix. -const DEFAULT_TEST_FILES = ['+(src|test?(s))/**/*+(-test|.spec|.test).js'] +const DEFAULT_TEST_FILES = ['+(src|test?(s))/**/*+(.spec|.test).js'] /** * Browser, framework and reporter config can be passed as strings or as plugin @@ -135,7 +135,7 @@ export default function createKarmaConfig(args, buildConfig, pluginConfig, userC let testFiles = userKarma.testFiles || DEFAULT_TEST_FILES // Polyfill by default for browsers which lack features (hello PhantomJS) - let files = [require.resolve('babel-polyfill/dist/polyfill.js')] + let files = [require.resolve('@babel/polyfill/dist/polyfill.js')] let preprocessors = {} if (userKarma.testContext) { diff --git a/src/createProject.js b/src/createProject.js index e2079216..68e8e396 100644 --- a/src/createProject.js +++ b/src/createProject.js @@ -118,10 +118,10 @@ function initGit(args, cwd, cb) { */ export function validateProjectType(projectType) { if (!projectType) { - throw new UserError(`A project type must be provided, one of: ${[...PROJECT_TYPES].join(', ')}`) + throw new UserError(`A project type must be provided, one of: ${Array.from(PROJECT_TYPES).join(', ')}`) } if (!PROJECT_TYPES.has(projectType)) { - throw new UserError(`Project type must be one of: ${[...PROJECT_TYPES].join(', ')}`) + throw new UserError(`Project type must be one of: ${Array.from(PROJECT_TYPES).join(', ')}`) } } diff --git a/src/createWebpackConfig.js b/src/createWebpackConfig.js index 46d2cc26..c9cdb94d 100644 --- a/src/createWebpackConfig.js +++ b/src/createWebpackConfig.js @@ -7,6 +7,7 @@ import CopyPlugin from 'copy-webpack-plugin' import HtmlPlugin from 'html-webpack-plugin' import MiniCssExtractPlugin from 'mini-css-extract-plugin' import NpmInstallPlugin from '@insin/npm-install-webpack-plugin' +import ReactRefreshPlugin from '@pmmmwh/react-refresh-webpack-plugin' import webpack from 'webpack' import merge from 'webpack-merge' @@ -489,6 +490,13 @@ export function createPlugins( plugins.push(new webpack.HotModuleReplacementPlugin()) optimization.noEmitOnErrors = true } + if (buildConfig.reactRefresh) { + // XXX disableRefreshCheck is currently required + // See https://github.com/pmmmwh/react-refresh-webpack-plugin/issues/15 + plugins.push(new ReactRefreshPlugin({ + disableRefreshCheck: true, + })) + } if (buildConfig.status) { plugins.push(new StatusPlugin(buildConfig.status)) } diff --git a/src/errors.js b/src/errors.js index f9dd57c3..14036444 100644 --- a/src/errors.js +++ b/src/errors.js @@ -1,18 +1,10 @@ // @flow + /** * An error related to user input or configuration, or anything else the user is * responsible for and can fix. */ -export class UserError extends Error { - constructor(message: string) { - super(message) - // Make instanceof UserError work in ES5 - // $FlowFixMe - this.constructor = UserError - // $FlowFixMe - this.__proto__ = UserError.prototype // eslint-disable-line no-proto - } -} +export class UserError extends Error {} export class KarmaExitCodeError { exitCode: number; diff --git a/src/expressMiddleware.js b/src/expressMiddleware.js index 1acab090..6b628423 100644 --- a/src/expressMiddleware.js +++ b/src/expressMiddleware.js @@ -42,7 +42,7 @@ export default function nwbMiddleware(express: Object, options: Object = {}) { let args = { _: [`serve-${projectType}`, options.entry], config: options.config, - hmre: !(options.hmr === false || options.hmre === false), + hmr: options.hmr !== false, install: !!options.install || !!options.autoInstall, reload: !!options.reload } diff --git a/src/inferno/inferno-preset.js b/src/inferno/inferno-preset.js index 879b9dbd..d5e999e7 100644 --- a/src/inferno/inferno-preset.js +++ b/src/inferno/inferno-preset.js @@ -1,6 +1,8 @@ -module.exports = { - plugins: [ - require.resolve('babel-plugin-syntax-jsx'), - require.resolve('babel-plugin-inferno'), - ] +module.exports = function() { + return { + plugins: [ + require.resolve('babel-plugin-syntax-jsx'), + require.resolve('babel-plugin-inferno'), + ] + } } diff --git a/src/moduleBuild.js b/src/moduleBuild.js index 6d7ba96d..01072812 100644 --- a/src/moduleBuild.js +++ b/src/moduleBuild.js @@ -16,13 +16,11 @@ import webpackBuild from './webpackBuild' import {createBanner, createExternals, logGzippedFileSizes} from './webpackUtils' // These match DEFAULT_TEST_DIRS and DEFAULT_TEST_FILES for co-located tests in -// ./createKarmaConfig.js; unfortunately Babel doesn't seem to support reusing -// the same patterns. +// ./createKarmaConfig.js const DEFAULT_BABEL_IGNORE_CONFIG = [ - '.spec.js', - '.test.js', - '-test.js', - '/__tests__/' + '**/*.spec.js', + '**/*.test.js', + '**/__tests__/' ] /** @@ -125,10 +123,12 @@ export default function moduleBuild(args, buildConfig = {}, cb) { ) } - let src = path.resolve('src') let pluginConfig = getPluginConfig(args) let userConfig = getUserConfig(args, {pluginConfig}) - let copyFiles = !!args['copy-files'] + let babelCliOptions = { + copyFiles: !!args['copy-files'], + src: path.resolve('src'), + } let tasks = [(cb) => cleanModule(args, cb)] @@ -137,16 +137,16 @@ export default function moduleBuild(args, buildConfig = {}, cb) { if (userConfig.npm.cjs !== false) { tasks.push((cb) => runBabel( 'ES5', - {copyFiles, outDir: path.resolve('lib'), src}, + {...babelCliOptions, outDir: path.resolve('lib')}, merge(buildConfig.babel, buildConfig.babelDev || {}, { - // Don't force CommonJS users of the CommonJS build to eat a .require - commonJSInterop: true, + // Don't set the path to nwb's @babel/runtime, as it will need to be a + // dependency or peerDependency of your module if you enable + // transform-runtime's 'helpers' option. + absoluteRuntime: false, // Transpile modules to CommonJS modules: 'commonjs', - // Don't set the path to nwb's babel-runtime, as it will need to be a - // peerDependency of your module if you use transform-runtime's helpers - // option. - setRuntimePath: false, + // Don't force CommonJS users of the CommonJS build to eat a .default + commonJSInterop: true, // Don't enable webpack-specific plugins webpack: false, }), @@ -160,12 +160,12 @@ export default function moduleBuild(args, buildConfig = {}, cb) { if (userConfig.npm.esModules !== false) { tasks.push((cb) => runBabel( 'ES modules', - {copyFiles, outDir: path.resolve('es'), src}, + {...babelCliOptions, outDir: path.resolve('es')}, merge(buildConfig.babel, buildConfig.babelDev || {}, { - // Don't set the path to nwb's babel-runtime, as it will need to be a - // peerDependency of your module if you use transform-runtime's helpers - // option. - setRuntimePath: false, + // Don't set the path to nwb's @babel/runtime, as it will need to be a + // dependency or peerDependency of your module if you enable + // transform-runtime's 'helpers' option. + absoluteRuntime: false, // Don't enable webpack-specific plugins webpack: false, }), diff --git a/src/preact/preact-preset.js b/src/preact/preact-preset.js index e72666aa..9935394d 100644 --- a/src/preact/preact-preset.js +++ b/src/preact/preact-preset.js @@ -1,5 +1,7 @@ -module.exports = { - plugins: [ - [require.resolve('babel-plugin-transform-react-jsx'), {pragma: 'h'}] - ] +module.exports = function() { + return { + plugins: [ + [require.resolve('@babel/plugin-transform-react-jsx'), {pragma: 'h'}] + ] + } } diff --git a/src/quickCommands.js b/src/quickCommands.js index 3f5357ed..fd5869a6 100644 --- a/src/quickCommands.js +++ b/src/quickCommands.js @@ -76,7 +76,9 @@ export function createBuildConfig(args: Object, options: QuickConfigOptions) { let config: Object = { babel: { - stage: 0, + proposals: { + all: true + } }, devtool: 'source-map', output: { @@ -137,7 +139,9 @@ export function createServeConfig(args: Object, options: QuickConfigOptions) { let config: Object = { babel: { - stage: 0 + proposals: { + all: true + } }, output: { filename: 'app.js', diff --git a/src/react/index.js b/src/react/index.js index 56b198b2..28bfcaba 100644 --- a/src/react/index.js +++ b/src/react/index.js @@ -6,7 +6,11 @@ import {modulePath} from '../utils' function getBaseConfig(): Object { return { babel: { - presets: [require.resolve('babel-preset-react')] + presets: [ + [require.resolve('@babel/preset-react'), { + development: process.env.NODE_ENV !== 'production' + }] + ] }, } } @@ -117,10 +121,14 @@ class ReactConfig { getServeConfig = () => { let config = getBaseConfig() - config.babel.presets.push(require.resolve('./react-dev-preset')) - if (this._args.hmr !== false && this._args.hmre !== false) { - config.babel.presets.push(require.resolve('./react-hmre-preset')) + if (this._args.hmr !== false) { + config.babel.plugins = [ + [require.resolve('react-refresh/babel'), { + skipEnvCheck: Boolean(process.env.NWB_TEST) + }] + ] + config.plugins = {reactRefresh: true} } return config diff --git a/src/react/react-dev-preset.js b/src/react/react-dev-preset.js deleted file mode 100644 index c889601c..00000000 --- a/src/react/react-dev-preset.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - plugins: [ - require.resolve('babel-plugin-transform-react-jsx-source'), - require.resolve('babel-plugin-transform-react-jsx-self'), - ] -} diff --git a/src/react/react-hmre-preset.js b/src/react/react-hmre-preset.js deleted file mode 100644 index eae0cbf0..00000000 --- a/src/react/react-hmre-preset.js +++ /dev/null @@ -1,18 +0,0 @@ -module.exports = { - plugins: [ - [require('babel-plugin-react-transform').default, { - factoryMethods: ['React.createClass', 'createClass', 'createReactClass'], - transforms: [ - { - transform: require.resolve('react-transform-hmr'), - imports: ['react'], - locals: ['module'] - }, - { - transform: require.resolve('react-transform-catch-errors'), - imports: ['react', require.resolve('redbox-noreact')] - } - ] - }] - ] -} diff --git a/src/utils.js b/src/utils.js index acd275e9..afb3d041 100644 --- a/src/utils.js +++ b/src/utils.js @@ -199,6 +199,10 @@ export function modulePath(module: string, basedir: string = process.cwd()): str return path.dirname(resolve.sync(`${module}/package.json`, {basedir})) } +export function padLines(message: string, padding: string = ' '): string { + return message.split('\n').map(line => `${padding}${line}`).join('\n') +} + export function pluralise(count: number, suffixes : string = ',s'): string { return suffixes.split(',')[count === 1 ? 0 : 1] } diff --git a/templates/inferno-app/tests/App-test.js b/templates/inferno-app/tests/App.test.js similarity index 100% rename from templates/inferno-app/tests/App-test.js rename to templates/inferno-app/tests/App.test.js diff --git a/templates/preact-app/tests/App-test.js b/templates/preact-app/tests/App.test.js similarity index 100% rename from templates/preact-app/tests/App-test.js rename to templates/preact-app/tests/App.test.js diff --git a/templates/react-app/tests/App-test.js b/templates/react-app/tests/App.test.js similarity index 100% rename from templates/react-app/tests/App-test.js rename to templates/react-app/tests/App.test.js diff --git a/templates/react-component/tests/index-test.js b/templates/react-component/tests/index.test.js similarity index 100% rename from templates/react-component/tests/index-test.js rename to templates/react-component/tests/index.test.js diff --git a/templates/web-app/tests/index-test.js b/templates/web-app/tests/index.test.js similarity index 100% rename from templates/web-app/tests/index-test.js rename to templates/web-app/tests/index.test.js diff --git a/templates/web-module/tests/index-test.js b/templates/web-module/tests/index.test.js similarity index 100% rename from templates/web-module/tests/index-test.js rename to templates/web-module/tests/index.test.js diff --git a/tests/commands/new-init-test.js b/tests/commands/new-init-test.js index 05a613c2..376eba16 100644 --- a/tests/commands/new-init-test.js +++ b/tests/commands/new-init-test.js @@ -34,7 +34,7 @@ function reactAppAssertions(dir, name, err, done) { 'src/react.svg', 'tests', 'tests/.eslintrc', - 'tests/App-test.js', + 'tests/App.test.js', ]) expect(glob.sync('node_modules/*', { cwd: path.resolve(dir) @@ -68,7 +68,7 @@ function reactComponentAssertions(dir, name, err, done) { 'src/index.js', 'tests', 'tests/.eslintrc', - 'tests/index-test.js', + 'tests/index.test.js', ]) expect(glob.sync('node_modules/*', { cwd: path.resolve(dir) @@ -112,7 +112,7 @@ function webAppAssertions(dir, name, err, done) { 'src/index.js', 'tests', 'tests/.eslintrc', - 'tests/index-test.js', + 'tests/index.test.js', ]) let pkg = require(path.resolve(dir, 'package.json')) expect(pkg.name).toBe(name) @@ -138,7 +138,7 @@ function webModuleAssertions(dir, name, err, done) { 'src/index.js', 'tests', 'tests/.eslintrc', - 'tests/index-test.js', + 'tests/index.test.js', ]) let pkg = require(path.resolve(dir, 'package.json')) expect(pkg.name).toBe(name) diff --git a/tests/commands/projects-test.js b/tests/commands/projects-test.js index a2fb0a7c..2558c65f 100644 --- a/tests/commands/projects-test.js +++ b/tests/commands/projects-test.js @@ -207,9 +207,9 @@ describe('sample projects', function() { it('ES5 build transpiles to a cherry-picked version', () => { expect(es5) - .toInclude("require('react-bootstrap/lib/Col')") - .toInclude("require('react-bootstrap/lib/Grid')") - .toInclude("require('react-bootstrap/lib/Row')") + .toInclude('require("react-bootstrap/lib/Col")') + .toInclude('require("react-bootstrap/lib/Grid")') + .toInclude('require("react-bootstrap/lib/Row")') }) it('ES5 build has propType declarations wrapped in an environment check', () => { expect(es5).toInclude('CherryPicker.propTypes = process.env.NODE_ENV !== "production" ? {') @@ -224,9 +224,9 @@ describe('sample projects', function() { }) it('ES modules build transpiles to a cherry-picked version', () => { expect(esModules) - .toInclude("import _Col from 'react-bootstrap/lib/Col'") - .toInclude("import _Grid from 'react-bootstrap/lib/Grid'") - .toInclude("import _Row from 'react-bootstrap/lib/Row'") + .toInclude('import _Col from "react-bootstrap/lib/Col"') + .toInclude('import _Grid from "react-bootstrap/lib/Grid"') + .toInclude('import _Row from "react-bootstrap/lib/Row"') }) it('ES module build has propType declarations wrapped in an environment check', () => { expect(esModules).toInclude('CherryPicker.propTypes = process.env.NODE_ENV !== "production" ? {') diff --git a/tests/commands/test-test.js b/tests/commands/test-test.js index 2f236261..65e5a5bc 100644 --- a/tests/commands/test-test.js +++ b/tests/commands/test-test.js @@ -95,8 +95,8 @@ describe('command: test', function() { cli(['new', 'web-module', 'test-failure-module', '-f'], err => { expect(err).toNotExist('No errors creating new web module for failure test') process.chdir(path.join(tmpDir, 'test-failure-module')) - let content = fs.readFileSync('./tests/index-test.js', 'utf-8') - fs.writeFileSync('./tests/index-test.js', content.replace('Welcome to', 'X')) + let content = fs.readFileSync('./tests/index.test.js', 'utf-8') + fs.writeFileSync('./tests/index.test.js', content.replace('Welcome to', 'X')) cli(['test'], err => { expect(err).toExist() done() @@ -108,8 +108,8 @@ describe('command: test', function() { cli(['new', 'web-module', 'test-failure-module', '-f'], err => { expect(err).toNotExist('No errors creating new web module for failure test') process.chdir(path.join(tmpDir, 'test-failure-module')) - let content = fs.readFileSync('./tests/index-test.js', 'utf-8') - fs.writeFileSync('./tests/index-test.js', content.replace('Welcome to', 'X')) + let content = fs.readFileSync('./tests/index.test.js', 'utf-8') + fs.writeFileSync('./tests/index.test.js', content.replace('Welcome to', 'X')) try { execSync(['node', path.join(__dirname, '../../lib/bin/nwb.js'), 'test'].join(' '), { stdio: 'inherit' diff --git a/tests/config-test.js b/tests/config-test.js index 73cd630a..08f89add 100644 --- a/tests/config-test.js +++ b/tests/config-test.js @@ -67,18 +67,23 @@ describe('processUserConfig()', () => { it('config file has an invalid type', () => { check({type: 'invalid'}, 'type', /Must be/) }) + // TODO Remove - deprecated it('babel.stage is not a number, or falsy', () => { check({babel: {stage: []}}, 'babel.stage', /Must be/) }) + // TODO Remove - deprecated it('babel.stage is out of bounds', () => { check({babel: {stage: -1}}, 'babel.stage', /Must be/) check({babel: {stage: 4}}, 'babel.stage', /Must be/) }) + it('babel.plugins is not an array', () => { + check({babel: {plugins: {}}}, 'babel.plugins', /Must be/) + }) it('babel.presets is not an array', () => { check({babel: {presets: {}}}, 'babel.presets', /Must be/) }) - it('babel.plugins is not an array', () => { - check({babel: {plugins: {}}}, 'babel.plugins', /Must be/) + it('babel.proposals is not an object or false', () => { + check({babel: {proposals: /invalid/}}, 'babel.proposals', /Must be/) }) it('babel.runtime is not valid', () => { check({babel: {runtime: 'welp'}}, 'babel.runtime', /Must be/) diff --git a/tests/createBabelConfig-test.js b/tests/createBabelConfig-test.js index 96e0b19e..74b8533b 100644 --- a/tests/createBabelConfig-test.js +++ b/tests/createBabelConfig-test.js @@ -5,14 +5,22 @@ import expect from 'expect' import createBabelConfig from '../src/createBabelConfig' -let babelRuntimePath = path.dirname(require.resolve('babel-runtime/package')) +let ABSOLUTE_RUNTIME_PATH = path.resolve(__dirname, '..') let DEFAULT_RUNTIME_CONFIG = - [require.resolve('babel-plugin-transform-runtime'), { - helpers: false, - polyfill: false, - regenerator: true, - moduleName: babelRuntimePath, + [require.resolve('@babel/plugin-transform-runtime'), { + absoluteRuntime: ABSOLUTE_RUNTIME_PATH, + useESModules: true, + }] + +let DEFAULT_PROPOSALS_CONFIG = + [require.resolve('babel-preset-proposals'), { + absolutePaths: true, + classProperties: true, + decorators: true, + exportDefaultFrom: true, + exportNamespaceFrom: true, + loose: true, }] describe('createBabelConfig()', () => { @@ -20,13 +28,12 @@ describe('createBabelConfig()', () => { it('generates default Babel config', () => { expect(createBabelConfig()).toEqual({ presets: [ - [require.resolve('babel-preset-env'), {loose: true, modules: false}], - require.resolve('babel-preset-stage-2'), + [require.resolve('@babel/preset-env'), {loose: true, modules: false}], + DEFAULT_PROPOSALS_CONFIG, ], plugins: [ - require.resolve('babel-plugin-transform-decorators-legacy'), DEFAULT_RUNTIME_CONFIG, - require.resolve('babel-plugin-syntax-dynamic-import'), + require.resolve('@babel/plugin-syntax-dynamic-import'), ] }) }) @@ -36,16 +43,17 @@ describe('createBabelConfig()', () => { it('generates build-configured Babel config', () => { expect(createBabelConfig({ modules: 'commonjs', - stage: 0, })).toEqual({ presets: [ - [require.resolve('babel-preset-env'), {loose: true, modules: 'commonjs'}], - require.resolve('babel-preset-stage-0'), + [require.resolve('@babel/preset-env'), {loose: true, modules: 'commonjs'}], + DEFAULT_PROPOSALS_CONFIG, ], plugins: [ - require.resolve('babel-plugin-transform-decorators-legacy'), - DEFAULT_RUNTIME_CONFIG, - require.resolve('babel-plugin-syntax-dynamic-import'), + [require.resolve('@babel/plugin-transform-runtime'), { + absoluteRuntime: ABSOLUTE_RUNTIME_PATH, + useESModules: false, + }], + require.resolve('@babel/plugin-syntax-dynamic-import'), ], }) }) @@ -53,16 +61,16 @@ describe('createBabelConfig()', () => { expect(createBabelConfig({ presets: ['react-prod'], }, { - stage: false, + proposals: false, })).toEqual({ presets: [ - [require.resolve('babel-preset-env'), {loose: true, modules: false}], + [require.resolve('@babel/preset-env'), {loose: true, modules: false}], ], plugins: [ - require.resolve('babel-plugin-transform-react-constant-elements'), + require.resolve('@babel/plugin-transform-react-constant-elements'), [require.resolve('babel-plugin-transform-react-remove-prop-types'), {}], DEFAULT_RUNTIME_CONFIG, - require.resolve('babel-plugin-syntax-dynamic-import'), + require.resolve('@babel/plugin-syntax-dynamic-import'), ], }) }) @@ -70,34 +78,32 @@ describe('createBabelConfig()', () => { expect(createBabelConfig({ removePropTypes: true, }, { - stage: false, + proposals: false, })).toEqual({ presets: [ - [require.resolve('babel-preset-env'), {loose: true, modules: false}], + [require.resolve('@babel/preset-env'), {loose: true, modules: false}], ], plugins: [ [require.resolve('babel-plugin-transform-react-remove-prop-types'), {}], DEFAULT_RUNTIME_CONFIG, - require.resolve('babel-plugin-syntax-dynamic-import'), + require.resolve('@babel/plugin-syntax-dynamic-import'), ], }) }) - it('prevents moduleName being configured for transform-runtime', () => { + it('prevents an absolute runtime path being configured for transform-runtime', () => { expect(createBabelConfig({ - setRuntimePath: false, + absoluteRuntime: false, })).toEqual({ presets: [ - [require.resolve('babel-preset-env'), {loose: true, modules: false}], - require.resolve('babel-preset-stage-2'), + [require.resolve('@babel/preset-env'), {loose: true, modules: false}], + DEFAULT_PROPOSALS_CONFIG, ], plugins: [ - require.resolve('babel-plugin-transform-decorators-legacy'), - [require.resolve('babel-plugin-transform-runtime'), { - helpers: false, - polyfill: false, - regenerator: true, + [require.resolve('@babel/plugin-transform-runtime'), { + absoluteRuntime: false, + useESModules: true, }], - require.resolve('babel-plugin-syntax-dynamic-import'), + require.resolve('@babel/plugin-syntax-dynamic-import'), ] }) }) @@ -106,87 +112,112 @@ describe('createBabelConfig()', () => { context('with user config', () => { it('generates user-configured Babel config', () => { expect(createBabelConfig({}, { - stage: 0, + proposals: { + numericSeparator: true + }, loose: false, - runtime: true, plugins: ['test-plugin'], presets: ['test-preset'], })).toEqual({ presets: [ - [require.resolve('babel-preset-env'), {loose: false, modules: false}], - require.resolve('babel-preset-stage-0'), + [require.resolve('@babel/preset-env'), {loose: false, modules: false}], + [require.resolve('babel-preset-proposals'), { + absolutePaths: true, + classProperties: true, + decorators: true, + exportDefaultFrom: true, + exportNamespaceFrom: true, + loose: false, + numericSeparator: true, + }], 'test-preset', ], plugins: [ - require.resolve('babel-plugin-transform-decorators-legacy'), 'test-plugin', - [require.resolve('babel-plugin-transform-runtime'), { - moduleName: babelRuntimePath, - }], - require.resolve('babel-plugin-syntax-dynamic-import'), + DEFAULT_RUNTIME_CONFIG, + require.resolve('@babel/plugin-syntax-dynamic-import'), ], }) }) - it('chooses runtime transform config', () => { - ['helpers', 'polyfill'].forEach(runtime => { - expect(createBabelConfig({}, { - runtime, - })).toEqual({ - presets: [ - [require.resolve('babel-preset-env'), {loose: true, modules: false}], - - require.resolve('babel-preset-stage-2'), - ], - plugins: [ - require.resolve('babel-plugin-transform-decorators-legacy'), - [require.resolve('babel-plugin-transform-runtime'), { - helpers: false, - polyfill: false, - regenerator: true, - moduleName: babelRuntimePath, - [runtime]: true, - }], - require.resolve('babel-plugin-syntax-dynamic-import'), - ] - }) + it('disables runtime transform helpers', () => { + expect(createBabelConfig({}, { + runtime: {helpers: false}, + })).toEqual({ + presets: [ + [require.resolve('@babel/preset-env'), {loose: true, modules: false}], + DEFAULT_PROPOSALS_CONFIG, + ], + plugins: [ + [require.resolve('@babel/plugin-transform-runtime'), { + absoluteRuntime: ABSOLUTE_RUNTIME_PATH, + useESModules: true, + helpers: false, + }], + require.resolve('@babel/plugin-syntax-dynamic-import'), + ] }) }) }) context('with build and user config', () => { - it('overrides build stage config with user stage config', () => { - expect(createBabelConfig({stage: 3}, {stage: 1})).toEqual({ + it('overrides build proposals config with user proposals config', () => { + expect(createBabelConfig({proposals: {numericSeparator: true}}, {proposals: {numericSeparator: false}})).toEqual({ + presets: [ + [require.resolve('@babel/preset-env'), {loose: true, modules: false}], + [require.resolve('babel-preset-proposals'), { + absolutePaths: true, + classProperties: true, + decorators: true, + exportDefaultFrom: true, + exportNamespaceFrom: true, + loose: true, + numericSeparator: false, + }] + ], + plugins: [ + DEFAULT_RUNTIME_CONFIG, + require.resolve('@babel/plugin-syntax-dynamic-import'), + ] + }) + }) + it('overrides default proposals config', () => { + expect(createBabelConfig({}, {proposals: {decorators: false}})).toEqual({ presets: [ - [require.resolve('babel-preset-env'), {loose: true, modules: false}], - require.resolve('babel-preset-stage-1'), + [require.resolve('@babel/preset-env'), {loose: true, modules: false}], + [require.resolve('babel-preset-proposals'), { + absolutePaths: true, + classProperties: true, + decorators: false, + exportDefaultFrom: true, + exportNamespaceFrom: true, + loose: true, + }] ], plugins: [ - require.resolve('babel-plugin-transform-decorators-legacy'), DEFAULT_RUNTIME_CONFIG, - require.resolve('babel-plugin-syntax-dynamic-import'), + require.resolve('@babel/plugin-syntax-dynamic-import'), ] }) }) - it('cancels default stage config', () => { - expect(createBabelConfig({}, {stage: false})).toEqual({ + it('cancels default proposals config', () => { + expect(createBabelConfig({}, {proposals: false})).toEqual({ presets: [ - [require.resolve('babel-preset-env'), {loose: true, modules: false}], + [require.resolve('@babel/preset-env'), {loose: true, modules: false}], ], plugins: [ DEFAULT_RUNTIME_CONFIG, - require.resolve('babel-plugin-syntax-dynamic-import'), + require.resolve('@babel/plugin-syntax-dynamic-import'), ] }) }) it('cancels default runtime config', () => { expect(createBabelConfig({}, {runtime: false})).toEqual({ presets: [ - [require.resolve('babel-preset-env'), {loose: true, modules: false}], - require.resolve('babel-preset-stage-2'), + [require.resolve('@babel/preset-env'), {loose: true, modules: false}], + DEFAULT_PROPOSALS_CONFIG, ], plugins: [ - require.resolve('babel-plugin-transform-decorators-legacy'), - require.resolve('babel-plugin-syntax-dynamic-import'), + require.resolve('@babel/plugin-syntax-dynamic-import'), ] }) }) diff --git a/tests/createKarmaConfig-test.js b/tests/createKarmaConfig-test.js index 9eb4fa14..6a4cc8a2 100644 --- a/tests/createKarmaConfig-test.js +++ b/tests/createKarmaConfig-test.js @@ -138,8 +138,8 @@ describe('createKarmaConfig()', () => { it('includes polyfill and default test files pattern', () => { let config = createKarmaConfig({}, {}, {}, {}) expect(config.files).toEqual([ - require.resolve('babel-polyfill/dist/polyfill.js'), - '+(src|test?(s))/**/*+(-test|.spec|.test).js', + require.resolve('@babel/polyfill/dist/polyfill.js'), + '+(src|test?(s))/**/*+(.spec|.test).js', ]) }) it('includes default mocha reporter config', () => { diff --git a/tests/fixtures/projects/async-await/tests/index-test.js b/tests/fixtures/projects/async-await/tests/index.test.js similarity index 100% rename from tests/fixtures/projects/async-await/tests/index-test.js rename to tests/fixtures/projects/async-await/tests/index.test.js diff --git a/tests/fixtures/projects/cherry-pick/src/index-test.js b/tests/fixtures/projects/cherry-pick/src/index-test.js deleted file mode 100644 index 8d321895..00000000 --- a/tests/fixtures/projects/cherry-pick/src/index-test.js +++ /dev/null @@ -1,2 +0,0 @@ -export function test() { -} diff --git a/tests/fixtures/worst-config.js b/tests/fixtures/worst-config.js index 1d408554..fcf20f11 100644 --- a/tests/fixtures/worst-config.js +++ b/tests/fixtures/worst-config.js @@ -10,10 +10,12 @@ module.exports = { env: 45, loose: 45, plugins: 45, + proposals: 45, presets: 45, removePropTypes: 45, reactConstantElements: 45, runtime: 45, + // TODO Remove - deprecated stage: 45, config: 45 }, diff --git a/tests/utils-test.js b/tests/utils-test.js index 8d69d6d2..ef55be8c 100644 --- a/tests/utils-test.js +++ b/tests/utils-test.js @@ -1,7 +1,7 @@ // @flow import expect from 'expect' -import {joinAnd} from '../src/utils' +import {joinAnd, padLines} from '../src/utils' import {createBanner, createExternals} from '../src/webpackUtils' describe('utils', () => { @@ -19,6 +19,12 @@ describe('utils', () => { expect(joinAnd(['one', 'two', 'three'])).toEqual('one, two and three') }) }) + + describe('padLines()', () => { + it('pads lines with 2 spaces by default', () => { + expect(padLines('1\n2\n3\n4')).toEqual(' 1\n 2\n 3\n 4') + }) + }) }) describe('webpackUtils', () => { From 08b3de4f644ebe1eb461e2c8be60db4251370b7e Mon Sep 17 00:00:00 2001 From: Muhannad Abdelrazek Date: Sat, 7 Mar 2020 04:30:40 +0200 Subject: [PATCH 23/66] Add document language option (#520) --- docs/Configuration.md | 4 ++++ src/appCommands.js | 1 + src/commands/build-demo.js | 1 + src/commands/serve-react-demo.js | 1 + templates/inferno-app/src/index.html | 2 +- templates/preact-app/src/index.html | 2 +- templates/react-app/src/index.html | 2 +- templates/web-app/src/index.html | 2 +- templates/webpack-template.html | 2 +- 9 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/Configuration.md b/docs/Configuration.md index 4c7e4c55..a915848b 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -579,6 +579,10 @@ module.exports = { If you don't have a template at `src/index.html` or specify one via `template`, nwb will fall back to using a basic template which has the following properties you can configure: +- `lang` - the language of document `` + + > Default: `'en'` + - `title` - contents for `` > Default: the value of `name` from your app's `package.json` diff --git a/src/appCommands.js b/src/appCommands.js index 71c2460f..ae159b52 100644 --- a/src/appCommands.js +++ b/src/appCommands.js @@ -125,6 +125,7 @@ export function getDefaultHTMLConfig(cwd: string = process.cwd()) { // Otherwise provide default variables for the internal template, in case we // fall back to it. return { + lang: 'en', mountId: 'app', title: require(path.join(cwd, 'package.json')).name, } diff --git a/src/commands/build-demo.js b/src/commands/build-demo.js index 5c1970f7..4e38b537 100644 --- a/src/commands/build-demo.js +++ b/src/commands/build-demo.js @@ -28,6 +28,7 @@ function getCommandConfig(args) { }, plugins: { html: { + lang: 'en', mountId: 'demo', title: args.title || `${pkg.name} ${pkg.version} Demo`, }, diff --git a/src/commands/serve-react-demo.js b/src/commands/serve-react-demo.js index 16cb15cc..e0535482 100644 --- a/src/commands/serve-react-demo.js +++ b/src/commands/serve-react-demo.js @@ -25,6 +25,7 @@ export default function serveReactDemo(args, cb) { }, plugins: { html: { + lang: 'en', mountId: 'demo', title: `${pkg.name} ${pkg.version} Demo`, }, diff --git a/templates/inferno-app/src/index.html b/templates/inferno-app/src/index.html index e07684fa..13be8d55 100644 --- a/templates/inferno-app/src/index.html +++ b/templates/inferno-app/src/index.html @@ -1,5 +1,5 @@ <!DOCTYPE html> -<html> +<html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> diff --git a/templates/preact-app/src/index.html b/templates/preact-app/src/index.html index e07684fa..13be8d55 100644 --- a/templates/preact-app/src/index.html +++ b/templates/preact-app/src/index.html @@ -1,5 +1,5 @@ <!DOCTYPE html> -<html> +<html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> diff --git a/templates/react-app/src/index.html b/templates/react-app/src/index.html index e07684fa..13be8d55 100644 --- a/templates/react-app/src/index.html +++ b/templates/react-app/src/index.html @@ -1,5 +1,5 @@ <!DOCTYPE html> -<html> +<html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> diff --git a/templates/web-app/src/index.html b/templates/web-app/src/index.html index e07684fa..13be8d55 100644 --- a/templates/web-app/src/index.html +++ b/templates/web-app/src/index.html @@ -1,5 +1,5 @@ <!DOCTYPE html> -<html> +<html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> diff --git a/templates/webpack-template.html b/templates/webpack-template.html index cc99def6..e5ef8987 100644 --- a/templates/webpack-template.html +++ b/templates/webpack-template.html @@ -1,5 +1,5 @@ <!DOCTYPE html> -<html> +<html lang="<%= htmlWebpackPlugin.options.lang %>"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> From 908267ffcc31a6eae5a263bdce9cdff5209627eb Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sat, 7 Mar 2020 12:43:13 +1000 Subject: [PATCH 24/66] Update CHANGES [ci skip] --- CHANGES.md | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 0c676006..b83d8917 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,12 +3,7 @@ ## Breaking Changes - Node.js 6 is no longer supported; Node.js 8.9.0 is now the minimum required version, as per nwb's dependencies. -- Dependencies with (documented) breaking changes: - - [copy-webpack-plugin@5.0.0](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#breaking-changes) - - [css-loader@3.0.0](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#breaking-changes) - - [file-loader@4.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#400-2019-06-05) - - [karma@4.0.0](https://github.com/karma-runner/karma/releases/tag/v4.0.0) - - [mocha@6.0.0](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#boom-breaking-changes) + - Updated to [Babel 7](https://babeljs.io/blog/2018/08/27/7.0.0) - [`babel.runtime` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#runtime-object--false) no longer accepts a `String` to enable an additional, named feature. @@ -17,11 +12,24 @@ - Support for tests in `*-test.js` files has been removed, as `@babel-core` no longer supports pattern matching them to ignore them when co-located in `src/`. Rename these to `*.test.js` instead. + - Dropped support for old `--no-hmre` alias to disable Hot Module Replacement, just use `--no-hmr` instead. +- Dependencies with (documented) breaking changes: + - [copy-webpack-plugin@5.0.0](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#breaking-changes) + - [css-loader@3.0.0](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#breaking-changes) + - [file-loader@4.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#400-2019-06-05) + - [karma@4.0.0](https://github.com/karma-runner/karma/releases/tag/v4.0.0) + - [mocha@6.0.0](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#boom-breaking-changes) + ## Added - Added [`babel.proposals` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#proposals-object--false) to configure use of Babel's proposal plugins. +- Added an `en` property to [`webpack.html` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#html-object) to set the document language when using nwb's default HTML template [[#520](https://github.com/insin/nwb/pull/520)] [[Muhnad][Muhnad]] + +## Fixed + +- Fix creation of an extra directory when creating a scoped component's UMD build [[#513](https://github.com/insin/nwb/issues/513)] [[rrapiteanu][rrapiteanu]] ## Changed @@ -43,7 +51,7 @@ - babel-plugin-inferno: v5.0.1 → [v5.1.0](https://github.com/infernojs/babel-plugin-inferno/releases) - case-sensitive-paths-webpack-plugin: v2.1.2 → [v2.3.0](https://github.com/Urthen/case-sensitive-paths-webpack-plugin/blob/master/CHANGELOG.md#v230) - chalk: v2.4.1 → [v3.0.0](https://github.com/chalk/chalk/releases/tag/v3.0.0) -- copy-webpack-plugin: v4.5.2 → [v5.1.1]https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#511-2019-12-12) +- copy-webpack-plugin: v4.5.2 → [v5.1.1](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#511-2019-12-12) - cross-spawn: v6.0.5 → [v7.0.1](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md#701-2019-10-07) - css-loader: v1.0.0 → [v3.4.2](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#342-2020-01-10) - detect-port: v1.2.3 → [v1.3.0](https://github.com/node-modules/detect-port/releases) @@ -67,7 +75,7 @@ - resolve: v1.8.1 → [v1.15.1](https://github.com/browserify/resolve/compare/v1.8.1...v1.15.1) - semver: v5.5.1 → [v7.1.3](https://github.com/npm/node-semver/compare/v5.5.1...v7.1.3) - style-loader: v0.21.0 → [v1.1.3](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0231-2018-10-08) -- uglifyjs-webpack-plugin v1.2.7 → [terser-webpack-plugin v1.2.3](https://github.com/webpack-contrib/terser-webpack-plugin#readme) +- uglifyjs-webpack-plugin v1.2.7 → [terser-webpack-plugin v2.3.5](https://github.com/webpack-contrib/terser-webpack-plugin#readme) - url-loader: v1.0.1 → [v2.3.0](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md#230-2019-11-21) - webpack: v4.16.4 → [v4.42.0](https://github.com/webpack/webpack/releases) - webpack-dev-middleware: v3.1.3 → [v3.7.2](https://github.com/webpack/webpack-dev-middleware/blob/master/CHANGELOG.md#372-2019-09-28) @@ -2161,8 +2169,10 @@ First 0.x release. [hanford]: https://github.com/hanford [jihchi]: https://github.com/jihchi [michaelsbradleyjr]: https://github.com/michaelsbradleyjr +[Muhnad]: https://github.com/Muhnad [ngyikp]: https://github.com/ngyikp [ntwcklng]: https://github.com/ntwcklng +[rrapiteanu]: https://github.com/rrapiteanu [seanofw]: https://github.com/seanofw [stephenwf]: https://github.com/stephenwf [totaldis]: https://github.com/totaldis From 81122b47ffc45e2ce876d809867980cf1ac4f03e Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sat, 7 Mar 2020 18:19:15 +1000 Subject: [PATCH 25/66] Update Preact config for Preact X --- CHANGES.md | 2 ++ src/preact/index.js | 20 ++++++-------------- src/preact/preact-preset.js | 5 ++++- src/preact/renderShim.js | 13 ++++++------- src/react/index.js | 12 ++++++------ templates/preact-app/src/index.js | 13 ++++++------- 6 files changed, 30 insertions(+), 35 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b83d8917..81449b88 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,8 @@ - Dropped support for old `--no-hmre` alias to disable Hot Module Replacement, just use `--no-hmr` instead. +- Updated Preact config for Preact X + - Dependencies with (documented) breaking changes: - [copy-webpack-plugin@5.0.0](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#breaking-changes) - [css-loader@3.0.0](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#breaking-changes) diff --git a/src/preact/index.js b/src/preact/index.js index cd19eeab..ac7febda 100644 --- a/src/preact/index.js +++ b/src/preact/index.js @@ -9,9 +9,9 @@ function getBaseConfig() { // Allow compatible React components to be used resolve: { alias: { - 'react': 'preact-compat', - 'react-dom': 'preact-compat', - 'create-react-class': 'preact-compat/lib/create-react-class', + 'react': 'preact/compat', + 'react-dom/test-utils': 'preact/test-utils', + 'react-dom': 'preact/compat', } }, } @@ -21,10 +21,6 @@ function getDependencies() { return ['preact'] } -function getCompatDependencies() { - return ['preact-compat'] -} - function getQuickConfig() { return { commandConfig: getBaseConfig(), @@ -42,11 +38,7 @@ export default (args: Object) => ({ return {compat: false} }, getProjectDependencies(answers: Object): string[] { - let deps = getDependencies() - if (answers.compat) { - deps = deps.concat(getCompatDependencies()) - } - return deps + return getDependencies() }, getProjectQuestions() { let defaults = this.getProjectDefaults() @@ -54,14 +46,14 @@ export default (args: Object) => ({ when: () => !('compat' in args), type: 'confirm', name: 'compat', - message: 'Do you want to use preact-compat so you can use React modules?', + message: 'Do you want to use preact/compat so you can use React modules?', default: defaults.compat, }] }, getBuildDependencies: () => [], getBuildConfig: getBaseConfig, getServeConfig: getBaseConfig, - getQuickDependencies: (): string[] => getDependencies().concat(getCompatDependencies()), + getQuickDependencies: (): string[] => getDependencies(), getQuickBuildConfig: getQuickConfig, getQuickServeConfig: getQuickConfig, getKarmaTestConfig: getBaseConfig, diff --git a/src/preact/preact-preset.js b/src/preact/preact-preset.js index 9935394d..70764c0a 100644 --- a/src/preact/preact-preset.js +++ b/src/preact/preact-preset.js @@ -1,7 +1,10 @@ module.exports = function() { return { plugins: [ - [require.resolve('@babel/plugin-transform-react-jsx'), {pragma: 'h'}] + [require.resolve('@babel/plugin-transform-react-jsx'), { + pragma: 'h', + pragmaFrag: 'Fragment', + }] ] } } diff --git a/src/preact/renderShim.js b/src/preact/renderShim.js index 6a9d37f1..481f543a 100644 --- a/src/preact/renderShim.js +++ b/src/preact/renderShim.js @@ -1,16 +1,15 @@ /* global NWB_QUICK_MOUNT_ID */ +// Enable use of Preact Devtools +if (process.env.NODE_ENV === 'development') { + require('preact/debug') +} + let Preact = require('preact') let parent = document.getElementById(NWB_QUICK_MOUNT_ID) -let root = parent.firstChild // If #app already contains elements, hydrate from them (for SSR) let vnode = null -if (process.env.NODE_ENV === 'development') { - // Enable use of React Developer Tools - require('preact/devtools') -} - function renderEntry(exported) { if (exported.default) { exported = exported.default @@ -28,7 +27,7 @@ function renderEntry(exported) { // Assumption: the entry module rendered the app return } - root = Preact.render(vnode, parent, root) + Preact.render(vnode, parent, parent.firstElementChild) } function init() { diff --git a/src/react/index.js b/src/react/index.js index 28bfcaba..4b9244a7 100644 --- a/src/react/index.js +++ b/src/react/index.js @@ -38,15 +38,15 @@ function getBuildConfig(args, options: {useModulePath?: boolean} = {}) { } } else if (args.preact || args['preact-compat']) { - // Use the path to preact-compat.js, as using the path to the preact-compat - // module picks up the "module" build, which prevents hijacking the render() - // function in the render shim. - let preactCompathPath = path.join(aliasPath('preact-compat'), 'dist/preact-compat') + // Use the path to preact/compat's CommonJS build to avoid picking up the + // ES modules build, which prevents hijacking the render() function in the + // render shim. + let preactCompathPath = path.join(aliasPath('preact'), 'compat/dist/compat') config.resolve = { alias: { 'react': preactCompathPath, + 'react-dom/test-utils': path.join(aliasPath('preact'), 'test-utils'), 'react-dom': preactCompathPath, - 'create-react-class': 'preact-compat/lib/create-react-class', }, } } @@ -66,7 +66,7 @@ class ReactConfig { return ['inferno', 'inferno-compat', 'inferno-clone-vnode', 'inferno-create-class', 'inferno-create-element'] } else if (this._args.preact || this._args['preact-compat']) { - return ['preact', 'preact-compat'] + return ['preact'] } return [] } diff --git a/templates/preact-app/src/index.js b/templates/preact-app/src/index.js index 4f7e6bf9..f1bb4002 100644 --- a/templates/preact-app/src/index.js +++ b/templates/preact-app/src/index.js @@ -1,16 +1,15 @@ +if (process.env.NODE_ENV === 'development') { + // Enable use of Preact Devtools + require('preact/debug') +} + import './index.css' import {h, render} from 'preact' -if (process.env.NODE_ENV === 'development') { - // Enable use of React Developer Tools - require('preact/devtools') -} - -let root function init() { let App = require('./App').default - root = render(<App/>, document.querySelector('#app'), root) + render(<App/>, document.querySelector('#app')) } if (module.hot) { From d556badbba8fdacadf13aab94e6f8fb24c49a48b Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sat, 7 Mar 2020 19:45:06 +1000 Subject: [PATCH 26/66] Update Node version in CONTRIBUTING templates [ci skip] --- templates/inferno-app/CONTRIBUTING.md | 2 +- templates/preact-app/CONTRIBUTING.md | 2 +- templates/react-app/CONTRIBUTING.md | 2 +- templates/react-component/CONTRIBUTING.md | 2 +- templates/web-app/CONTRIBUTING.md | 2 +- templates/web-module/CONTRIBUTING.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/inferno-app/CONTRIBUTING.md b/templates/inferno-app/CONTRIBUTING.md index dd641ced..c259e6ce 100644 --- a/templates/inferno-app/CONTRIBUTING.md +++ b/templates/inferno-app/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Prerequisites -[Node.js](http://nodejs.org/) >= 6 must be installed. +[Node.js](http://nodejs.org/) >= 8 must be installed. ## Installation diff --git a/templates/preact-app/CONTRIBUTING.md b/templates/preact-app/CONTRIBUTING.md index dd641ced..c259e6ce 100644 --- a/templates/preact-app/CONTRIBUTING.md +++ b/templates/preact-app/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Prerequisites -[Node.js](http://nodejs.org/) >= 6 must be installed. +[Node.js](http://nodejs.org/) >= 8 must be installed. ## Installation diff --git a/templates/react-app/CONTRIBUTING.md b/templates/react-app/CONTRIBUTING.md index dd641ced..c259e6ce 100644 --- a/templates/react-app/CONTRIBUTING.md +++ b/templates/react-app/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Prerequisites -[Node.js](http://nodejs.org/) >= 6 must be installed. +[Node.js](http://nodejs.org/) >= 8 must be installed. ## Installation diff --git a/templates/react-component/CONTRIBUTING.md b/templates/react-component/CONTRIBUTING.md index a9b8b42a..4868f267 100644 --- a/templates/react-component/CONTRIBUTING.md +++ b/templates/react-component/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Prerequisites -[Node.js](http://nodejs.org/) >= 6 must be installed. +[Node.js](http://nodejs.org/) >= 8 must be installed. ## Installation diff --git a/templates/web-app/CONTRIBUTING.md b/templates/web-app/CONTRIBUTING.md index 25e7f12d..9dc3f4d7 100644 --- a/templates/web-app/CONTRIBUTING.md +++ b/templates/web-app/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Prerequisites -[Node.js](http://nodejs.org/) >= 6 must be installed. +[Node.js](http://nodejs.org/) >= 8 must be installed. ## Installation diff --git a/templates/web-module/CONTRIBUTING.md b/templates/web-module/CONTRIBUTING.md index e4d0e499..64011920 100644 --- a/templates/web-module/CONTRIBUTING.md +++ b/templates/web-module/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Prerequisites -[Node.js](http://nodejs.org/) >= 6 must be installed. +[Node.js](http://nodejs.org/) >= 8 must be installed. ## Installation From c13e27ef72f93191ab00da3f3bd6c5be5aead3d7 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sat, 7 Mar 2020 19:52:53 +1000 Subject: [PATCH 27/66] Remove some missed mentions of *-test.js from the docs [ci skip] --- docs/Testing.md | 2 +- docs/guides/ReactApps.md | 2 +- docs/guides/ReactComponents.md | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/Testing.md b/docs/Testing.md index 73eeb4f8..1089d5b8 100644 --- a/docs/Testing.md +++ b/docs/Testing.md @@ -46,7 +46,7 @@ import expect from 'expect' #### Test Files -In the project skeletons created by nwb's `new` and `init` commands, the sample unit test is in a `*-test.js` file in the `tests/` directory. +In the project skeletons created by nwb's `new` and `init` commands, the sample unit test is in a `*.test.js` file in the `tests/` directory. However, the default configuration supports having tests in any file which ends with one of the following suffixes, anywhere underneath a `src/`, `test/` or `tests/` directory: diff --git a/docs/guides/ReactApps.md b/docs/guides/ReactApps.md index 842871fa..9a1d94a0 100644 --- a/docs/guides/ReactApps.md +++ b/docs/guides/ReactApps.md @@ -83,7 +83,7 @@ Includes a template for your project's HTML entry point, which will have `<link> > Gist: any file Webpack is configured to deal with (including stylesheets and images) can be imported as if it were a module; Webpack starts from your app's entry module and walks imports to build up a graph of modules to be built. -**tests/**: nwb will find and run tests in a separate `tests/` directory or co-located with your source code under `src/`, as long as their filenames end with `.test.js`, `-test.js` or `.spec.js` - an example of a basic React component test is provided. +**tests/**: nwb will find and run tests in a separate `tests/` directory or co-located with your source code under `src/`, as long as their filenames end with `.test.js` or `.spec.js` - an example of a basic React component test is provided. --- diff --git a/docs/guides/ReactComponents.md b/docs/guides/ReactComponents.md index 9faa88aa..c5058092 100644 --- a/docs/guides/ReactComponents.md +++ b/docs/guides/ReactComponents.md @@ -123,7 +123,7 @@ react-loading-button/ index.js tests/ .eslintrc - index-test.js + index.test.js ``` **demo/**: Contains a React application you can develop your module against using nwb's development server. @@ -134,7 +134,7 @@ react-loading-button/ **src/**: Contains your React module's source. -**tests/**: nwb will find and run tests in a separate `tests/` directory or co-located with your source code under `src/`, as long as their filenames end with `.test.js`, `-test.js` or `.spec.js` - an example of a basic React component test is provided. +**tests/**: nwb will find and run tests in a separate `tests/` directory or co-located with your source code under `src/`, as long as their filenames end with `.test.js` or `.spec.js` - an example of a basic React component test is provided. --- @@ -263,7 +263,7 @@ export default LoadingButton nwb provides a default testing setup which uses Karma to run tests written with Mocha and Expect in the headless PhantomJS browser. -> The [Testing documentation](/docs/Testing.md) provides an in-depth overview of what nwb's default testing setup provides (and how to configure things to your liking if you want to), but we'll stick to editing the initial test provided in the React component project skeleton, in `tests/index-test.js`. +> The [Testing documentation](/docs/Testing.md) provides an in-depth overview of what nwb's default testing setup provides (and how to configure things to your liking if you want to), but we'll stick to editing the initial test provided in the React component project skeleton, in `tests/index.test.js`. `npm run test:watch` automatically re-runs tests on every change to provide a quick feedback loop while developing, whether you're writing tests up-front, in parallel with implementation or after the fact. From 88a3e5249436400b98ab41733824fcfde2c4f18f Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sun, 8 Mar 2020 10:31:11 +1000 Subject: [PATCH 28/66] Fix Inferno Babel config and re-enable the new app test Fix `nwb preact run SomeComponent.js` duplicating an exported component on hot reload --- src/inferno/inferno-preset.js | 2 +- src/preact/renderShim.js | 3 ++- tests/commands/test-test.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/inferno/inferno-preset.js b/src/inferno/inferno-preset.js index d5e999e7..ededafe4 100644 --- a/src/inferno/inferno-preset.js +++ b/src/inferno/inferno-preset.js @@ -1,7 +1,7 @@ module.exports = function() { return { plugins: [ - require.resolve('babel-plugin-syntax-jsx'), + require.resolve('@babel/plugin-syntax-jsx'), require.resolve('babel-plugin-inferno'), ] } diff --git a/src/preact/renderShim.js b/src/preact/renderShim.js index 481f543a..57298ca8 100644 --- a/src/preact/renderShim.js +++ b/src/preact/renderShim.js @@ -8,6 +8,7 @@ if (process.env.NODE_ENV === 'development') { let Preact = require('preact') let parent = document.getElementById(NWB_QUICK_MOUNT_ID) +let root = parent.firstElementChild let vnode = null function renderEntry(exported) { @@ -27,7 +28,7 @@ function renderEntry(exported) { // Assumption: the entry module rendered the app return } - Preact.render(vnode, parent, parent.firstElementChild) + root = Preact.render(vnode, parent, root) } function init() { diff --git a/tests/commands/test-test.js b/tests/commands/test-test.js index 65e5a5bc..238f4910 100644 --- a/tests/commands/test-test.js +++ b/tests/commands/test-test.js @@ -69,7 +69,7 @@ describe('command: test', function() { }) }) - it.skip('successfully tests a new Inferno app', function(done) { + it('successfully tests a new Inferno app', function(done) { cli(['new', 'inferno-app', 'test-app', '-f'], err => { expect(err).toNotExist('No errors creating new Inferno app') process.chdir(path.join(tmpDir, 'test-app')) From f500d245f8d0a4917de3729c038eda871c90e39b Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sun, 8 Mar 2020 19:30:46 +1000 Subject: [PATCH 29/66] Doc tweaks [ci skip] --- CHANGES.md | 14 ++++++++------ docs/Commands.md | 6 +++--- docs/guides/QuickDevelopment.md | 10 +++++----- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 81449b88..c79539ce 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,7 +2,7 @@ ## Breaking Changes -- Node.js 6 is no longer supported; Node.js 8.9.0 is now the minimum required version, as per nwb's dependencies. +- Node.js 6 is no longer supported; Node.js 8.9.0 is now the minimum required version, as per many of nwb's dependencies. - Updated to [Babel 7](https://babeljs.io/blog/2018/08/27/7.0.0) - [`babel.runtime` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#runtime-object--false) no longer accepts a `String` to enable an additional, named feature. @@ -13,9 +13,9 @@ Rename these to `*.test.js` instead. -- Dropped support for old `--no-hmre` alias to disable Hot Module Replacement, just use `--no-hmr` instead. +- Dropped support for the old `--no-hmre` alias to disable Hot Module Replacement, just use `--no-hmr` instead. -- Updated Preact config for Preact X +- Updated Preact config for [Preact X](https://preactjs.com/guide/v10/whats-new). - Dependencies with (documented) breaking changes: - [copy-webpack-plugin@5.0.0](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#breaking-changes) @@ -37,15 +37,17 @@ - [React Refresh Webpack Plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin) is now used to enable [Fast Refresh](https://github.com/facebook/react/issues/16604#issuecomment-528663101) for React apps, as babel-plugin-react-transform is deprecated and doesn't support Babel 7. - Replaced use of `UglifyJsPlugin` with `TerserWebpackPlugin`. - - Deprecated `webpack.uglify` config, which has been renamed to [`webpack.terser`](https://github.com/insin/nwb/blob/master/docs/Configuration.md#terser-object--false). -- Autoprefixer renamed its `browsers` option to `overrideBrowserslist`, so you will get deprecation warnings if you were using `{browsers: ...}` in [`webpack.autoprefixer` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#autoprefixer-string--object). ## Deprecated -- `babel.stage` config is deprecated, as Babel's `stage-X` presets were/are being removed in Babel 7 - if you provide it, nwb will warn you and enable Babel proposal plugins equivalent to the current stage they're at. +- Deprecated `babel.stage` config, as Babel's `stage-X` presets were/are being removed in Babel 7 - if you provide it, nwb will warn you and enable Babel proposal plugins equivalent to the current stage they're at. Use [`babel.proposals` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#proposals-object--false) instead if you want to toggle some or all additional proposal plugins on. +- Deprecated `webpack.uglify` config, which has been renamed to [`webpack.terser`](https://github.com/insin/nwb/blob/master/docs/Configuration.md#terser-object--false). + +- Autoprefixer renamed its `browsers` option to `overrideBrowserslist`, so you will get deprecation warnings if you were using `{browsers: ...}` in [`webpack.autoprefixer` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#autoprefixer-string--object). + ## Dependencies - autoprefixer: v9.0.2 → [v9.7.4](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#974) diff --git a/docs/Commands.md b/docs/Commands.md index c1deeb0c..f3188407 100644 --- a/docs/Commands.md +++ b/docs/Commands.md @@ -27,7 +27,7 @@ Installing nwb provides the following commands: - [Project Type-specific Commands](#project-type-specific-commands) - [`nwb check-config`](#nwb-check-config-command) -- [`nwb react`, `nwb inferno`, `nwb preact` and `nwb web`](#nwb-react-nwb-inferno-and-nwb-preact) - quick development +- [`nwb react`, `nwb inferno`, `nwb preact` and `nwb web`](#nwb-react-nwb-inferno-and-nwb-preact) - quick development commands - See the [Quick Development with nwb](/docs/guides/QuickDevelopment.md#quick-development-with-nwb) guide ## `nwb` @@ -227,9 +227,9 @@ Disable creation of `vendor.js` and `vendor.css` files for dependencies imported #### React app builds -In production mode builds, the Babel [react-remove-prop-types](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types) transform will be used. +In production mode builds, the Babel [`react-remove-prop-types`](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types) transform will be used. -When building React apps, you can also pass a `--preact` flag to configure Webpack to use [Preact](https://preactjs.com/) via the [`preact-compat`](https://github.com/developit/preact-compat#readme) module, or an `--inferno` flag to configure Webpack to use [Inferno](https://infernojs.org/) via the [`inferno-compat`](https://github.com/infernojs/inferno/tree/master/packages/inferno-compat#readme) module. +When building React apps, you can also pass a `--preact` flag to configure Webpack to use [Preact](https://preactjs.com/) via [`preact/compat`](https://preactjs.com/guide/v10/switching-to-preact) module, or an `--inferno` flag to configure Webpack to use [Inferno](https://infernojs.org/) via the [`inferno-compat`](https://github.com/infernojs/inferno/tree/master/packages/inferno-compat#readme) module. If your app and its dependencies are compatible, this can be a quick and easy way to reduce the size of your app. diff --git a/docs/guides/QuickDevelopment.md b/docs/guides/QuickDevelopment.md index ec5cf45e..6d0df7a4 100644 --- a/docs/guides/QuickDevelopment.md +++ b/docs/guides/QuickDevelopment.md @@ -51,7 +51,7 @@ To serve this for development use `nwb preact run`, which will install essential ```sh $ nwb preact run Lightbulb.js -✔ Installing preact and preact-compat +✔ Installing preact Starting Webpack compilation... Compiled successfully in 3717 ms. @@ -233,7 +233,7 @@ Inferno and Preact both provide compatibility layers which simulate React APIs a #### React Compatible Builds with `--inferno` or `--preact` -To try this out with some React code you've written, you can pass an `--inferno` flag for a build which uses [`inferno-compat`](https://infernojs.org/docs/guides/switching-to-inferno) or a `--preact` flag for a build which uses [`preact-compat`](https://preactjs.com/guide/switching-to-preact). +To try this out with some React code you've written, you can pass an `--inferno` flag for a build which uses [`inferno-compat`](https://infernojs.org/docs/guides/switching-to-inferno) or a `--preact` flag for a build which uses [`preact/compat`](https://preactjs.com/guide/v10/switching-to-preact) . If your code is compatible, these builds offer an easy way to take a large chunk off the size of the final bundle, and may even provide a performance boost. @@ -247,7 +247,7 @@ File size after gzip: ``` ```sh $ nwb react build hello.js --preact -✔ Installing preact and preact-compat +✔ Installing preact ✔ Cleaning app ✔ Building Preact (React compat) app @@ -312,7 +312,7 @@ export default <div> ``` ```sh $ nwb inferno run idea.js -✔ Installing inferno, inferno-component and inferno-compat +✔ Installing inferno, inferno-compat, inferno-clone-vnode, inferno-create-class and inferno-create-element Starting Webpack compilation... Compiled successfully in 3595 ms. @@ -348,7 +348,7 @@ When the rendering shim detects that one of these has been exported from the pro #### React Rendering Shim -`nwb react run`'s configuration uses [React Refresh Webpack Plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin/#react-refresh-webpack-plugin) to enable Fast Refresh for React components. +`nwb react run`'s configuration uses [React Refresh Webpack Plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin/#react-refresh-webpack-plugin) to enable [Fast Refresh](https://github.com/facebook/react/issues/16604#issuecomment-528663101) for React components. > To disable this, pass a `--no-hmr` flag. From ae2b06a8895835529dd1c33f089db3a9619fd8b3 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sun, 8 Mar 2020 19:42:02 +1000 Subject: [PATCH 30/66] Don't ask a question about React compatibility when creating a Preact app, as preact/compat is now always available --- CHANGES.md | 1 + src/preact/index.js | 13 +++---------- src/react/index.js | 5 +---- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index c79539ce..f10cda49 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -37,6 +37,7 @@ - [React Refresh Webpack Plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin) is now used to enable [Fast Refresh](https://github.com/facebook/react/issues/16604#issuecomment-528663101) for React apps, as babel-plugin-react-transform is deprecated and doesn't support Babel 7. - Replaced use of `UglifyJsPlugin` with `TerserWebpackPlugin`. +- React compatibility is now always configured for Preact apps, as `preact/compat` is now part of the `preact` module. ## Deprecated diff --git a/src/preact/index.js b/src/preact/index.js index ac7febda..6479cb8a 100644 --- a/src/preact/index.js +++ b/src/preact/index.js @@ -35,20 +35,13 @@ function getQuickConfig() { export default (args: Object) => ({ getName: () => 'Preact', getProjectDefaults() { - return {compat: false} + return {} }, - getProjectDependencies(answers: Object): string[] { + getProjectDependencies(): string[] { return getDependencies() }, getProjectQuestions() { - let defaults = this.getProjectDefaults() - return [{ - when: () => !('compat' in args), - type: 'confirm', - name: 'compat', - message: 'Do you want to use preact/compat so you can use React modules?', - default: defaults.compat, - }] + return null }, getBuildDependencies: () => [], getBuildConfig: getBaseConfig, diff --git a/src/react/index.js b/src/react/index.js index 4b9244a7..176c504e 100644 --- a/src/react/index.js +++ b/src/react/index.js @@ -38,10 +38,7 @@ function getBuildConfig(args, options: {useModulePath?: boolean} = {}) { } } else if (args.preact || args['preact-compat']) { - // Use the path to preact/compat's CommonJS build to avoid picking up the - // ES modules build, which prevents hijacking the render() function in the - // render shim. - let preactCompathPath = path.join(aliasPath('preact'), 'compat/dist/compat') + let preactCompathPath = path.join(aliasPath('preact'), 'compat') config.resolve = { alias: { 'react': preactCompathPath, From ae86f9ec3115151b5bbe665fdb377ef3f9232878 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sun, 8 Mar 2020 19:48:31 +1000 Subject: [PATCH 31/66] Release v0.24.0 --- CHANGES.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f10cda49..4a40a536 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,4 @@ -# Unreleased (in `master`) +# 0.24.0 / 2020-03-08 ♀️ ## Breaking Changes diff --git a/package.json b/package.json index f2d71314..085d14f8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nwb", "description": "A toolkit for React, Preact & Inferno apps, React libraries and other npm modules for the web, with no configuration (until you need it)", - "version": "0.23.0", + "version": "0.24.0", "license": "MIT", "author": "Jonny Buchanan <jonathan.buchanan@gmail.com>", "bin": { From 86df4abd77ab448728ea4b1d928bf55d68c521eb Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Wed, 11 Mar 2020 21:55:58 +1000 Subject: [PATCH 32/66] Fixed serving the demo app for React components Also fixed Fast Refresh for the default React component demo app by exporting the Demo component in the template Closes #542 --- CHANGES.md | 5 +++++ src/commands/serve-react-demo.js | 2 +- templates/react-component/demo/src/index.js | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4a40a536..1b158175 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +## Fixed + +- Fixed serving the demo app for a React component. +- Fixed Fast Refresh for the default React component demo app by exporting the `Demo` component in the template. + # 0.24.0 / 2020-03-08 ♀️ ## Breaking Changes diff --git a/src/commands/serve-react-demo.js b/src/commands/serve-react-demo.js index e0535482..86fe0090 100644 --- a/src/commands/serve-react-demo.js +++ b/src/commands/serve-react-demo.js @@ -34,7 +34,7 @@ export default function serveReactDemo(args, cb) { if (args.hmr !== false) { config.babel.plugins = [require.resolve('react-refresh/babel')] - config.plugins = {reactRefresh: true} + config.plugins.reactRefresh = true } if (directoryExists('demo/public')) { diff --git a/templates/react-component/demo/src/index.js b/templates/react-component/demo/src/index.js index 8fdbeb4f..0b4519b2 100644 --- a/templates/react-component/demo/src/index.js +++ b/templates/react-component/demo/src/index.js @@ -3,7 +3,7 @@ import {render} from 'react-dom' import Example from '../../src' -class Demo extends Component { +export default class Demo extends Component { render() { return <div> <h1>{{name}} Demo</h1> From 9c13da8f99407a6791ee07902ed0861c337b7552 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Wed, 11 Mar 2020 21:56:26 +1000 Subject: [PATCH 33/66] Release v0.24.1 --- CHANGES.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 1b158175..7f63dedc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,5 @@ +# 0.24.1 / 2020-03-11 + ## Fixed - Fixed serving the demo app for a React component. diff --git a/package.json b/package.json index 085d14f8..0eace1dd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nwb", "description": "A toolkit for React, Preact & Inferno apps, React libraries and other npm modules for the web, with no configuration (until you need it)", - "version": "0.24.0", + "version": "0.24.1", "license": "MIT", "author": "Jonny Buchanan <jonathan.buchanan@gmail.com>", "bin": { From a88418b313e79b495cbd1e8b2846a91f24b2bdf5 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Thu, 12 Mar 2020 02:24:13 +1000 Subject: [PATCH 34/66] Fix copying of co-located test files when building a React component or web module Fixes #529 --- CHANGES.md | 8 +++++++- src/moduleBuild.js | 2 +- .../src/components/Thing.spec.js | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 tests/fixtures/projects/react-component-with-css/src/components/Thing.spec.js diff --git a/CHANGES.md b/CHANGES.md index 7f63dedc..f85ec66d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,14 @@ +# Unreleased (in `master`) + +## Fixed + +- Fixed copying of co-located `.test.js`/`.spec.js` files when building a React component or web module by also passing the new `--no-copy-ignored` flag when calling @babel/cli [[#529](https://github.com/insin/nwb/pull/529)] + # 0.24.1 / 2020-03-11 ## Fixed -- Fixed serving the demo app for a React component. +- Fixed serving the demo app for a React component [[#542](https://github.com/insin/nwb/pull/542)] - Fixed Fast Refresh for the default React component demo app by exporting the `Demo` component in the template. # 0.24.0 / 2020-03-08 ♀️ diff --git a/src/moduleBuild.js b/src/moduleBuild.js index f4681859..c530b1a6 100644 --- a/src/moduleBuild.js +++ b/src/moduleBuild.js @@ -34,7 +34,7 @@ function runBabel(name, {copyFiles, outDir, src}, buildBabelConfig, userConfig, let args = [src, '--out-dir', outDir, '--quiet'] if (copyFiles) { - args.push('--copy-files') + args.push('--copy-files', '--no-copy-ignored') } fs.writeFile('.babelrc', JSON.stringify(babelConfig, null, 2), (err) => { diff --git a/tests/fixtures/projects/react-component-with-css/src/components/Thing.spec.js b/tests/fixtures/projects/react-component-with-css/src/components/Thing.spec.js new file mode 100644 index 00000000..df327826 --- /dev/null +++ b/tests/fixtures/projects/react-component-with-css/src/components/Thing.spec.js @@ -0,0 +1,14 @@ +import expect from 'expect' +import React from 'react' +import {render} from 'react-dom' + +import Thing from './Thing' + +describe('Thing', () => { + it('displays a Thing', () => { + let node = document.createElement('div') + render(<Thing/>, node, () => { + expect(node.innerHTML).toContain('<div class="Thing">') + }) + }) +}) From 709701e3864c503ed9395da5444bc2cd9d68e98e Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Thu, 12 Mar 2020 09:10:14 +1000 Subject: [PATCH 35/66] Update dependencies --- CHANGES.md | 6 ++++++ package.json | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f85ec66d..44f2ed03 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,12 @@ - Fixed copying of co-located `.test.js`/`.spec.js` files when building a React component or web module by also passing the new `--no-copy-ignored` flag when calling @babel/cli [[#529](https://github.com/insin/nwb/pull/529)] +## Dependencies + +- inquirer: v7.0.6 → [v7.1.0](https://github.com/SBoudrias/Inquirer.js/compare/inquirer@7.0.6...inquirer@7.1.0) +- minimist v1.2.0 → [v1.2.4](https://github.com/substack/minimist/compare/1.2.0...1.2.4) - security fix +- open: v7.0.2 → [v7.0.3](https://github.com/sindresorhus/open/releases/tag/v7.0.3) + # 0.24.1 / 2020-03-11 ## Fixed diff --git a/package.json b/package.json index 0eace1dd..ae9a0433 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,8 @@ "filesize": "6.1.0", "fs-extra": "8.1.0", "gzip-size": "5.1.1", - "inquirer": "7.0.6", - "minimist": "1.2.0", + "inquirer": "7.1.0", + "minimist": "1.2.4", "ora": "4.0.3", "resolve": "1.15.1", "run-series": "1.1.8", @@ -95,7 +95,7 @@ "html-webpack-plugin": "3.2.0", "mini-css-extract-plugin": "0.9.0", "@insin/npm-install-webpack-plugin": "5.0.0", - "open": "7.0.2", + "open": "7.0.3", "postcss-loader": "3.0.0", "style-loader": "1.1.3", "terser-webpack-plugin": "2.3.5", From 02d565aefb26ad7cea42c124820d8bfd634588b6 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Thu, 12 Mar 2020 10:49:31 +1000 Subject: [PATCH 36/66] Release v0.24.2 --- CHANGES.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 44f2ed03..862c23fc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,4 @@ -# Unreleased (in `master`) +# 0.24.2 / 2020-03-12 ## Fixed diff --git a/package.json b/package.json index ae9a0433..d2e0ab96 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nwb", "description": "A toolkit for React, Preact & Inferno apps, React libraries and other npm modules for the web, with no configuration (until you need it)", - "version": "0.24.1", + "version": "0.24.2", "license": "MIT", "author": "Jonny Buchanan <jonathan.buchanan@gmail.com>", "bin": { From 63a1eb56beb21309a0f861dc7d22ebbbc853b6cb Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Thu, 12 Mar 2020 11:10:54 +1000 Subject: [PATCH 37/66] Bypass Webpack Dev Server startup info logging which ignores the quiet option --- CHANGES.md | 6 ++++++ src/devServer.js | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 862c23fc..ec4de538 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +# Unreleased (in `master`) + +## Changed + +- Added a temporary hack to bypass [startup info logging](https://github.com/webpack/webpack-dev-server/blob/50c09a4b64c013cca0acb6013bdaa28d0f342149/lib/utils/status.js#L9-L16) Webpack Dev Server currently does even when its `quiet` option is set. + # 0.24.2 / 2020-03-12 ## Fixed diff --git a/src/devServer.js b/src/devServer.js index 0ce39fb7..187cd7b5 100644 --- a/src/devServer.js +++ b/src/devServer.js @@ -34,7 +34,13 @@ export default function devServer(webpackConfig, serverConfig, url, cb) { debug('webpack dev server options: %s', deepToString(webpackDevServerOptions)) let server = new WebpackDevServer(compiler, webpackDevServerOptions) + + // XXX Temporarily replace console.info() to prevent WDS startup logging which + // is explicitly done at the info level when the quiet option is set. + let info = console.info + console.info = () => {} server.listen(port, host, (err) => { + console.info = info if (err) return cb(err) if (open) { // --open From 7677f400ab57fa0001d43c3a6503cb0e49a2c837 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Fri, 13 Mar 2020 01:19:42 +1000 Subject: [PATCH 38/66] Re-enable CSS minification Closes #467 --- CHANGES.md | 3 ++- flow-typed/libdefs.js | 1 + package.json | 1 + src/createWebpackConfig.js | 16 ++++++++++++---- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index ec4de538..6b6f0ef0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,12 +3,13 @@ ## Changed - Added a temporary hack to bypass [startup info logging](https://github.com/webpack/webpack-dev-server/blob/50c09a4b64c013cca0acb6013bdaa28d0f342149/lib/utils/status.js#L9-L16) Webpack Dev Server currently does even when its `quiet` option is set. +- CSS minification hasn't been enabled since nwb v0.23.0 as css-loader v1.0.0 stopped doing it by default - re-enable it using [Optimize CSS Assets Webpack Plugin](https://github.com/NMFR/optimize-css-assets-webpack-plugin) [[#467](https://github.com/insin/nwb/issues/467)] # 0.24.2 / 2020-03-12 ## Fixed -- Fixed copying of co-located `.test.js`/`.spec.js` files when building a React component or web module by also passing the new `--no-copy-ignored` flag when calling @babel/cli [[#529](https://github.com/insin/nwb/pull/529)] +- Fixed copying of co-located `.test.js`/`.spec.js` files when building a React component or web module by also passing the new `--no-copy-ignored` flag when calling @babel/cli [[#529](https://github.com/insin/nwb/issues/529)] ## Dependencies diff --git a/flow-typed/libdefs.js b/flow-typed/libdefs.js index 80ed1568..96c23ac6 100644 --- a/flow-typed/libdefs.js +++ b/flow-typed/libdefs.js @@ -8,6 +8,7 @@ declare module 'fs-extra' { declare module.exports: any; } declare module 'html-webpack-plugin' { declare module.exports: any; } declare module 'mini-css-extract-plugin' { declare module.exports: any; } declare module '@insin/npm-install-webpack-plugin' { declare module.exports: any; } +declare module 'optimize-css-assets-webpack-plugin' { declare module.exports: any; } declare module 'ora' { declare module.exports: any; } declare module 'resolve' { declare module.exports: any; } declare module 'terser-webpack-plugin' { declare module.exports: any; } diff --git a/package.json b/package.json index d2e0ab96..4c86f917 100644 --- a/package.json +++ b/package.json @@ -95,6 +95,7 @@ "html-webpack-plugin": "3.2.0", "mini-css-extract-plugin": "0.9.0", "@insin/npm-install-webpack-plugin": "5.0.0", + "optimize-css-assets-webpack-plugin": "5.0.3", "open": "7.0.3", "postcss-loader": "3.0.0", "style-loader": "1.1.3", diff --git a/src/createWebpackConfig.js b/src/createWebpackConfig.js index c9cdb94d..4a4a78a7 100644 --- a/src/createWebpackConfig.js +++ b/src/createWebpackConfig.js @@ -536,13 +536,21 @@ export function createPlugins( })) optimization.minimize = buildConfig.terser !== false && userConfig.terser !== false if (buildConfig.terser !== false && userConfig.terser !== false) { - optimization.minimizer = [{ - apply(compiler: any) { - // Lazy load the terser plugin + optimization.minimizer = [ + (compiler: any) => { let TerserPlugin = require('terser-webpack-plugin') + let OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin') new TerserPlugin(createTerserConfig(userConfig)).apply(compiler) + new OptimizeCSSAssetsPlugin({ + cssProcessorOptions: { + map: { + inline: false, + annotation: true, + } + } + }).apply(compiler) } - }] + ] } } From 12e11e1c2e69b0f91569c30e06643a6080195f72 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sat, 14 Mar 2020 01:19:40 +1000 Subject: [PATCH 39/66] Update dependencies --- CHANGES.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 6b6f0ef0..1483a27b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,10 @@ - Added a temporary hack to bypass [startup info logging](https://github.com/webpack/webpack-dev-server/blob/50c09a4b64c013cca0acb6013bdaa28d0f342149/lib/utils/status.js#L9-L16) Webpack Dev Server currently does even when its `quiet` option is set. - CSS minification hasn't been enabled since nwb v0.23.0 as css-loader v1.0.0 stopped doing it by default - re-enable it using [Optimize CSS Assets Webpack Plugin](https://github.com/NMFR/optimize-css-assets-webpack-plugin) [[#467](https://github.com/insin/nwb/issues/467)] +## Dependencies + +- minimist v1.2.4 → v1.2.5 + # 0.24.2 / 2020-03-12 ## Fixed diff --git a/package.json b/package.json index 4c86f917..a17ee520 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "fs-extra": "8.1.0", "gzip-size": "5.1.1", "inquirer": "7.1.0", - "minimist": "1.2.4", + "minimist": "1.2.5", "ora": "4.0.3", "resolve": "1.15.1", "run-series": "1.1.8", From 5923e47dacef61af4e86ac0da4ff37cf88ec69a4 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sat, 14 Mar 2020 01:19:52 +1000 Subject: [PATCH 40/66] Update flow --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a17ee520..67befb08 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,7 @@ "cross-env": "7.0.2", "eslint-config-jonnybuchanan": "6.0.0", "eventsource": "1.0.7", - "flow-bin": "0.82.0", + "flow-bin": "0.120.1", "glob": "7.1.6", "nyc": "15.0.0", "rimraf": "3.0.2", From 92db10e91fb6fdd6c565a1593b9ab0a3116ace5a Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sat, 14 Mar 2020 01:29:45 +1000 Subject: [PATCH 41/66] Release v0.24.3 --- CHANGES.md | 3 ++- package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 1483a27b..0e16d345 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,4 @@ -# Unreleased (in `master`) +# 0.24.3 / 2020-03-14 ## Changed @@ -8,6 +8,7 @@ ## Dependencies - minimist v1.2.4 → v1.2.5 +- optimize-css-assets-webpack-plugin v5.0.3 # 0.24.2 / 2020-03-12 diff --git a/package.json b/package.json index 67befb08..cfb9747a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nwb", "description": "A toolkit for React, Preact & Inferno apps, React libraries and other npm modules for the web, with no configuration (until you need it)", - "version": "0.24.2", + "version": "0.24.3", "license": "MIT", "author": "Jonny Buchanan <jonathan.buchanan@gmail.com>", "bin": { From 44297ea2ebcc56380750e83e6edccf6443cd3734 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sat, 14 Mar 2020 01:48:02 +1000 Subject: [PATCH 42/66] Remove babel7 branch from Travis config --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 12e6906e..fc5c8868 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,4 +24,3 @@ branches: only: - master - next - - babel7 From c69e2bad890cf10ded491e64b2cc8ebaa54da669 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Mon, 16 Mar 2020 20:35:55 +1000 Subject: [PATCH 43/66] Verify that the entry module argument for quick commands exists, to avoid a confusing error message Fixes #441 --- CHANGES.md | 6 ++++++ src/quickCommands.js | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 0e16d345..949166d2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +# Unreleased (in `master`) + +## Changed + +- Validate that the entry module for quick commands (`nwb react`, `nwb preact`, `nwb inferno`) exists, to avoid a confusing error message [[#441](https://github.com/insin/nwb/issues/441)] + # 0.24.3 / 2020-03-14 ## Changed diff --git a/src/quickCommands.js b/src/quickCommands.js index fd5869a6..1371c354 100644 --- a/src/quickCommands.js +++ b/src/quickCommands.js @@ -1,4 +1,5 @@ // @flow +import fs from 'fs' import path from 'path' import runSeries from 'run-series' @@ -40,6 +41,9 @@ export function build(args: Object, appConfig: QuickAppConfig, cb: ErrBack) { if (args._.length === 1) { return cb(new UserError('An entry module must be specified.')) } + if (!fs.existsSync(args._[1])) { + return cb(new UserError(`${args._[1]} does not exist.`)) + } let dist = args._[2] || 'dist' @@ -187,6 +191,9 @@ export function serve(args: Object, appConfig: QuickAppConfig, cb: ErrBack) { if (args._.length === 1) { return cb(new UserError('An entry module must be specified.')) } + if (!fs.existsSync(args._[1])) { + return cb(new UserError(`${args._[1]} does not exist.`)) + } runSeries([ (cb) => install(appConfig.getQuickDependencies(), {args, check: true}, cb), From d3e35eb185e163a5181b327e68135a5ac5045456 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sat, 21 Mar 2020 14:57:10 +1000 Subject: [PATCH 44/66] Update dependencies --- CHANGES.md | 14 ++++++++++++++ package.json | 26 +++++++++++++------------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 949166d2..90f6cc1a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,8 +2,22 @@ ## Changed +- Updated to [Babel v7.9.0](https://babeljs.io/blog/2020/03/16/7.9.0). - Validate that the entry module for quick commands (`nwb react`, `nwb preact`, `nwb inferno`) exists, to avoid a confusing error message [[#441](https://github.com/insin/nwb/issues/441)] +## Dependencies + +- @babel/core: v7.8.7 → v7.9.0 +- @babel/plugin-transform-react-constant-elements: v7.8.3 → v7.9.0 +- @babel/plugin-transform-react-jsx: v7.8.3 → v7.9.1 +- @babel/plugin-transform-runtime: v7.8.3 → v7.9.0 +- @babel/preset-env: v7.8.7 → v7.9.0 +- @babel/preset-react: v7.8.3 → v7.9.1 +- @babel/runtime: v7.8.7 → v7.9.0 +- babel-loader: v8.0.6 → [v8.1.0](https://github.com/babel/babel-loader/releases/tag/v8.1.0) +- mocha: v7.1.0 → [v7.1.1](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#711--2020-03-18) +- react-refresh: v0.8.0 → v0.8.1 + # 0.24.3 / 2020-03-14 ## Changed diff --git a/package.json b/package.json index cfb9747a..6efc19a3 100644 --- a/package.json +++ b/package.json @@ -47,16 +47,16 @@ "webpack-merge": "4.2.2", "@babel/cli": "7.8.4", - "@babel/core": "7.8.7", + "@babel/core": "7.9.0", "@babel/plugin-syntax-dynamic-import": "7.8.3", "@babel/plugin-syntax-jsx": "7.8.3", - "@babel/plugin-transform-react-constant-elements": "7.8.3", - "@babel/plugin-transform-react-jsx": "7.8.3", - "@babel/plugin-transform-runtime": "7.8.3", + "@babel/plugin-transform-react-constant-elements": "7.9.0", + "@babel/plugin-transform-react-jsx": "7.9.1", + "@babel/plugin-transform-runtime": "7.9.0", "@babel/polyfill": "7.8.7", - "@babel/preset-env": "7.8.7", - "@babel/preset-react": "7.8.3", - "@babel/runtime": "7.8.7", + "@babel/preset-env": "7.9.0", + "@babel/preset-react": "7.9.1", + "@babel/runtime": "7.9.0", "@pmmmwh/react-refresh-webpack-plugin": "0.2.0", "babel-plugin-add-module-exports": "1.0.2", "babel-plugin-inferno": "6.1.0", @@ -65,7 +65,7 @@ "babel-plugin-transform-decorators-legacy": "1.3.5", "babel-plugin-transform-react-remove-prop-types": "0.4.24", "babel-preset-proposals": "0.3.0", - "react-refresh": "0.8.0", + "react-refresh": "0.8.1", "karma": "4.4.1", "karma-chrome-launcher": "3.1.0", @@ -77,7 +77,7 @@ "karma-webpack": "4.0.2", "phantomjs-prebuilt": "2.1.16", - "mocha": "7.1.0", + "mocha": "7.1.1", "expect": "1.20.2", "object-assign": "4.1.1", @@ -86,7 +86,7 @@ "webpack": "4.42.0", "autoprefixer": "9.7.4", - "babel-loader": "8.0.6", + "babel-loader": "8.1.0", "case-sensitive-paths-webpack-plugin": "2.3.0", "copy-webpack-plugin": "5.1.1", "css-loader": "3.4.2", @@ -106,12 +106,12 @@ "webpack-hot-middleware": "2.25.0" }, "devDependencies": { - "@babel/preset-flow": "7.8.3", - "@babel/register": "7.8.6", + "@babel/preset-flow": "7.9.0", + "@babel/register": "7.9.0", "cross-env": "7.0.2", "eslint-config-jonnybuchanan": "6.0.0", "eventsource": "1.0.7", - "flow-bin": "0.120.1", + "flow-bin": "0.121.0", "glob": "7.1.6", "nyc": "15.0.0", "rimraf": "3.0.2", From ff91570e150c85b8616c496faa4fdcbdfc177870 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sat, 21 Mar 2020 23:03:35 +1000 Subject: [PATCH 45/66] Add babel.react config to configure @babel/preset-react options so you can try the new automatic runtime with the experimental version of React --- .editorconfig | 1 + CHANGES.md | 16 +++++++++++++- docs/Configuration.md | 31 +++++++++++++++++++++++++-- src/commands/build-demo.js | 2 +- src/commands/build-react-component.js | 2 +- src/commands/serve-react-demo.js | 4 +--- src/config/babel.js | 16 ++++++++++++++ src/createBabelConfig.js | 12 ++++++++++- src/react/index.js | 5 ++--- tests/config-test.js | 13 +++++++++++ tests/createBabelConfig-test.js | 18 +++++++++++++++- 11 files changed, 107 insertions(+), 13 deletions(-) diff --git a/.editorconfig b/.editorconfig index b603b5c3..443ca8e6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,3 +8,4 @@ end_of_line = lf insert_final_newline = true indent_style = space indent_size = 2 +trim_trailing_whitespace=true diff --git a/CHANGES.md b/CHANGES.md index 90f6cc1a..94122f31 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,9 +1,23 @@ # Unreleased (in `master`) +## Added + +- Added [`babel.react` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#react-string--object) to configure `@babel/preset-react` options, allowing you to opt-in to using the [new `automatic` runtime](https://reactjs.org/blog/2019/10/22/react-release-channels.html#experimental-channel) which was added in Babel v7.9.0. + + For convenience, you can just configure the runtime name if you want to try it with the [experimental version of React](https://reactjs.org/blog/2019/10/22/react-release-channels.html#experimental-channel): + + ```js + module.exports = { + babel: { + react: 'automatic' + } + } + ``` + ## Changed - Updated to [Babel v7.9.0](https://babeljs.io/blog/2020/03/16/7.9.0). -- Validate that the entry module for quick commands (`nwb react`, `nwb preact`, `nwb inferno`) exists, to avoid a confusing error message [[#441](https://github.com/insin/nwb/issues/441)] +- Validate that the entry module for quick commands (e.g. `nwb react run SomeComponent.js`) exists, to avoid a confusing error message [[#441](https://github.com/insin/nwb/issues/441)] ## Dependencies diff --git a/docs/Configuration.md b/docs/Configuration.md index a915848b..4bb36094 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -78,6 +78,7 @@ The configuration object can include the following properties: - [`babel.presets`](#presets-string--array) - extra Babel presets to be used - [`babel.proposals`](#proposals-object--false) - configure or disable use of `babel-preset-proposals` - [`babel.removePropTypes`](#removeproptypes-object--false) - configure or disable removal of React component `propTypes` in production builds + - [`babel.react`](#react-string--object) - configure the Babel `react` preset - [`babel.reactConstantElements`](#reactconstantelements-false) - disable use of React constant element hoisting in production builds - [`babel.runtime`](#runtime-object--false) - configure or disable the Babel `transform-runtime` plugin - [`babel.stage`](#stage-number--false) - control which experimental and upcoming JavaScript features can be used @@ -193,7 +194,7 @@ This is implemented using [babel-plugin-lodash](https://github.com/lodash/babel- ##### `env`: `Object` -Additional [options for `@babel/preset-env`](https://babeljs.io/docs/en/next/babel-preset-env#options) - nwb uses `@babel/preset-env` to transpile ECMAScript features which aren't natively available in all browsers yet. +Additional [options for `@babel/preset-env`](https://babeljs.io/docs/en/babel-preset-env#options) - nwb uses `@babel/preset-env` to transpile ECMAScript features which aren't natively available in all browsers yet. ##### `loose`: `Boolean` @@ -317,6 +318,32 @@ module.exports = { } ``` +##### `react`: `String | Object` + +*added in v0.24.4* + +Configure [options for Babel's `@babel/preset-react` preset](https://babeljs.io/docs/en/babel-preset-react#options). + +In addition to the existing `classic` mode, Babel v7.9.0 added [a new `automatic` JSX transform](https://babeljs.io/blog/2020/03/16/7.9.0#a-new-jsx-transform-11154-https-githubcom-babel-babel-pull-11154) to this preset, which: + +- **currently requires the [experimental version of React](https://reactjs.org/blog/2019/10/22/react-release-channels.html#experimental-channel)** +- uses new functions for instantiating JSX elements, which will allow optimizing them better in the future. +- automatically imports the functions that JSX transpiles to. + +If you just want to enable the new transform, you can use a String to specify the new `'automatic'` runtime: + +```js +module.exports = { + babel: { + react: 'automatic' + } +} +``` + +Use an Object if you need to configure any of the preset's other options. + +> **Note:** The preset's `development` option is automatically set for you depending on whether or not you're running a production build, no matter which runtime you use. + ##### `reactConstantElements`: `false` Set this to `false` to disable use of the [React constant element hoisting transform](https://babeljs.io/docs/plugins/transform-react-constant-elements/) in React app production builds. @@ -325,7 +352,7 @@ Set this to `false` to disable use of the [React constant element hoisting trans *changed in v0.24.0 - now only takes an `Object` to tweak config* -Configure options for Babel's [runtime transform plugin](https://babeljs.io/docs/en/next/babel-plugin-transform-runtime.html), which by default imports helper modules from `@babel/runtime/helpers` instead of duplicating helper code at the top of every module which needs it, and imports the regenerator runtime from `@babel/runtime/regenerator` required to use `async`/`await` or generators when needed. +Configure options for Babel's [runtime transform plugin](https://babeljs.io/docs/en/babel-plugin-transform-runtime), which by default imports helper modules from `@babel/runtime/helpers` instead of duplicating helper code at the top of every module which needs it, and imports the regenerator runtime from `@babel/runtime/regenerator` required to use `async`/`await` or generators when needed. > **Note:** if you use `async`/`await` or generators in a React Component or Web Module project and are transpiling it to ES5 for publishing (which is the default), you will need to add `@babel/runtime` to your package.json `peerDependencies` to ensure it can be resolved when somebody else uses your module from npm. diff --git a/src/commands/build-demo.js b/src/commands/build-demo.js index 4e38b537..da71e8c4 100644 --- a/src/commands/build-demo.js +++ b/src/commands/build-demo.js @@ -15,7 +15,7 @@ function getCommandConfig(args) { let config = { babel: { - presets: [require.resolve('@babel/preset-react')], + presets: ['react'], }, devtool: 'source-map', entry: { diff --git a/src/commands/build-react-component.js b/src/commands/build-react-component.js index a5f89171..bdfe962b 100644 --- a/src/commands/build-react-component.js +++ b/src/commands/build-react-component.js @@ -11,7 +11,7 @@ import buildDemo from './build-demo' export default function buildModule(args, cb) { let config = { babel: { - presets: [require.resolve('@babel/preset-react')], + presets: ['react'], runtime: { helpers: false } diff --git a/src/commands/serve-react-demo.js b/src/commands/serve-react-demo.js index 86fe0090..85934eb6 100644 --- a/src/commands/serve-react-demo.js +++ b/src/commands/serve-react-demo.js @@ -13,9 +13,7 @@ export default function serveReactDemo(args, cb) { let config = { babel: { - presets: [ - [require.resolve('@babel/preset-react'), {development: true}] - ], + presets: ['react'], }, entry: [path.resolve('demo/src/index.js')], output: { diff --git a/src/config/babel.js b/src/config/babel.js index d56c7e9e..d6236b67 100644 --- a/src/config/babel.js +++ b/src/config/babel.js @@ -42,6 +42,7 @@ export function processBabelConfig({report, userConfig}) { presets, proposals, removePropTypes, + react, reactConstantElements, runtime, stage, @@ -150,6 +151,21 @@ export function processBabelConfig({report, userConfig}) { } } + // react + if ('react' in userConfig.babel) { + if (typeOf(react) === 'string') { + userConfig.babel.react = {runtime: react} + } + else if (typeOf(react) !== 'object') { + report.error( + `babel.react`, + react, + `Must be an ${chalk.cyan('Object')} (to configure @babel/preset-react options) ` + + `or a ${chalk.cyan('String')} (to configure @babel/preset-react's runtime option)` + ) + } + } + // reactConstantElements if ('reactConstantElements' in userConfig.babel) { if (typeOf(reactConstantElements) !== 'boolean') { diff --git a/src/createBabelConfig.js b/src/createBabelConfig.js index 0a2e6a16..d3e06ac9 100644 --- a/src/createBabelConfig.js +++ b/src/createBabelConfig.js @@ -31,6 +31,7 @@ type UserOptions = { plugins?: BabelPluginConfig[], presets?: BabelPluginConfig[], proposals?: false | Object, + react?: Object, reactConstantElements?: boolean, removePropTypes?: false | Object, runtime?: false | Object, @@ -61,6 +62,7 @@ export default function createBabelConfig( plugins: userPlugins = [], presets: userPresets, proposals: userProposals = {}, + react = {}, reactConstantElements, removePropTypes: userRemovePropTypes, runtime: userRuntime, @@ -83,7 +85,15 @@ export default function createBabelConfig( buildPresets.forEach(preset => { // Presets which are configurable via user config are specified by name so // customisation can be handled in this module. - if (preset === 'react-prod') { + if (preset === 'react') { + presets.push( + [require.resolve('@babel/preset-react'), { + development: process.env.NODE_ENV !== 'production', + ...react + }] + ) + } + else if (preset === 'react-prod') { // Hoist static element subtrees up so React can skip them when reconciling if (reactConstantElements !== false) { plugins.push(require.resolve('@babel/plugin-transform-react-constant-elements')) diff --git a/src/react/index.js b/src/react/index.js index 176c504e..b913b849 100644 --- a/src/react/index.js +++ b/src/react/index.js @@ -7,9 +7,8 @@ function getBaseConfig(): Object { return { babel: { presets: [ - [require.resolve('@babel/preset-react'), { - development: process.env.NODE_ENV !== 'production' - }] + // User-configurable, so handled by createBabelConfig + 'react' ] }, } diff --git a/tests/config-test.js b/tests/config-test.js index 08f89add..e849c10f 100644 --- a/tests/config-test.js +++ b/tests/config-test.js @@ -85,6 +85,15 @@ describe('processUserConfig()', () => { it('babel.proposals is not an object or false', () => { check({babel: {proposals: /invalid/}}, 'babel.proposals', /Must be/) }) + it('babel.react is not an string or an object', () => { + check({babel: {react: /invalid/}}, 'babel.react', /Must be/) + }) + it('babel.react is not an string or an object', () => { + check({babel: {react: /invalid/}}, 'babel.react', /Must be/) + }) + it('babel.reactConstantElements is not a boolean', () => { + check({babel: {reactConstantElements: 'invalid'}}, 'babel.reactConstantElements', /Must be/) + }) it('babel.runtime is not valid', () => { check({babel: {runtime: 'welp'}}, 'babel.runtime', /Must be/) }) @@ -200,6 +209,10 @@ describe('processUserConfig()', () => { }) describe('convenience shorthand', () => { + it('allows babel.react to be a string', () => { + let config = process({babel: {react: 'test'}}) + expect(config.babel.react).toEqual({runtime: 'test'}) + }) it('allows npm.umd to be a string', () => { let config = process({npm: {umd: 'test'}}) expect(config.npm.umd).toEqual({global: 'test'}) diff --git a/tests/createBabelConfig-test.js b/tests/createBabelConfig-test.js index 74b8533b..fa32130a 100644 --- a/tests/createBabelConfig-test.js +++ b/tests/createBabelConfig-test.js @@ -57,7 +57,23 @@ describe('createBabelConfig()', () => { ], }) }) - it('adds plugins given the "react-prod" preset', () => { + it('adds the @babel/preset-react preset given a "react" preset', () => { + expect(createBabelConfig({ + presets: ['react'], + }, { + proposals: false, + })).toEqual({ + presets: [ + [require.resolve('@babel/preset-env'), {loose: true, modules: false}], + [require.resolve('@babel/preset-react'), {development: true}], + ], + plugins: [ + DEFAULT_RUNTIME_CONFIG, + require.resolve('@babel/plugin-syntax-dynamic-import'), + ], + }) + }) + it('adds plugins given a "react-prod" preset', () => { expect(createBabelConfig({ presets: ['react-prod'], }, { From 33f0eab6abcd722a8f0d2b83d4a6d0dc0b59c60f Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sat, 21 Mar 2020 23:34:09 +1000 Subject: [PATCH 46/66] Release v0.24.4 --- CHANGES.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 94122f31..572aa02e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,4 @@ -# Unreleased (in `master`) +# 0.24.4 / 2020-03-21 ## Added diff --git a/package.json b/package.json index 6efc19a3..5d7b76de 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nwb", "description": "A toolkit for React, Preact & Inferno apps, React libraries and other npm modules for the web, with no configuration (until you need it)", - "version": "0.24.3", + "version": "0.24.4", "license": "MIT", "author": "Jonny Buchanan <jonathan.buchanan@gmail.com>", "bin": { From 3163aade908892f6ec4a1cedd0a61ab53a810559 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Tue, 24 Mar 2020 22:50:48 +1000 Subject: [PATCH 47/66] Update dependencies Update inlineRuntimePlugin to use the new html-webpack-plugin v4 hooks API --- CHANGES.md | 18 ++++++++++++++++++ package.json | 12 ++++++------ src/createWebpackConfig.js | 24 ++++++++---------------- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 572aa02e..d4ce5b6a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,21 @@ +# Unreleased (in `master`) + +## Changed + +- [html-webpack-plugin got a major version bump to v4](https://dev.to/jantimon/html-webpack-plugin-4-has-been-released-125d) + - Output HTML is now minified by default - you can disable this by configuring `html.minification = false`. + - Chunk sorting was removed, but it seems to work as before for the ordering of the JavaScript files generated by nwb's build. + - The plugin nwb uses to inline the webpack runtime chunk was rewritten to use v4's new hooks. + +## Dependencies + +- @babel/plugin-transform-react-jsx: v7.9.1 → [v7.9.4](https://github.com/babel/babel/releases/tag/v7.9.4) +- @babel/preset-react: v7.9.1 → [v7.9.4](https://github.com/babel/babel/releases/tag/v7.9.4) +- @babel/runtime: v7.9.0 → v7.9.2 +- autoprefixer: v9.7.4 → [v9.7.5](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#975) +- html-webpack-plugin: v3.2.0 → [v4.0.1](https://github.com/jantimon/html-webpack-plugin/blob/master/CHANGELOG.md#401-2020-03-23) +- webpack: v4.42.0 → [v4.42.1](https://github.com/webpack/webpack/releases/tag/v4.42.1) + # 0.24.4 / 2020-03-21 ## Added diff --git a/package.json b/package.json index 5d7b76de..e2ff7323 100644 --- a/package.json +++ b/package.json @@ -51,12 +51,12 @@ "@babel/plugin-syntax-dynamic-import": "7.8.3", "@babel/plugin-syntax-jsx": "7.8.3", "@babel/plugin-transform-react-constant-elements": "7.9.0", - "@babel/plugin-transform-react-jsx": "7.9.1", + "@babel/plugin-transform-react-jsx": "7.9.4", "@babel/plugin-transform-runtime": "7.9.0", "@babel/polyfill": "7.8.7", "@babel/preset-env": "7.9.0", - "@babel/preset-react": "7.9.1", - "@babel/runtime": "7.9.0", + "@babel/preset-react": "7.9.4", + "@babel/runtime": "7.9.2", "@pmmmwh/react-refresh-webpack-plugin": "0.2.0", "babel-plugin-add-module-exports": "1.0.2", "babel-plugin-inferno": "6.1.0", @@ -84,15 +84,15 @@ "promise": "8.1.0", "whatwg-fetch": "3.0.0", - "webpack": "4.42.0", - "autoprefixer": "9.7.4", + "webpack": "4.42.1", + "autoprefixer": "9.7.5", "babel-loader": "8.1.0", "case-sensitive-paths-webpack-plugin": "2.3.0", "copy-webpack-plugin": "5.1.1", "css-loader": "3.4.2", "eventsource-polyfill": "0.9.6", "file-loader": "4.3.0", - "html-webpack-plugin": "3.2.0", + "html-webpack-plugin": "4.0.1", "mini-css-extract-plugin": "0.9.0", "@insin/npm-install-webpack-plugin": "5.0.0", "optimize-css-assets-webpack-plugin": "5.0.3", diff --git a/src/createWebpackConfig.js b/src/createWebpackConfig.js index 4a4a78a7..e05fbd78 100644 --- a/src/createWebpackConfig.js +++ b/src/createWebpackConfig.js @@ -409,25 +409,18 @@ export function createExtraRules( /** * Plugin for HtmlPlugin which inlines the Webpack runtime code and chunk - * manifest into the HTML in a <script> tag before other emitted asssets are - * injected by HtmlPlugin itself. + * manifest into its <script> tag. */ function inlineRuntimePlugin() { this.hooks.compilation.tap('inlineRuntimePlugin', compilation => { - compilation.hooks.htmlWebpackPluginBeforeHtmlProcessing.tapAsync('inlineRuntimePlugin', (data, cb) => { - Object.keys(compilation.assets).forEach(key => { - if (!/^runtime\.[a-z\d]+\.js$/.test(key)) return - let {children} = compilation.assets[key] + HtmlPlugin.getHooks(compilation).alterAssetTags.tapAsync('inlineRuntimePlugin', (data, cb) => { + Object.keys(compilation.assets).forEach(assetName => { + if (!/^runtime\.[a-z\d]+\.js$/.test(assetName)) return + let {children} = compilation.assets[assetName] if (children && children[0]) { - data.html = data.html.replace( - /^(\s*)<\/body>/m, - `$1<script>${children[0]._value}</script>\n$1</body>` - ) - // Remove the runtime from HtmlPlugin's assets to prevent a <script> - // tag being created for it. - var runtimeIndex = data.assets.js.indexOf(data.assets.publicPath + key) - data.assets.js.splice(runtimeIndex, 1) - delete data.assets.chunks.runtime + let tag = data.assetTags.scripts.find(tag => tag.attributes.src.endsWith(assetName)) + delete tag.attributes.src + tag.innerHTML = children[0]._value } }) cb(null, data) @@ -557,7 +550,6 @@ export function createPlugins( // Generate an HTML file for web apps which pulls in generated resources if (buildConfig.html) { plugins.push(new HtmlPlugin({ - chunksSortMode: 'dependency', template: path.join(__dirname, '../templates/webpack-template.html'), ...buildConfig.html, ...userConfig.html, From db1b59734fdbe5f85bd924c7bce3d847989c78cc Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Tue, 24 Mar 2020 23:15:02 +1000 Subject: [PATCH 48/66] Fixed population of the <html> lang attribute default for quick commands6 --- CHANGES.md | 4 ++++ src/quickCommands.js | 2 ++ 2 files changed, 6 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index d4ce5b6a..97cb823b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,10 @@ - Chunk sorting was removed, but it seems to work as before for the ordering of the JavaScript files generated by nwb's build. - The plugin nwb uses to inline the webpack runtime chunk was rewritten to use v4's new hooks. +## Fixed + +- The `lang` attribute on `<html>` wasn't getting set to the default `'en'` when using the `nwb react`, `nwb preact` and `nwb inferno` quick development commands. + ## Dependencies - @babel/plugin-transform-react-jsx: v7.9.1 → [v7.9.4](https://github.com/babel/babel/releases/tag/v7.9.4) diff --git a/src/quickCommands.js b/src/quickCommands.js index 1371c354..f58edfea 100644 --- a/src/quickCommands.js +++ b/src/quickCommands.js @@ -93,6 +93,7 @@ export function createBuildConfig(args: Object, options: QuickConfigOptions) { }, plugins: { html: { + lang: 'en', mountId, title: args.title || defaultTitle, }, @@ -154,6 +155,7 @@ export function createServeConfig(args: Object, options: QuickConfigOptions) { }, plugins: { html: { + lang: 'en', mountId, title: args.title || defaultTitle, }, From 2e9418936b62e4094faab62e8af40598234ddb59 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Tue, 24 Mar 2020 23:16:41 +1000 Subject: [PATCH 49/66] Release v0.24.5 --- CHANGES.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 97cb823b..83e5da0d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,4 @@ -# Unreleased (in `master`) +# 0.24.5 / 2020-03-24 ## Changed diff --git a/package.json b/package.json index e2ff7323..ba776fb9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nwb", "description": "A toolkit for React, Preact & Inferno apps, React libraries and other npm modules for the web, with no configuration (until you need it)", - "version": "0.24.4", + "version": "0.24.5", "license": "MIT", "author": "Jonny Buchanan <jonathan.buchanan@gmail.com>", "bin": { From 39b4326c1cc03820eb0cc8800fed527a276d4844 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Wed, 8 Apr 2020 01:32:06 +1000 Subject: [PATCH 50/66] Update dependencies --- CHANGES.md | 10 ++++++++++ package.json | 14 +++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 83e5da0d..d20b51f1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,13 @@ +# Unreleased (in `master`) + +## Dependencies + +- autoprefixer: v9.7.5 → [v9.7.6](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#976) +- cross-spawn: v7.0.1 → [v7.0.2](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md#702-2020-04-04) +- css-loader: v3.4.2 → [v3.5.1](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#351-2020-04-07) +- html-webpack-plugin: v3.2.0 → [v4.0.4](https://github.com/jantimon/html-webpack-plugin/blob/master/CHANGELOG.md#404-2020-04-01) +- semver: v7.1.3 → [v7.2.1](https://github.com/npm/node-semver/compare/v7.1.3...v7.2.1) + # 0.24.5 / 2020-03-24 ## Changed diff --git a/package.json b/package.json index ba776fb9..ed811ffc 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "dependencies": { "chalk": "3.0.0", "copy-template-dir": "1.4.0", - "cross-spawn": "7.0.1", + "cross-spawn": "7.0.2", "debug": "4.1.1", "detect-port": "1.3.0", "figures": "3.2.0", @@ -43,7 +43,7 @@ "ora": "4.0.3", "resolve": "1.15.1", "run-series": "1.1.8", - "semver": "7.1.3", + "semver": "7.2.1", "webpack-merge": "4.2.2", "@babel/cli": "7.8.4", @@ -85,14 +85,14 @@ "whatwg-fetch": "3.0.0", "webpack": "4.42.1", - "autoprefixer": "9.7.5", + "autoprefixer": "9.7.6", "babel-loader": "8.1.0", "case-sensitive-paths-webpack-plugin": "2.3.0", "copy-webpack-plugin": "5.1.1", - "css-loader": "3.4.2", + "css-loader": "3.5.1", "eventsource-polyfill": "0.9.6", "file-loader": "4.3.0", - "html-webpack-plugin": "4.0.1", + "html-webpack-plugin": "4.0.4", "mini-css-extract-plugin": "0.9.0", "@insin/npm-install-webpack-plugin": "5.0.0", "optimize-css-assets-webpack-plugin": "5.0.3", @@ -111,9 +111,9 @@ "cross-env": "7.0.2", "eslint-config-jonnybuchanan": "6.0.0", "eventsource": "1.0.7", - "flow-bin": "0.121.0", + "flow-bin": "0.122.0", "glob": "7.1.6", - "nyc": "15.0.0", + "nyc": "15.0.1", "rimraf": "3.0.2", "temp": "0.9.1", "tree-kill": "1.2.2" From 9cd54fba318d039f31a8702cb78bfcfd07274e0d Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sun, 3 May 2020 10:45:53 +1000 Subject: [PATCH 51/66] Update dependencies --- CHANGES.md | 18 +++++++++++++++--- TODO | 9 +++++++++ package.json | 32 ++++++++++++++++---------------- 3 files changed, 40 insertions(+), 19 deletions(-) create mode 100644 TODO diff --git a/CHANGES.md b/CHANGES.md index d20b51f1..86e1d899 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,11 +2,23 @@ ## Dependencies +- @babel/core: v7.90 → [v7.9.6](https://github.com/babel/babel/blob/master/CHANGELOG.md#v796-2020-04-29) +- @babel/plugin-transform-runtime: v7.9.0 → [v7.9.6](https://github.com/babel/babel/blob/master/CHANGELOG.md#v796-2020-04-29) +- @babel/preset-env: v7.9.0 → [v7.9.6](https://github.com/babel/babel/blob/master/CHANGELOG.md#v796-2020-04-29) +- @babel/runtime: v7.9.2 → [v7.9.6](https://github.com/babel/babel/blob/master/CHANGELOG.md#v796-2020-04-29) - autoprefixer: v9.7.5 → [v9.7.6](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#976) - cross-spawn: v7.0.1 → [v7.0.2](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md#702-2020-04-04) -- css-loader: v3.4.2 → [v3.5.1](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#351-2020-04-07) -- html-webpack-plugin: v3.2.0 → [v4.0.4](https://github.com/jantimon/html-webpack-plugin/blob/master/CHANGELOG.md#404-2020-04-01) -- semver: v7.1.3 → [v7.2.1](https://github.com/npm/node-semver/compare/v7.1.3...v7.2.1) +- css-loader: v3.4.2 → [v3.5.3](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#353-2020-04-24) +- html-webpack-plugin: v3.2.0 → [v4.3.0](https://github.com/jantimon/html-webpack-plugin/blob/master/CHANGELOG.md#430-2020-04-30) +- karma-coverage: v2.0.1 → [v2.0.2](https://github.com/karma-runner/karma-coverage/blob/master/CHANGELOG.md#202-2020-04-13) +- mocha: v7.1.1 → [v7.1.2](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#712--2020-04-26) +- ora: v4.0.3 → [v4.0.4](https://github.com/sindresorhus/ora/compare/v4.0.3...v4.0.4) +- react-refresh: v0.8.1 → [v0.8.2](https://github.com/facebook/react/commits/9491f394723e140259d65f4d2b8a4d869fa4ba62/packages/react-refresh) +- resolve: v1.15.1 → [v1.17.0](https://github.com/browserify/resolve/compare/v1.15.1...v1.17.0) +- semver: v7.1.3 → [v7.3.2](https://github.com/npm/node-semver/compare/v7.1.3...v7.3.2) +- style-loader: v1.1.3 → [v1.2.1](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#121-2020-04-28) +- terser-webpack-plugin v2.3.5 → [v2.3.6](https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/CHANGELOG.md#236-2020-04-25) +- webpack: v4.42.1 → [v4.43.0](https://github.com/webpack/webpack/releases/tag/v4.43.0) # 0.24.5 / 2020-03-24 diff --git a/TODO b/TODO new file mode 100644 index 00000000..dd117c44 --- /dev/null +++ b/TODO @@ -0,0 +1,9 @@ +Dependencies: + ☐ Node.js 10 minimum version + chalk + file-loader + fs-extra + karma + karma-mocha + terser-webpack-plugin + url-loader diff --git a/package.json b/package.json index ed811ffc..d9144a1a 100644 --- a/package.json +++ b/package.json @@ -40,23 +40,23 @@ "gzip-size": "5.1.1", "inquirer": "7.1.0", "minimist": "1.2.5", - "ora": "4.0.3", - "resolve": "1.15.1", + "ora": "4.0.4", + "resolve": "1.17.0", "run-series": "1.1.8", - "semver": "7.2.1", + "semver": "7.3.2", "webpack-merge": "4.2.2", "@babel/cli": "7.8.4", - "@babel/core": "7.9.0", + "@babel/core": "7.9.6", "@babel/plugin-syntax-dynamic-import": "7.8.3", "@babel/plugin-syntax-jsx": "7.8.3", "@babel/plugin-transform-react-constant-elements": "7.9.0", "@babel/plugin-transform-react-jsx": "7.9.4", - "@babel/plugin-transform-runtime": "7.9.0", + "@babel/plugin-transform-runtime": "7.9.6", "@babel/polyfill": "7.8.7", - "@babel/preset-env": "7.9.0", + "@babel/preset-env": "7.9.6", "@babel/preset-react": "7.9.4", - "@babel/runtime": "7.9.2", + "@babel/runtime": "7.9.6", "@pmmmwh/react-refresh-webpack-plugin": "0.2.0", "babel-plugin-add-module-exports": "1.0.2", "babel-plugin-inferno": "6.1.0", @@ -65,11 +65,11 @@ "babel-plugin-transform-decorators-legacy": "1.3.5", "babel-plugin-transform-react-remove-prop-types": "0.4.24", "babel-preset-proposals": "0.3.0", - "react-refresh": "0.8.1", + "react-refresh": "0.8.2", "karma": "4.4.1", "karma-chrome-launcher": "3.1.0", - "karma-coverage": "2.0.1", + "karma-coverage": "2.0.2", "karma-mocha": "1.3.0", "karma-mocha-reporter": "2.2.5", "karma-phantomjs-launcher": "1.0.4", @@ -77,29 +77,29 @@ "karma-webpack": "4.0.2", "phantomjs-prebuilt": "2.1.16", - "mocha": "7.1.1", + "mocha": "7.1.2", "expect": "1.20.2", "object-assign": "4.1.1", "promise": "8.1.0", "whatwg-fetch": "3.0.0", - "webpack": "4.42.1", + "webpack": "4.43.0", "autoprefixer": "9.7.6", "babel-loader": "8.1.0", "case-sensitive-paths-webpack-plugin": "2.3.0", "copy-webpack-plugin": "5.1.1", - "css-loader": "3.5.1", + "css-loader": "3.5.3", "eventsource-polyfill": "0.9.6", "file-loader": "4.3.0", - "html-webpack-plugin": "4.0.4", + "html-webpack-plugin": "4.3.0", "mini-css-extract-plugin": "0.9.0", "@insin/npm-install-webpack-plugin": "5.0.0", "optimize-css-assets-webpack-plugin": "5.0.3", "open": "7.0.3", "postcss-loader": "3.0.0", - "style-loader": "1.1.3", - "terser-webpack-plugin": "2.3.5", + "style-loader": "1.2.1", + "terser-webpack-plugin": "2.3.6", "url-loader": "2.3.0", "webpack-dev-middleware": "3.7.2", "webpack-dev-server": "3.10.3", @@ -111,7 +111,7 @@ "cross-env": "7.0.2", "eslint-config-jonnybuchanan": "6.0.0", "eventsource": "1.0.7", - "flow-bin": "0.122.0", + "flow-bin": "0.123.0", "glob": "7.1.6", "nyc": "15.0.1", "rimraf": "3.0.2", From c927565d548c55e207ccb2be0a132524cefa976a Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Tue, 12 May 2020 21:08:21 +1000 Subject: [PATCH 52/66] Update dependencies Remove deprecated disableRefreshCheck config for ReactRefreshPlugin --- CHANGES.md | 2 ++ package.json | 6 +++--- src/createWebpackConfig.js | 6 +----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 86e1d899..b8d3aeed 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ - @babel/plugin-transform-runtime: v7.9.0 → [v7.9.6](https://github.com/babel/babel/blob/master/CHANGELOG.md#v796-2020-04-29) - @babel/preset-env: v7.9.0 → [v7.9.6](https://github.com/babel/babel/blob/master/CHANGELOG.md#v796-2020-04-29) - @babel/runtime: v7.9.2 → [v7.9.6](https://github.com/babel/babel/blob/master/CHANGELOG.md#v796-2020-04-29) +- @pmmmwh/react-refresh-webpack-plugin: v0.2.0 → [v0.3.1](https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/master/CHANGELOG.md#031-11-may-2020) - autoprefixer: v9.7.5 → [v9.7.6](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#976) - cross-spawn: v7.0.1 → [v7.0.2](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md#702-2020-04-04) - css-loader: v3.4.2 → [v3.5.3](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#353-2020-04-24) @@ -19,6 +20,7 @@ - style-loader: v1.1.3 → [v1.2.1](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#121-2020-04-28) - terser-webpack-plugin v2.3.5 → [v2.3.6](https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/CHANGELOG.md#236-2020-04-25) - webpack: v4.42.1 → [v4.43.0](https://github.com/webpack/webpack/releases/tag/v4.43.0) +- webpack-dev-server: v3.10.3 → [v3.11.0](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md#3110-2020-05-08) # 0.24.5 / 2020-03-24 diff --git a/package.json b/package.json index d9144a1a..ba4becf0 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "@babel/preset-env": "7.9.6", "@babel/preset-react": "7.9.4", "@babel/runtime": "7.9.6", - "@pmmmwh/react-refresh-webpack-plugin": "0.2.0", + "@pmmmwh/react-refresh-webpack-plugin": "0.3.1", "babel-plugin-add-module-exports": "1.0.2", "babel-plugin-inferno": "6.1.0", "babel-plugin-istanbul": "6.0.0", @@ -102,7 +102,7 @@ "terser-webpack-plugin": "2.3.6", "url-loader": "2.3.0", "webpack-dev-middleware": "3.7.2", - "webpack-dev-server": "3.10.3", + "webpack-dev-server": "3.11.0", "webpack-hot-middleware": "2.25.0" }, "devDependencies": { @@ -111,7 +111,7 @@ "cross-env": "7.0.2", "eslint-config-jonnybuchanan": "6.0.0", "eventsource": "1.0.7", - "flow-bin": "0.123.0", + "flow-bin": "0.124.0", "glob": "7.1.6", "nyc": "15.0.1", "rimraf": "3.0.2", diff --git a/src/createWebpackConfig.js b/src/createWebpackConfig.js index e05fbd78..d65e2d31 100644 --- a/src/createWebpackConfig.js +++ b/src/createWebpackConfig.js @@ -484,11 +484,7 @@ export function createPlugins( optimization.noEmitOnErrors = true } if (buildConfig.reactRefresh) { - // XXX disableRefreshCheck is currently required - // See https://github.com/pmmmwh/react-refresh-webpack-plugin/issues/15 - plugins.push(new ReactRefreshPlugin({ - disableRefreshCheck: true, - })) + plugins.push(new ReactRefreshPlugin()) } if (buildConfig.status) { plugins.push(new StatusPlugin(buildConfig.status)) From 6163fa090f1f8987e0864de5c21bad9e9c755c0d Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Tue, 12 May 2020 21:32:10 +1000 Subject: [PATCH 53/66] Release v0.24.6 --- CHANGES.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b8d3aeed..da301b53 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,4 @@ -# Unreleased (in `master`) +# 0.24.6 / 2020-05-12 ## Dependencies diff --git a/package.json b/package.json index ba4becf0..d2bc4ec6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nwb", "description": "A toolkit for React, Preact & Inferno apps, React libraries and other npm modules for the web, with no configuration (until you need it)", - "version": "0.24.5", + "version": "0.24.6", "license": "MIT", "author": "Jonny Buchanan <jonathan.buchanan@gmail.com>", "bin": { From 80a981941754bb3af02c00102929af790369d34e Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sat, 16 May 2020 23:14:45 +1000 Subject: [PATCH 54/66] Fix inclusion of __source and __self debugging info when transpiling JSX in react-component projects --- CHANGES.md | 4 ++++ src/moduleBuild.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index da301b53..9d3c477d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +## Fixed + +- Fixed inclusion of `__source` and `__self` debugging information when transpiling JSX in `react-component` projects by defaulting `process.env.NODE_ENV` to `'production'` when building. + # 0.24.6 / 2020-05-12 ## Dependencies diff --git a/src/moduleBuild.js b/src/moduleBuild.js index c530b1a6..d337b3fb 100644 --- a/src/moduleBuild.js +++ b/src/moduleBuild.js @@ -123,6 +123,10 @@ export default function moduleBuild(args, buildConfig = {}, cb) { ) } + if (!process.env.NODE_ENV) { + process.env.NODE_ENV = 'production' + } + let pluginConfig = getPluginConfig(args) let userConfig = getUserConfig(args, {pluginConfig}) let babelCliOptions = { From aa01bf63c778b73f0075c5470c01d51b2fa44a66 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sat, 16 May 2020 23:15:26 +1000 Subject: [PATCH 55/66] Update dependencies --- CHANGES.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 9d3c477d..d93fee3b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,10 @@ - Fixed inclusion of `__source` and `__self` debugging information when transpiling JSX in `react-component` projects by defaulting `process.env.NODE_ENV` to `'production'` when building. +## Dependencies + +- open: v7.0.3 → [v7.0.4](https://github.com/sindresorhus/open/releases/tag/v7.0.4) + # 0.24.6 / 2020-05-12 ## Dependencies diff --git a/package.json b/package.json index d2bc4ec6..a6f0d53a 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ "mini-css-extract-plugin": "0.9.0", "@insin/npm-install-webpack-plugin": "5.0.0", "optimize-css-assets-webpack-plugin": "5.0.3", - "open": "7.0.3", + "open": "7.0.4", "postcss-loader": "3.0.0", "style-loader": "1.2.1", "terser-webpack-plugin": "2.3.6", From cdab645c3e967211eb4ad3325b752d767963ff6b Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sat, 16 May 2020 23:16:36 +1000 Subject: [PATCH 56/66] Release v0.24.7 --- CHANGES.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index d93fee3b..d92b643b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,5 @@ +# 0.24.7 / 2020-05-16 + ## Fixed - Fixed inclusion of `__source` and `__self` debugging information when transpiling JSX in `react-component` projects by defaulting `process.env.NODE_ENV` to `'production'` when building. diff --git a/package.json b/package.json index a6f0d53a..b841c552 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nwb", "description": "A toolkit for React, Preact & Inferno apps, React libraries and other npm modules for the web, with no configuration (until you need it)", - "version": "0.24.6", + "version": "0.24.7", "license": "MIT", "author": "Jonny Buchanan <jonathan.buchanan@gmail.com>", "bin": { From bf053188e46e2e8e02dd29c5e9cb1413aeb4f82a Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sat, 14 Mar 2020 01:46:54 +1000 Subject: [PATCH 57/66] Breaking: Drop support for Node.js 8 - Node.js 10.13.0 is now the minimum required version - closes #547 Breaking: Remove support for deprecated babel.stage and webpack.uglify config Breaking: Remove default polyfills for Promise, fetch() and Object.assign() - import react-app-polyfill in your app if you need polyfills Update dependencies which have dropped Node 8 --- .travis.yml | 2 +- CHANGES.md | 21 ++++++++ appveyor.yml | 2 +- docs/Configuration.md | 17 ------- docs/FAQ.md | 4 -- docs/Features.md | 1 - docs/Testing.md | 2 +- docs/guides/QuickDevelopment.md | 5 -- docs/guides/ReactApps.md | 1 - package.json | 20 +++----- polyfills.js | 17 ------- src/appCommands.js | 4 -- src/commands/inferno.js | 2 - src/commands/preact.js | 2 - src/commands/react.js | 2 - src/commands/web.js | 2 - src/config/babel.js | 84 +------------------------------ src/config/user.js | 17 ++++--- src/config/webpack.js | 19 ------- src/createServerWebpackConfig.js | 2 +- src/createWebpackConfig.js | 20 +------- src/moduleBuild.js | 1 - src/quickCommands.js | 8 --- tests/config-test.js | 9 ---- tests/createWebpackConfig-test.js | 11 +--- tests/fixtures/worst-config.js | 2 - 26 files changed, 48 insertions(+), 229 deletions(-) delete mode 100644 polyfills.js diff --git a/.travis.yml b/.travis.yml index fc5c8868..9cae74f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,9 @@ sudo: false language: node_js node_js: - - 8 - 10 - 12 + - 14 cache: directories: diff --git a/CHANGES.md b/CHANGES.md index d92b643b..ad470405 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,24 @@ +# `next` branch + +## Breaking Changes + +- Node.js 8 is no longer supported; Node.js 10.13.0 is now the minimum required version, as per many of nwb's dependencies. +- Removed support for deprecated `babel.stage` and `webpack.uglify` config. +- Removed default polyfills for `Promise`, `fetch()` and `Object.assign()` and deprecated `polyfill` config. + - If you need to support older browsers, you will need to provide the necessary polyfills yourself. + - The [react-app-polyfill](https://github.com/facebook/create-react-app/tree/master/packages/react-app-polyfill#react-app-polyfill) module provides polyfills for IE 9-11, and for stable language features - its instructions also work for apps using nwb. +- file-loader v6.0.0 [changed its default hashing algorithm](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#600-2020-03-17). + +## Dependencies + +- chalk: v3.0.0 → [v4.0.0](https://github.com/chalk/chalk/releases/tag/v4.0.0) +- file-loader: v4.3.0 → [v6.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#600-2020-03-17) +- fs-extra: v8.1.0 → [v9.0.0](https://github.com/jprichardson/node-fs-extra/blob/master/CHANGELOG.md#900--2020-03-19) +- karma: v4.4.1 → [v5.0.5](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md#505-2020-05-07) +- karma-mocha: v1.3.0 → [v2.0.1](https://github.com/karma-runner/karma-mocha/blob/master/CHANGELOG.md#201-2020-04-29) +- terser-webpack-plugin v2.3.6 → [v3.0.1](https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/CHANGELOG.md#301-2020-05-06) +- url-loader: v2.3.0→ [v4.1.0](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md) + # 0.24.7 / 2020-05-16 ## Fixed diff --git a/appveyor.yml b/appveyor.yml index 78093707..6a68c113 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,7 +5,7 @@ branches: environment: matrix: - - nodejs_version: "8" + - nodejs_version: "12" install: - ps: Install-Product node $env:nodejs_version x64 diff --git a/docs/Configuration.md b/docs/Configuration.md index 4bb36094..786d1e32 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -68,7 +68,6 @@ The configuration object can include the following properties: - nwb Configuration - [`type`](#type-string-required-for-generic-build-commands) - - [`polyfill`](#polyfill-boolean) - control automatic polyfilling - [Babel Configuration](#babel-configuration) - [`babel`](#babel-object) - [`babel.cherryPick`](#cherrypick-string--arraystring) - enable cherry-picking for destructured `import` statements @@ -140,18 +139,6 @@ If configured, it must be one of the following: - `'web-app'` - `'web-module'` -#### `polyfill`: `Boolean` - -For apps, nwb will provide polyfills for `Promise`, `fetch` and `Object.assign` by default. - -To disable this, set `polyfill` to `false`: - -```js -module.exports = { - polyfill: false -} -``` - ### Babel Configuration #### `babel`: `Object` @@ -378,10 +365,6 @@ module.exports = { } ``` -##### `stage`: `Number | false` - -*deprecated in v0.24.0 - use [`babel.proposals` config](#proposals-object--false) instead* - ##### `config`: `Function` Finally, if you need *complete* control, provide a `babel.config()` function which will be given the generated config. diff --git a/docs/FAQ.md b/docs/FAQ.md index 74bc8dc0..d20528ef 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -63,10 +63,6 @@ If you only need CSS Modules for some of the stylesheets you'll be importing, yo ### What can I configure to reduce bundle size? -#### Disable default polyfills - -If you don't need the `Promise`, `fetch` and `Object.assign` polyfills nwb provides by default, configuring [`polyfill: false`](/docs/Configuration.md#polyfill-boolean) (or passing a [`--no-polyfill` flag](/docs/guides/QuickDevelopment.md#options-for-run-and-build-commands) when using Quick Development commands) will shave ~4KB off the gzipped vendor bundle. - #### Enable cherry-picking for destructuring imports If you're using destructuring imports with libraries like React Router and React Bootstrap (e.g. `import {Button} from 'react-bootstrap'`), you're bundling the whole library, instead of just the bits you need. diff --git a/docs/Features.md b/docs/Features.md index 4cdbf07f..7ce7b52d 100644 --- a/docs/Features.md +++ b/docs/Features.md @@ -5,7 +5,6 @@ - Provides tooling for [React](https://facebook.github.io/react/) apps and components, [Preact](https://preactjs.com/) apps, [Inferno](https://infernojs.org/) apps, and vanilla JS web apps and npm modules. - Use modern JavaScript features, and JSX. - Use proposed JavaScript features now. -- Default polyfills and configuration allow use of [`Promise`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise) (with [rejection tracking](https://www.2ality.com/2016/04/unhandled-rejections.html) enabled), [`fetch()`](https://developer.mozilla.org/en/docs/Web/API/Fetch_API), [`async`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function)/[`await`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await), [generators](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/function*) and [`Object.assign()`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) in any browser. - Import CSS (and font resources) and images to be managed by Webpack. - [Autoprefixed](https://github.com/postcss/autoprefixer#autoprefixer-) CSS, so you don't need to write browser prefixes; you can also configure your own [PostCSS](https://postcss.org/) plugins. - Plugin modules which add support for the [Sass](https://github.com/insin/nwb-sass), [Less](https://github.com/insin/nwb-less) and [Stylus](https://github.com/insin/nwb-stylus) stylesheet languages. diff --git a/docs/Testing.md b/docs/Testing.md index 1089d5b8..8bc6a8ee 100644 --- a/docs/Testing.md +++ b/docs/Testing.md @@ -136,7 +136,7 @@ module.exports = { #### Automatic Babel Polyfill -A context module is commonly used to load polyfills to allow tests to run in browsers missing certain features, but you don't need to worry about that if you were just going to use `babel-polyfill` - nwb automatically injects Babel's polyfill into Karma tests for you. +A context module is commonly used to load polyfills to allow tests to run in browsers missing certain features, but you don't need to worry about that if you were just going to use `@babel/polyfill` - nwb automatically injects Babel's polyfill into Karma tests for you. #### Configuring Testing Libraries diff --git a/docs/guides/QuickDevelopment.md b/docs/guides/QuickDevelopment.md index 6d0df7a4..92811ee9 100644 --- a/docs/guides/QuickDevelopment.md +++ b/docs/guides/QuickDevelopment.md @@ -118,10 +118,6 @@ Don't use a rendering shim, run the provided entry module directly - see [Opting The default HTML template provided contains a `<div>` which the app is rendered into, with a default `id` of `'app'`. You can change the `id` with this setting. -#### `--no-polyfill` - -Disable inclusion of nwb's default polyfills for `Promise`, `fetch()` and `Object.assign()` - you can use this to shave a few KB off the final bundle size if you're not using these features, are only supporting browsers which support them natively, or would prefer to provide your own polyfills, etc. - #### `--title` Contents for `<title>` - defaults to the type of app you're serving, e.g. `'Preact App'` @@ -177,7 +173,6 @@ Create a build of a React project which uses Inferno or Preact as the runtime vi - Decorators. - Export extensions. -- Polyfills for `Promise`, `fetch()` and `Object.assign()`, which can be disabled with a `--no-polyfill` flag if you don’t need them or want to provide your own. - Import images and stylesheets into JavaScript like any other module, to be handled by Webpack as part of its build. ```js diff --git a/docs/guides/ReactApps.md b/docs/guides/ReactApps.md index 9a1d94a0..b7bdd434 100644 --- a/docs/guides/ReactApps.md +++ b/docs/guides/ReactApps.md @@ -148,7 +148,6 @@ Without any configuration, the main features you get are: - Use proposed JavaScript features which make writing React apps more convenient: - Class properties, for avoiding boilerplate when writing classes. - Decorators, for libraries which are intended to be used with them. -- Polyfills for `Promise`, `fetch` and `Object.assign`. - Import stylesheets (and font resources), images and JSON into JavaScript, to be handled by Webpack. - Autoprefixed CSS, so you don't need to write browser prefixes. diff --git a/package.json b/package.json index b841c552..8f8f1ede 100644 --- a/package.json +++ b/package.json @@ -26,17 +26,17 @@ "polyfills.js" ], "engines": { - "node": ">=8.9.0" + "node": ">=10.13.0" }, "dependencies": { - "chalk": "3.0.0", + "chalk": "4.0.0", "copy-template-dir": "1.4.0", "cross-spawn": "7.0.2", "debug": "4.1.1", "detect-port": "1.3.0", "figures": "3.2.0", "filesize": "6.1.0", - "fs-extra": "8.1.0", + "fs-extra": "9.0.0", "gzip-size": "5.1.1", "inquirer": "7.1.0", "minimist": "1.2.5", @@ -67,10 +67,10 @@ "babel-preset-proposals": "0.3.0", "react-refresh": "0.8.2", - "karma": "4.4.1", + "karma": "5.0.5", "karma-chrome-launcher": "3.1.0", "karma-coverage": "2.0.2", - "karma-mocha": "1.3.0", + "karma-mocha": "2.0.1", "karma-mocha-reporter": "2.2.5", "karma-phantomjs-launcher": "1.0.4", "karma-sourcemap-loader": "0.3.7", @@ -80,10 +80,6 @@ "mocha": "7.1.2", "expect": "1.20.2", - "object-assign": "4.1.1", - "promise": "8.1.0", - "whatwg-fetch": "3.0.0", - "webpack": "4.43.0", "autoprefixer": "9.7.6", "babel-loader": "8.1.0", @@ -91,7 +87,7 @@ "copy-webpack-plugin": "5.1.1", "css-loader": "3.5.3", "eventsource-polyfill": "0.9.6", - "file-loader": "4.3.0", + "file-loader": "6.0.0", "html-webpack-plugin": "4.3.0", "mini-css-extract-plugin": "0.9.0", "@insin/npm-install-webpack-plugin": "5.0.0", @@ -99,8 +95,8 @@ "open": "7.0.4", "postcss-loader": "3.0.0", "style-loader": "1.2.1", - "terser-webpack-plugin": "2.3.6", - "url-loader": "2.3.0", + "terser-webpack-plugin": "3.0.1", + "url-loader": "4.1.0", "webpack-dev-middleware": "3.7.2", "webpack-dev-server": "3.11.0", "webpack-hot-middleware": "2.25.0" diff --git a/polyfills.js b/polyfills.js deleted file mode 100644 index 710cce8f..00000000 --- a/polyfills.js +++ /dev/null @@ -1,17 +0,0 @@ -// Ensure polyfill compatibility between create-react-app and zero-config nwb apps. -// This is from https://github.com/facebookincubator/create-react-app/blob/master/config/polyfills.js - -if (typeof Promise === 'undefined') { - // Rejection tracking prevents a common issue where React gets into an - // inconsistent state due to an error, but it gets swallowed by a Promise, - // and the user has no idea what causes React's erratic future behaviour. - require('promise/lib/rejection-tracking').enable() - window.Promise = require('promise/lib/es6-extensions.js') -} - -// fetch() polyfill for making API calls -require('whatwg-fetch') - -// Object.assign() is commonly used with React. -// It will use the native implementation if it's present and isn't buggy. -Object.assign = require('object-assign') diff --git a/src/appCommands.js b/src/appCommands.js index ae159b52..c9388a4b 100644 --- a/src/appCommands.js +++ b/src/appCommands.js @@ -78,10 +78,6 @@ export function createBuildConfig(args: Object, extra: Object = {}) { config.plugins.copy = [{from: path.resolve('public'), to: dist, ignore: ['.gitkeep']}] } - if (args.polyfill === false || args.polyfills === false) { - config.polyfill = false - } - return merge(config, extra) } diff --git a/src/commands/inferno.js b/src/commands/inferno.js index f54e7924..8e98d793 100644 --- a/src/commands/inferno.js +++ b/src/commands/inferno.js @@ -55,7 +55,6 @@ Commands: ${opt('--host')} hostname to bind the dev server to ${opt('--mount-id')} id for the <div> the app will render into ${opt('[default: app]')} ${opt('--no-fallback')} disable serving of the index page from any path - ${opt('--no-polyfill')} disable inclusion of default polyfills ${opt('--port')} port to run the dev server on ${opt('[default: 3000]')} ${opt('--reload')} auto reload the page if hot reloading fails ${opt('--title')} contents for <title> ${opt('[default: Inferno App]')} @@ -70,7 +69,6 @@ Commands: Options: ${opt('--force')} don't shim rendering, use the given entry module directly ${opt('--mount-id')} id for the <div> the app will render into ${opt('[default: app]')} - ${opt('--no-polyfill')} disable bundling of default polyfills ${opt('--title')} contents for <title> ${opt('[default: Inferno App]')} ${opt('--vendor')} create a 'vendor' bundle for node_modules/ modules `) diff --git a/src/commands/preact.js b/src/commands/preact.js index bcd70158..2305caea 100644 --- a/src/commands/preact.js +++ b/src/commands/preact.js @@ -55,7 +55,6 @@ Commands: ${opt('--host')} hostname to bind the dev server to ${opt('--mount-id')} id for the <div> the app will render into ${opt('[default: app]')} ${opt('--no-fallback')} disable serving of the index page from any path - ${opt('--no-polyfill')} disable inclusion of default polyfills ${opt('--port')} port to run the dev server on ${opt('[default: 3000]')} ${opt('--reload')} auto reload the page if hot reloading fails ${opt('--title')} contents for <title> ${opt('[default: Preact App]')} @@ -70,7 +69,6 @@ Commands: Options: ${opt('--force')} don't shim rendering, use the given entry module directly ${opt('--mount-id')} id for the <div> the app will render into ${opt('[default: app]')} - ${opt('--no-polyfill')} disable bundling of default polyfills ${opt('--title')} contents for <title> ${opt('[default: Preact App]')} ${opt('--vendor')} create a 'vendor' bundle for node_modules/ modules `) diff --git a/src/commands/react.js b/src/commands/react.js index 587b7f88..c700def6 100644 --- a/src/commands/react.js +++ b/src/commands/react.js @@ -56,7 +56,6 @@ Commands: ${opt('--mount-id')} id for the <div> the app will render into ${opt('[default: app]')} ${opt('--no-fallback')} disable serving of the index page from any path ${opt('--no-hmr')} disable use of Fast Refresh for Hot Module Replacement - ${opt('--no-polyfill')} disable inclusion of default polyfills ${opt('--port')} port to run the dev server on ${opt('[default: 3000]')} ${opt('--reload')} auto reload the page if hot reloading fails ${opt('--title')} contents for <title> ${opt('[default: React App]')} @@ -71,7 +70,6 @@ Commands: Options: ${opt('--force')} don't shim rendering, use the given entry module directly ${opt('--mount-id')} id for the <div> the app will render into ${opt('[default: app]')} - ${opt('--no-polyfill')} disable bundling of default polyfills ${opt('--title')} contents for <title> ${opt('[default: React App]')} ${opt('--vendor')} create a 'vendor' bundle for node_modules/ modules diff --git a/src/commands/web.js b/src/commands/web.js index 82b64f07..4d34c056 100644 --- a/src/commands/web.js +++ b/src/commands/web.js @@ -55,7 +55,6 @@ Commands: ${opt('--mount-id')} id for the <div> in the default HTML ${opt('[default: app]')} ${opt('--no-fallback')} disable serving of the index page from any path ${opt('--no-reload')} disable auto reloading on changes - ${opt('--no-polyfill')} disable inclusion of default polyfills ${opt('--port')} port to run the dev server on ${opt('[default: 3000]')} ${opt('--title')} contents for <title> ${opt('[default: Web App]')} @@ -68,7 +67,6 @@ Commands: Options: ${opt('--mount-id')} id for the <div> in the default HTML ${opt('[default: app]')} - ${opt('--no-polyfill')} disable bundling of default polyfills ${opt('--title')} contents for <title> ${opt('[default: Web App]')} ${opt('--vendor')} create a 'vendor' bundle for node_modules/ modules `) diff --git a/src/config/babel.js b/src/config/babel.js index d6236b67..0e53c271 100644 --- a/src/config/babel.js +++ b/src/config/babel.js @@ -1,37 +1,7 @@ import {validateOptions} from 'babel-preset-proposals' import chalk from 'chalk' -import {padLines, pluralise as s, toSource, typeOf} from '../utils' - -// TODO Remove - deprecated -let warnedAboutStageConfig = false -const STAGE_3_PROPOSALS = { - dynamicImport: true, - importMeta: true, - classProperties: true, - numericSeparator: true, - // Actually Stage 4, but still... - exportNamespaceFrom: true, -} -const STAGE_2_PROPOSALS = { - ...STAGE_3_PROPOSALS, - decorators: true, - functionSent: true, - logicalAssignmentOperators: true, - throwExpressions: true, -} -const STAGE_1_PROPOSALS = { - ...STAGE_2_PROPOSALS, - exportDefaultFrom: true, - pipelineOperator: true, - doExpressions: true, -} -const PROPOSALS_BY_STAGE = { - 0: {all: true}, - 1: STAGE_1_PROPOSALS, - 2: STAGE_2_PROPOSALS, - 3: STAGE_3_PROPOSALS, -} +import {pluralise as s, typeOf} from '../utils' export function processBabelConfig({report, userConfig}) { let { @@ -45,7 +15,6 @@ export function processBabelConfig({report, userConfig}) { react, reactConstantElements, runtime, - stage, config, ...unexpectedConfig } = userConfig.babel @@ -189,57 +158,6 @@ export function processBabelConfig({report, userConfig}) { } } - // TODO Remove - deprecated - // stage - if ('stage' in userConfig.babel) { - let hasProposalsConfig = 'proposals' in userConfig.babel - let deprecationMessages = [ - 'Deprecated as of nwb v0.24.0, as Babel 7 no longer has preset-stage-X presets', - 'Use babel.proposals config instead to enable the required proposal plugins', - ] - - if (typeOf(stage) === 'number') { - if (stage < 0 || stage > 3) { - report.error( - 'babel.stage', - stage, - `Must be between ${chalk.cyan(0)} and ${chalk.cyan(3)}` - ) - } - else if (!hasProposalsConfig) { - deprecationMessages.push( - `For now, nwb will enable proposal plugins corresponding to the final version of preset-stage-${stage}`, - `This is equivalent to the following babel.proposals config:`, - '', - ...padLines(toSource(PROPOSALS_BY_STAGE[stage])).split('\n') - ) - userConfig.babel.proposals = {...PROPOSALS_BY_STAGE[stage]} - } - } - else if (stage !== false) { - report.error( - 'babel.stage', - stage, - `Must be a ${chalk.cyan('Number')} between ${chalk.cyan(0)} and ${chalk.cyan(3)} (to choose a stage preset), ` + - `or ${chalk.cyan('false')} (to disable use of a stage preset)` - ) - } - else { - if (!hasProposalsConfig) { - deprecationMessages.push( - `For now, nwb will disable use of proposal plugins`, - `This is equivalent to configuring ${chalk.cyan('babel.proposals = false')}` - ) - userConfig.babel.proposals = false - } - } - - if (!warnedAboutStageConfig) { - report.deprecated('babel.stage', ...deprecationMessages) - warnedAboutStageConfig = true - } - } - // config if ('config' in userConfig.babel && typeOf(config) !== 'function') { report.error( diff --git a/src/config/user.js b/src/config/user.js index 9dd33edf..15f8e4b4 100644 --- a/src/config/user.js +++ b/src/config/user.js @@ -116,6 +116,8 @@ export function getProjectType(args = {}) { return userConfig.type } +let warnedAboutPolyfillConfig = false + /** * Validate user config and perform any supported transformations to it. */ @@ -160,12 +162,15 @@ export function processUserConfig({ report.error('type', userConfig.type, `Must be one of: ${joinAnd(Array.from(PROJECT_TYPES), 'or')}`) } - if ('polyfill' in userConfig && typeOf(polyfill) !== 'boolean') { - report.error( - 'polyfill', - `type: ${typeOf(polyfill)}`, - `Must be ${chalk.cyan('Boolean')}` - ) + // TODO Deprecated - remove + if ('polyfill' in userConfig) { + if (!warnedAboutPolyfillConfig) { + report.deprecated( + 'polyfill', + 'Default polyfills were removed in nwb v0.25.0, so polyfill config is no longer supported' + ) + warnedAboutPolyfillConfig = true + } } let argumentOverrides = {} diff --git a/src/config/webpack.js b/src/config/webpack.js index b78bf4e4..caedc7a7 100644 --- a/src/config/webpack.js +++ b/src/config/webpack.js @@ -6,8 +6,6 @@ import {joinAnd, pluralise as s, typeOf} from '../utils' const DEFAULT_STYLE_LOADERS = new Set(['css', 'postcss']) -let warnedAboutUglify = false - export function processWebpackConfig({pluginConfig, report, userConfig}) { let { aliases, @@ -23,7 +21,6 @@ export function processWebpackConfig({pluginConfig, report, userConfig}) { rules, styles, terser, - uglify, extra, config, ...unexpectedConfig @@ -329,22 +326,6 @@ export function processWebpackConfig({pluginConfig, report, userConfig}) { } } - // TODO Deprecated - remove - // uglify - if ('uglify' in userConfig.webpack) { - if (!warnedAboutUglify) { - report.deprecated( - 'webpack.uglify', - `This setting has been renamed to ${chalk.cyan('webpack.terser')} as of nwb v0.24` - ) - warnedAboutUglify = true - if (!('terser' in userConfig.webpack)) { - userConfig.webpack.terser = uglify - terser = uglify - } - } - } - // terser if ('terser' in userConfig.webpack) { if (terser !== false && typeOf(terser) !== 'object') { diff --git a/src/createServerWebpackConfig.js b/src/createServerWebpackConfig.js index 0b3f3983..96fe92e0 100644 --- a/src/createServerWebpackConfig.js +++ b/src/createServerWebpackConfig.js @@ -15,7 +15,7 @@ function getHMRClientEntries(args: Object, serverConfig: ?ServerConfig): string[ if (serverConfig == null) { let hotMiddlewareOptions = args.reload ? '?reload=true' : '' return [ - // Polyfill EventSource for IE, as webpack-hot-middleware/client uses it + // Polyfill EventSource for IE11, as webpack-hot-middleware/client uses it require.resolve('eventsource-polyfill'), require.resolve('webpack-hot-middleware/client') + hotMiddlewareOptions, ] diff --git a/src/createWebpackConfig.js b/src/createWebpackConfig.js index d65e2d31..4af11965 100644 --- a/src/createWebpackConfig.js +++ b/src/createWebpackConfig.js @@ -339,7 +339,7 @@ export function createRules( createRule('babel', { test: /\.js$/, loader: require.resolve('babel-loader'), - exclude: process.env.NWB_TEST ? /(node_modules|nwb[\\/]polyfills\.js$)/ : /node_modules/, + exclude: /node_modules/, options: { // Don't look for .babelrc files babelrc: false, @@ -658,19 +658,6 @@ export function getCompatConfig(userCompatConfig: Object = {}): ?Object { return merge(...configs) } -/** - * Add default polyfills to the head of the entry array. - */ -function addPolyfillsToEntry(entry) { - if (typeOf(entry) === 'array') { - entry.unshift(require.resolve('../polyfills')) - } - else { - // Assumption: there will only be one entry point, naming the entry chunk - entry[Object.keys(entry)[0]].unshift(require.resolve('../polyfills')) - } -} - /** * Create a webpack config with a curated set of default rules suitable for * creating a static build (default) or serving an app with hot reloading. @@ -691,7 +678,6 @@ export default function createWebpackConfig( babel: buildBabelConfig = {}, entry, output: buildOutputConfig, - polyfill: buildPolyfill, plugins: buildPluginConfig = {}, resolve: buildResolveConfig = {}, rules: buildRulesConfig = {}, @@ -737,10 +723,6 @@ export default function createWebpackConfig( } if (entry) { - // Add default polyfills to the entry chunk unless configured not to - if (buildPolyfill !== false && userConfig.polyfill !== false) { - addPolyfillsToEntry(entry) - } webpackConfig.entry = entry } diff --git a/src/moduleBuild.js b/src/moduleBuild.js index d337b3fb..a9d1f8c0 100644 --- a/src/moduleBuild.js +++ b/src/moduleBuild.js @@ -76,7 +76,6 @@ function buildUMD(args, buildConfig, userConfig, cb) { path: path.resolve('umd'), }, externals: createExternals(userConfig.npm.umd.externals), - polyfill: false, plugins: { banner: createBanner(pkg), terser: false, diff --git a/src/quickCommands.js b/src/quickCommands.js index f58edfea..128d1216 100644 --- a/src/quickCommands.js +++ b/src/quickCommands.js @@ -119,10 +119,6 @@ export function createBuildConfig(args: Object, options: QuickConfigOptions) { } } - if (args.polyfill === false || args.polyfills === false) { - config.polyfill = false - } - return merge(config, extraConfig) } @@ -178,10 +174,6 @@ export function createServeConfig(args: Object, options: QuickConfigOptions) { } } - if (args.polyfill === false || args.polyfills === false) { - config.polyfill = false - } - return merge(config, extraConfig) } diff --git a/tests/config-test.js b/tests/config-test.js index e849c10f..5c5e04b6 100644 --- a/tests/config-test.js +++ b/tests/config-test.js @@ -67,15 +67,6 @@ describe('processUserConfig()', () => { it('config file has an invalid type', () => { check({type: 'invalid'}, 'type', /Must be/) }) - // TODO Remove - deprecated - it('babel.stage is not a number, or falsy', () => { - check({babel: {stage: []}}, 'babel.stage', /Must be/) - }) - // TODO Remove - deprecated - it('babel.stage is out of bounds', () => { - check({babel: {stage: -1}}, 'babel.stage', /Must be/) - check({babel: {stage: 4}}, 'babel.stage', /Must be/) - }) it('babel.plugins is not an array', () => { check({babel: {plugins: {}}}, 'babel.plugins', /Must be/) }) diff --git a/tests/createWebpackConfig-test.js b/tests/createWebpackConfig-test.js index 6b5dccec..d95b86c1 100644 --- a/tests/createWebpackConfig-test.js +++ b/tests/createWebpackConfig-test.js @@ -36,8 +36,8 @@ describe('createWebpackConfig()', () => { it('excludes node_modules from babel-loader', () => { expect(config.module.rules[0].exclude.test('node_modules')).toBe(true) }) - it('adds default polyfills to the entry chunk', () => { - expect(config.entry).toEqual([require.resolve('../polyfills'), 'index.js']) + it('uses entry config', () => { + expect(config.entry).toEqual(['index.js']) }) }) @@ -66,13 +66,6 @@ describe('createWebpackConfig()', () => { }) }) - context('with polyfill=false config', () => { - let config = createWebpackConfig({entry: ['index.js'], polyfill: false}) - it('skips default polyfilling', () => { - expect(config.entry).toEqual(['index.js']) - }) - }) - context('configuring styles', () => { let cssPreprocessorPluginConfig = { cssPreprocessors: { diff --git a/tests/fixtures/worst-config.js b/tests/fixtures/worst-config.js index fcf20f11..ed48d9cb 100644 --- a/tests/fixtures/worst-config.js +++ b/tests/fixtures/worst-config.js @@ -15,8 +15,6 @@ module.exports = { removePropTypes: 45, reactConstantElements: 45, runtime: 45, - // TODO Remove - deprecated - stage: 45, config: 45 }, devServer: 45, From c8e9dbf671a045d69f4a91a2d89645bf2621ac25 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sun, 17 May 2020 14:04:05 +1000 Subject: [PATCH 58/66] Added top-level browsers config for configuring browser support with a browserslist query Breaking: configuring webpack.autoprefixer as a browserslist query is deprecated and won't do anything Breaking: default browser support for CSS prefixes when building changed from '>1%, last 4 versions, Firefox ESR, not ie < 9' to '>0.2%, not dead, not op_mini all' #550 --- CHANGES.md | 10 ++++++ docs/Configuration.md | 59 ++++++++++++++++++++++++---------- src/config/user.js | 28 +++++++++++++++- src/config/webpack.js | 16 ++++++--- src/constants.js | 3 ++ src/createWebpackConfig.js | 13 ++++---- tests/config-test.js | 22 +++++++------ tests/fixtures/worst-config.js | 1 + 8 files changed, 115 insertions(+), 37 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index ad470405..c9f92555 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,8 +7,18 @@ - Removed default polyfills for `Promise`, `fetch()` and `Object.assign()` and deprecated `polyfill` config. - If you need to support older browsers, you will need to provide the necessary polyfills yourself. - The [react-app-polyfill](https://github.com/facebook/create-react-app/tree/master/packages/react-app-polyfill#react-app-polyfill) module provides polyfills for IE 9-11, and for stable language features - its instructions also work for apps using nwb. +- Deprecated using a string for [`webpack.autoprefixer` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#autoprefixer-object) to configure supported browsers - this will no longer do anything and should be moved to the new [`browsers` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#browsers-string--arraystring--object). +- Default browser configuration for Autoprefixer when building an app has changed from [`>1%, last 4 versions, Firefox ESR, not ie < 9`](https://browserl.ist/?q=%3E1%25%2C+last+4+versions%2C+Firefox+ESR%2C+not+ie+%3C+9) to [`>0.2%, not dead, not op_mini all`](https://browserl.ist/?q=%3E0.2%25%2C+not+dead%2C+not+op_mini+all). - file-loader v6.0.0 [changed its default hashing algorithm](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#600-2020-03-17). +## Added + +- Added top-level [`browsers` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#browsers-string--arraystring--object) to configure supported browsers. This supports using separate browserslist configuration for development and production. + +## Changed + +- Default browser configuration for Autoprefixer when running the development server for an app has changed from [`>1%, last 4 versions, Firefox ESR, not ie < 9`](https://browserl.ist/?q=%3E1%25%2C+last+4+versions%2C+Firefox+ESR%2C+not+ie+%3C+9) to [`last 1 chrome version, last 1 firefox version, last 1 safari version`](https://browserl.ist/?q=last+1+chrome+version%2C+last+1+firefox+version%2C+last+1+safari+version). + ## Dependencies - chalk: v3.0.0 → [v4.0.0](https://github.com/chalk/chalk/releases/tag/v4.0.0) diff --git a/docs/Configuration.md b/docs/Configuration.md index 786d1e32..307b590d 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -27,7 +27,7 @@ module.exports = { ...or a function which returns a configuration object when called: ```js -module.exports = function(args) { +module.exports = function(nwb) { return { // ... } @@ -68,6 +68,7 @@ The configuration object can include the following properties: - nwb Configuration - [`type`](#type-string-required-for-generic-build-commands) + - [`browsers`](#browsers-string--arraystring--object) - browserslist queries for the browsers your app supports - [Babel Configuration](#babel-configuration) - [`babel`](#babel-object) - [`babel.cherryPick`](#cherrypick-string--arraystring) - enable cherry-picking for destructured `import` statements @@ -85,7 +86,7 @@ The configuration object can include the following properties: - [Webpack Configuration](#webpack-configuration) - [`webpack`](#webpack-object) - [`webpack.aliases`](#aliases-object) - rewrite certain import paths - - [`webpack.autoprefixer`](#autoprefixer-string--object) - options for Autoprefixer + - [`webpack.autoprefixer`](#autoprefixer-object) - options for Autoprefixer - [`webpack.compat`](#compat-object) - enable Webpack compatibility tweaks for commonly-used modules - [`webpack.copy`](#copy-array--object) - patterns and options for `CopyWebpackPlugin` - [`webpack.debug`](#debug-boolean) - create a more debuggable production build @@ -139,6 +140,40 @@ If configured, it must be one of the following: - `'web-app'` - `'web-module'` +#### `browsers`: `String | Array<String> | Object` + +Configures [Browserslist](https://github.com/browserslist/browserslist#browserslist-) queries specifying the range of browsers your app supports. + +If you don't configure this, nwb's default configuration is: + +- `'last 1 chrome version, last 1 firefox version, last 1 safari version'` for development (when running a development server with `nwb serve`) +- `'>0.2%, not dead, not op_mini all'` for production (when building your app with `nwb build`) + +To override the defaults individually, configure an object with `development` or `production` properties: + +```js +module.exports = { + browsers: { + production: '>0.5%, not IE 11' + } +} +``` + +If you configure a string or a list of strings, it will be used for both development and production: + +```js +module.exports = { + browsers: [ + 'last 2 chrome versions', + 'last 2 firefox versions', + 'last 2 safari versions', + 'IE 11' + ] +} +``` + +You can check which browsers your query will target using the [browserl.ist](http://browserl.ist) service. + ### Babel Configuration #### `babel`: `Object` @@ -413,36 +448,26 @@ module.exports = { You should be careful to avoid creating aliases which conflict with the names of Node.js built-ins or npm packages, as you will then be unable to import them. -##### `autoprefixer`: `String | Object` +##### `autoprefixer`: `Object` Configures [Autoprefixer options](https://github.com/postcss/autoprefixer#options) for nwb's default PostCSS configuration. -If you just need to configure the range of browsers prefix addition/removal is based on (nwb's default is `>1%, last 4 versions, Firefox ESR, not ie < 9`), you can use a String: +If you want to configure the range of browsers prefix management is based on, the top-level [`browsers` config](#browsers-string--arraystring--object) is passed to Autoprefixer by default for its `overrideBrowserslist` option. -```js -module.exports = { - webpack: { - autoprefixer: '> 1%, last 2 versions, Firefox ESR, ios >= 8' - } -} -``` - -Use an Object if you need to set any of Autoprefixer's other options. +Provide an Object to configure any of Autoprefixer's other options. -e.g. if you also want to disable removal of prefixes which aren't required for the configured range of browsers: +e.g. if you want to enable grid prefixes for IE 10 and IE 11: ```js module.exports = { webpack: { autoprefixer: { - remove: false, + grid: 'autoplace' } } } ``` -You can check which browsers your Autoprefixer configuration will target using the [browserl.ist](http://browserl.ist) service. - ##### `compat`: `Object` Certain libraries require specific configuration to play nicely with Webpack - nwb can take care of the details for you if you use a `compat` object to tell it when you're using them. diff --git a/src/config/user.js b/src/config/user.js index 15f8e4b4..6207d67a 100644 --- a/src/config/user.js +++ b/src/config/user.js @@ -143,7 +143,9 @@ export function processUserConfig({ let report = new UserConfigReport({configFileExists, configPath}) let { - type, polyfill, + type, browsers, + // TODO Deprecated - remove + polyfill, babel, devServer, karma, npm, webpack: _webpack, // eslint-disable-line no-unused-vars ...unexpectedConfig } = userConfig @@ -162,6 +164,30 @@ export function processUserConfig({ report.error('type', userConfig.type, `Must be one of: ${joinAnd(Array.from(PROJECT_TYPES), 'or')}`) } + if ('browsers' in userConfig) { + if (typeOf(browsers) === 'string' || typeOf(browsers) === 'array') { + userConfig.browsers = { + development: browsers, + production: browsers + } + } + else if (typeOf(browsers) === 'object') { + if (!browsers.hasOwnProperty('development') && !browsers.hasOwnProperty('production')) { + report.hint( + 'browsers', + `You provided ${chalk.cyan('browsers')} config but didn't provide ${chalk.cyan('development')} or ${chalk.cyan('production')} settings` + ) + } + } + else { + report.error( + 'browsers', + `type: ${typeOf(browsers)}`, + `Must be a ${chalk.cyan('String')}, ${chalk.cyan('Array')} or ${chalk.cyan('Object')}` + ) + } + } + // TODO Deprecated - remove if ('polyfill' in userConfig) { if (!warnedAboutPolyfillConfig) { diff --git a/src/config/webpack.js b/src/config/webpack.js index caedc7a7..2c09d187 100644 --- a/src/config/webpack.js +++ b/src/config/webpack.js @@ -6,6 +6,8 @@ import {joinAnd, pluralise as s, typeOf} from '../utils' const DEFAULT_STYLE_LOADERS = new Set(['css', 'postcss']) +let warnedAboutAutoPrefixerString = false + export function processWebpackConfig({pluginConfig, report, userConfig}) { let { aliases, @@ -58,16 +60,22 @@ export function processWebpackConfig({pluginConfig, report, userConfig}) { // autoprefixer if ('autoprefixer' in userConfig.webpack) { - // Convenience: allow Autoprefixer browsers config to be configured as a String + // TODO Deprecated - remove if (typeOf(autoprefixer) === 'string') { - userConfig.webpack.autoprefixer = {overrideBrowserslist: autoprefixer} + if (!warnedAboutAutoPrefixerString) { + report.deprecated( + 'webpack.autoprefixer as a String', + 'Replaced by top-level "browsers" config in nwb v0.25.0 - webpack.autoprefixer can no longer be a String', + ) + warnedAboutAutoPrefixerString = true + } + userConfig.webpack.autoprefixer = {} } else if (typeOf(autoprefixer) !== 'object') { report.error( 'webpack.autoprefixer', `type: ${typeOf(autoprefixer)}`, - `Must be a ${chalk.cyan('String')} (for ${chalk.cyan('browsers')} config only) ` + - `or an ${chalk.cyan('Object')} (for any Autoprefixer options)` + `Must be an ${chalk.cyan('Object')}` ) } } diff --git a/src/constants.js b/src/constants.js index ddbb5a68..1579da1e 100644 --- a/src/constants.js +++ b/src/constants.js @@ -17,3 +17,6 @@ export const PROJECT_TYPES = new Set([ WEB_APP, WEB_MODULE, ]) + +export const DEFAULT_BROWSERS_DEV = 'last 1 chrome version, last 1 firefox version, last 1 safari version' +export const DEFAULT_BROWSERS_PROD = '>0.2%, not dead, not op_mini all' diff --git a/src/createWebpackConfig.js b/src/createWebpackConfig.js index 4af11965..1d6bb13c 100644 --- a/src/createWebpackConfig.js +++ b/src/createWebpackConfig.js @@ -12,6 +12,7 @@ import webpack from 'webpack' import merge from 'webpack-merge' import createBabelConfig from './createBabelConfig' +import {DEFAULT_BROWSERS_DEV, DEFAULT_BROWSERS_PROD} from './constants' import debug from './debug' import {UserError} from './errors' import {deepToString, replaceArrayMerge, typeOf} from './utils' @@ -590,14 +591,14 @@ export function createPlugins( } function createDefaultPostCSSPlugins(userWebpackConfig) { + let overrideBrowserslist = process.env.NODE_ENV === 'production' + ? (userWebpackConfig.browsers && userWebpackConfig.browsers.production) || + DEFAULT_BROWSERS_PROD + : (userWebpackConfig.browsers && userWebpackConfig.browsers.development) || + DEFAULT_BROWSERS_DEV return [ autoprefixer({ - overrideBrowserslist: [ - '>1%', - 'last 4 versions', - 'Firefox ESR', - 'not ie < 9', - ], + overrideBrowserslist, ...userWebpackConfig.autoprefixer }) ] diff --git a/tests/config-test.js b/tests/config-test.js index 5c5e04b6..632ccc70 100644 --- a/tests/config-test.js +++ b/tests/config-test.js @@ -64,9 +64,12 @@ function process(config) { describe('processUserConfig()', () => { describe('validation', () => { - it('config file has an invalid type', () => { + it('type is not a string', () => { check({type: 'invalid'}, 'type', /Must be/) }) + it('browsers is an invalid type', () => { + check({browsers: /invalid/}, 'browsers', /Must be/) + }) it('babel.plugins is not an array', () => { check({babel: {plugins: {}}}, 'babel.plugins', /Must be/) }) @@ -76,10 +79,7 @@ describe('processUserConfig()', () => { it('babel.proposals is not an object or false', () => { check({babel: {proposals: /invalid/}}, 'babel.proposals', /Must be/) }) - it('babel.react is not an string or an object', () => { - check({babel: {react: /invalid/}}, 'babel.react', /Must be/) - }) - it('babel.react is not an string or an object', () => { + it('babel.react is not a string or an object', () => { check({babel: {react: /invalid/}}, 'babel.react', /Must be/) }) it('babel.reactConstantElements is not a boolean', () => { @@ -200,6 +200,14 @@ describe('processUserConfig()', () => { }) describe('convenience shorthand', () => { + it('allows browsers to be a string', () => { + let config = process({browsers: 'test'}) + expect(config.browsers).toEqual({development: 'test', production: 'test'}) + }) + it('allows browsers to be an array', () => { + let config = process({browsers: ['test']}) + expect(config.browsers).toEqual({development: ['test'], production: ['test']}) + }) it('allows babel.react to be a string', () => { let config = process({babel: {react: 'test'}}) expect(config.babel.react).toEqual({runtime: 'test'}) @@ -208,10 +216,6 @@ describe('processUserConfig()', () => { let config = process({npm: {umd: 'test'}}) expect(config.npm.umd).toEqual({global: 'test'}) }) - it('allows webpack.autoprefixer to be a browser string', () => { - let config = process({webpack: {autoprefixer: 'test'}}) - expect(config.webpack.autoprefixer).toEqual({overrideBrowserslist: 'test'}) - }) it('allows webpack.copy to be an array', () => { let config = process({webpack: {copy: ['test']}}) expect(config.webpack.copy).toEqual({patterns: ['test']}) diff --git a/tests/fixtures/worst-config.js b/tests/fixtures/worst-config.js index ed48d9cb..4c44b964 100644 --- a/tests/fixtures/worst-config.js +++ b/tests/fixtures/worst-config.js @@ -1,6 +1,7 @@ // A config file in which everything is wrong module.exports = { type: 'invalid', + browsers: 45, polyfill: 45, invalidTopLevelConfig: true, moreInvalidTopLevelConfig: true, From d028177e9f33f545141971eaa308f02317f5b137 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Sun, 17 May 2020 14:45:21 +1000 Subject: [PATCH 59/66] Update dependencies Breaking: copy-webpack-plugin has breaking config changes in both its patterns and options --- CHANGES.md | 8 ++++++-- docs/Features.md | 2 +- package.json | 4 ++-- src/appCommands.js | 12 ++++++++++-- src/createWebpackConfig.js | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index c9f92555..52f707d3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,10 +5,13 @@ - Node.js 8 is no longer supported; Node.js 10.13.0 is now the minimum required version, as per many of nwb's dependencies. - Removed support for deprecated `babel.stage` and `webpack.uglify` config. - Removed default polyfills for `Promise`, `fetch()` and `Object.assign()` and deprecated `polyfill` config. - - If you need to support older browsers, you will need to provide the necessary polyfills yourself. + - If you need to support older browsers, you will now need to provide the necessary polyfills yourself in your app. - The [react-app-polyfill](https://github.com/facebook/create-react-app/tree/master/packages/react-app-polyfill#react-app-polyfill) module provides polyfills for IE 9-11, and for stable language features - its instructions also work for apps using nwb. - Deprecated using a string for [`webpack.autoprefixer` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#autoprefixer-object) to configure supported browsers - this will no longer do anything and should be moved to the new [`browsers` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#browsers-string--arraystring--object). - Default browser configuration for Autoprefixer when building an app has changed from [`>1%, last 4 versions, Firefox ESR, not ie < 9`](https://browserl.ist/?q=%3E1%25%2C+last+4+versions%2C+Firefox+ESR%2C+not+ie+%3C+9) to [`>0.2%, not dead, not op_mini all`](https://browserl.ist/?q=%3E0.2%25%2C+not+dead%2C+not+op_mini+all). +- copy-webpack-plugin v6.0.0 [has breaking changes to its options](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#600-2020-05-15) which you should read if you've configured the [`webpack.copy` option](https://github.com/insin/nwb/blob/master/docs/Configuration.md#copy-array--object). + + In particular, the `ignore` option in a copy pattern must now be put inside the new `globOptions` option. - file-loader v6.0.0 [changed its default hashing algorithm](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#600-2020-03-17). ## Added @@ -22,9 +25,10 @@ ## Dependencies - chalk: v3.0.0 → [v4.0.0](https://github.com/chalk/chalk/releases/tag/v4.0.0) +- copy-webpack-plugin: v5.1.1 → [v6.0.1](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#601-2020-05-16) - file-loader: v4.3.0 → [v6.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#600-2020-03-17) - fs-extra: v8.1.0 → [v9.0.0](https://github.com/jprichardson/node-fs-extra/blob/master/CHANGELOG.md#900--2020-03-19) -- karma: v4.4.1 → [v5.0.5](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md#505-2020-05-07) +- karma: v4.4.1 → [v5.0.7](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md#507-2020-05-16) - karma-mocha: v1.3.0 → [v2.0.1](https://github.com/karma-runner/karma-mocha/blob/master/CHANGELOG.md#201-2020-04-29) - terser-webpack-plugin v2.3.6 → [v3.0.1](https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/CHANGELOG.md#301-2020-05-06) - url-loader: v2.3.0→ [v4.1.0](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md) diff --git a/docs/Features.md b/docs/Features.md index 7ce7b52d..1524ec54 100644 --- a/docs/Features.md +++ b/docs/Features.md @@ -1,7 +1,7 @@ ## Features - **A toolkit, not a boilerplate.** -- Uses [Webpack 4](https://webpack.js.org/), [Babel 7](https://babeljs.io/) and [Karma 4](https://karma-runner.github.io/). +- Uses [Webpack 4](https://webpack.js.org/), [Babel 7](https://babeljs.io/) and [Karma 5](https://karma-runner.github.io/). - Provides tooling for [React](https://facebook.github.io/react/) apps and components, [Preact](https://preactjs.com/) apps, [Inferno](https://infernojs.org/) apps, and vanilla JS web apps and npm modules. - Use modern JavaScript features, and JSX. - Use proposed JavaScript features now. diff --git a/package.json b/package.json index 8f8f1ede..1025558d 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "babel-preset-proposals": "0.3.0", "react-refresh": "0.8.2", - "karma": "5.0.5", + "karma": "5.0.7", "karma-chrome-launcher": "3.1.0", "karma-coverage": "2.0.2", "karma-mocha": "2.0.1", @@ -84,7 +84,7 @@ "autoprefixer": "9.7.6", "babel-loader": "8.1.0", "case-sensitive-paths-webpack-plugin": "2.3.0", - "copy-webpack-plugin": "5.1.1", + "copy-webpack-plugin": "6.0.1", "css-loader": "3.5.3", "eventsource-polyfill": "0.9.6", "file-loader": "6.0.0", diff --git a/src/appCommands.js b/src/appCommands.js index c9388a4b..7d88b226 100644 --- a/src/appCommands.js +++ b/src/appCommands.js @@ -75,7 +75,11 @@ export function createBuildConfig(args: Object, extra: Object = {}) { } if (directoryExists('public')) { - config.plugins.copy = [{from: path.resolve('public'), to: dist, ignore: ['.gitkeep']}] + config.plugins.copy = [{ + from: path.resolve('public'), + to: dist, + globOptions: {ignore: ['.gitkeep']} + }] } return merge(config, extra) @@ -102,7 +106,11 @@ export function createServeConfig(args: Object, ...extra: Object[]) { } if (directoryExists('public')) { - config.plugins.copy = [{from: path.resolve('public'), to: dist, ignore: ['.gitkeep']}] + config.plugins.copy = [{ + from: path.resolve('public'), + to: dist, + globOptions: {ignore: ['.gitkeep']} + }] } return merge(config, ...extra) diff --git a/src/createWebpackConfig.js b/src/createWebpackConfig.js index 1d6bb13c..e25eaf6b 100644 --- a/src/createWebpackConfig.js +++ b/src/createWebpackConfig.js @@ -562,7 +562,7 @@ export function createPlugins( if (buildConfig.copy || userConfig.copy) { const [patterns, options] = getCopyPluginArgs(buildConfig.copy, userConfig.copy) if (patterns.length > 0) { - plugins.push(new CopyPlugin(patterns, options)) + plugins.push(new CopyPlugin({patterns, options})) } } From 524a642eb595ca5c5dc7d40c77999e1f0e5ba27c Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Mon, 18 May 2020 15:35:20 +1000 Subject: [PATCH 60/66] Add targets config for preset-env Add preset-env config to support polyfilling with core-js@3 Add Babel plugins (temporarily) for nullish coalescing and optional chaining, as Webpack can't currently handle these untranspiled Add BrowserSupport docs Closes #550 --- CHANGES.md | 39 +++++++++++---- docs/BrowserSupport.md | 81 +++++++++++++++++++++++++++++++ docs/Configuration.md | 2 + docs/Features.md | 2 +- package.json | 2 + src/appCommands.js | 17 +++++++ src/commands/build-demo.js | 7 +++ src/commands/serve-react-demo.js | 7 +++ src/createBabelConfig.js | 41 ++++++++++++++-- src/createWebpackConfig.js | 8 ++- src/quickCommands.js | 13 +++++ tests/createBabelConfig-test.js | 68 ++++++++++++++++++++++++++ tests/createWebpackConfig-test.js | 2 +- 13 files changed, 271 insertions(+), 18 deletions(-) create mode 100644 docs/BrowserSupport.md diff --git a/CHANGES.md b/CHANGES.md index 52f707d3..3f8fc8b2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,24 +3,43 @@ ## Breaking Changes - Node.js 8 is no longer supported; Node.js 10.13.0 is now the minimum required version, as per many of nwb's dependencies. -- Removed support for deprecated `babel.stage` and `webpack.uglify` config. + +**Browser Support** + - Removed default polyfills for `Promise`, `fetch()` and `Object.assign()` and deprecated `polyfill` config. - - If you need to support older browsers, you will now need to provide the necessary polyfills yourself in your app. - - The [react-app-polyfill](https://github.com/facebook/create-react-app/tree/master/packages/react-app-polyfill#react-app-polyfill) module provides polyfills for IE 9-11, and for stable language features - its instructions also work for apps using nwb. -- Deprecated using a string for [`webpack.autoprefixer` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#autoprefixer-object) to configure supported browsers - this will no longer do anything and should be moved to the new [`browsers` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#browsers-string--arraystring--object). + + If you need to support older browsers, you will now need to include the necessary polyfills in your app - see the new [Browser Support docs](https://github.com/insin/nwb/blob/master/docs/BrowserSupport.md#browser-support) for details on polyfilling and suggested modules it's to provide them. + + If this change affects your app, a quick fix is to use [react-app-polyfill](https://github.com/facebook/create-react-app/tree/master/packages/react-app-polyfill)'s IE11 polyfill, which is equivalent to what nwb's default polyfill used to be: + + ```js + import 'react-app-polyfill/ie11' + ``` + +- For apps and quick commands, `@babel/preset-env` is now configured to [only transpile the necessary ECMAScript 2015+ for supported browsers](https://github.com/insin/nwb/blob/master/docs/BrowserSupport.md#default-browser-support). + + When running a development server, this defaults to the most recent version of Chrome, Firefox or Safari, so you _may_ need to adjust [`browsers.development` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#browsers-string--arraystring--object) if you're using an out of date browser and you **will** need to adjust it if you're developing with an older browser supported by your app. + - Default browser configuration for Autoprefixer when building an app has changed from [`>1%, last 4 versions, Firefox ESR, not ie < 9`](https://browserl.ist/?q=%3E1%25%2C+last+4+versions%2C+Firefox+ESR%2C+not+ie+%3C+9) to [`>0.2%, not dead, not op_mini all`](https://browserl.ist/?q=%3E0.2%25%2C+not+dead%2C+not+op_mini+all). -- copy-webpack-plugin v6.0.0 [has breaking changes to its options](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#600-2020-05-15) which you should read if you've configured the [`webpack.copy` option](https://github.com/insin/nwb/blob/master/docs/Configuration.md#copy-array--object). + + When running a development server, the default browser configuration has changed to [`last 1 chrome version, last 1 firefox version, last 1 safari version`](https://browserl.ist/?q=last+1+chrome+version%2C+last+1+firefox+version%2C+last+1+safari+version). + +**Configuration** + +- Deprecated using a string for [`webpack.autoprefixer` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#autoprefixer-object) to configure supported browsers - this will no longer do anything and should be moved to the new [`browsers` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#browsers-string--arraystring--object). +- Removed support for `babel.stage` and `webpack.uglify` config deprecated in nwb v0.24.0. +- copy-webpack-plugin v6.0.0 [has breaking changes to its options](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#600-2020-05-15) which you should read if you're using [`webpack.copy` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#copy-array--object). In particular, the `ignore` option in a copy pattern must now be put inside the new `globOptions` option. -- file-loader v6.0.0 [changed its default hashing algorithm](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#600-2020-03-17). -## Added +**Dependencies** -- Added top-level [`browsers` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#browsers-string--arraystring--object) to configure supported browsers. This supports using separate browserslist configuration for development and production. +- file-loader v6.0.0 [changed its default hashing algorithm](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#600-2020-03-17) so hashes in output filenames will change after updating to this release, even if their contents haven't changed. -## Changed +## Added -- Default browser configuration for Autoprefixer when running the development server for an app has changed from [`>1%, last 4 versions, Firefox ESR, not ie < 9`](https://browserl.ist/?q=%3E1%25%2C+last+4+versions%2C+Firefox+ESR%2C+not+ie+%3C+9) to [`last 1 chrome version, last 1 firefox version, last 1 safari version`](https://browserl.ist/?q=last+1+chrome+version%2C+last+1+firefox+version%2C+last+1+safari+version). +- Added top-level [`browsers` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#browsers-string--arraystring--object) to configure supported browsers. This supports using separate browserslist queries for development and production. +- Added [Browser Support docs](https://github.com/insin/nwb/blob/master/docs/BrowserSupport.md#browser-support), with a section on [polyfilling missing language features](https://github.com/insin/nwb/blob/master/docs/BrowserSupport.md#polyfilling-missing-language-features). ## Dependencies diff --git a/docs/BrowserSupport.md b/docs/BrowserSupport.md new file mode 100644 index 00000000..b1aab0d5 --- /dev/null +++ b/docs/BrowserSupport.md @@ -0,0 +1,81 @@ +## Browser Support + +nwb's default configuration supports modern browsers. Support for Internet Explorer 9, 10 and 11 requires [polyfills](#supporting-internet-explorer). + +### Default Browser Support + +nwb uses the following [Browserslist](https://github.com/browserslist/browserslist#browserslist-) queries by default: + +- [`last 1 chrome version, last 1 firefox version, last 1 safari version`](https://browserl.ist/?q=last+1+chrome+version%2C+last+1+firefox+version%2C+last+1+safari+version) for development, when running the development server with `nwb serve` (or quick commands such as `npm react run`) +- [`>0.2%, not dead, not op_mini all`](https://browserl.ist/?q=%3E0.2%25%2C+not+dead%2C+not+op_mini+all) for production, when creating a build with `nwb build` (or quick commands such as `npm react build`) + +> Use the links above to check which browsers and versions these queries currently resolve to. + +These are used to configure: + +- [`@babel/preset-env`'s `targets` option](https://babeljs.io/docs/en/babel-preset-env#targets), so it only transpiles the necessary ECMAScript 2015+ for supported browsers. +- [Autoprefixer's `overrideBrowserslist` option](https://github.com/postcss/autoprefixer#options), so it only includes the necessary CSS prefixes for supported browsers. + +### Configuring Browser Support + +If your app needs to support more (or fewer!) browsers, you can tweak browser support settings using [`browsers` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#browsers-string--arraystring--object). + +Broadening the range of supported browsers will ensure your app works for everone who needs to use it, while narrowing the range may help decrease your bundle sizes, if less code needs to be transpiled and fewer Babel helpers need to be imported. + +For example, IE9 is considered a "dead" browser in Browserslist queries, so if you needed to support it, you could specifically enable it in [`browsers.production` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#browsers-string--arraystring--object) like so: + +```js +module.exports = { + browsers { + production: '>0.2%, not dead, not op_mini all, ie 9' + } +} +``` + +You can see that [IE 9 has now been added](https://browserl.ist/?q=%3E0.2%25%2C+not+dead%2C+not+op_mini+all%2C+ie+9) to the list of supported browsers. + +## Polyfilling Missing Language Features + +### Supporting Internet Explorer + +[react-app-polyfill](https://github.com/facebook/create-react-app/tree/master/packages/react-app-polyfill#react-app-polyfill) provides convenient collection of polyfills for IE9 and IE11. + +If you need to support Internet Explorer, install react-app-polyfill and import the appropriate polyfill entry point as the first thing in your app's entry point (usually `src/index.js`): + +``` +npm install react-app-polyfill +``` +```js +import 'react-app-polyfill/ie11' +``` + +See [react-app-polyfill's Supporting Internet Explorer docs](https://github.com/facebook/create-react-app/tree/master/packages/react-app-polyfill#supporting-internet-explorer) for more details. + +### Manual Polyfilling + +If there are specific language features missing from one of your supported browsers, you can polyfill them manually by installing [core-js](https://github.com/zloirock/core-js#core-js) and importing the appropriate polyfills at the top of your app's entry point (usually `src/index.js`). + +e.g. if you want to use [`Object.values()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Object/values) in your app, but one of your target browsers doesn't support it: + +``` +npm install core-js +``` +```js +import 'core-js/features/object/values' +``` + +### Automatic Polyfilling + +nwb configures `@babel/preset-env`'s [`useBuiltins: 'entry'` option](https://babeljs.io/docs/en/next/babel-preset-env), which will look for a core-js entry point import in your code and replace it with a specific list of polyfill imports to cover the range of supported browsers. See the [core-js docs for an example of this feature in action](https://github.com/zloirock/core-js#babelpreset-env). + +To make use of this, import a core-js entry point at the top of your app's entry point (usually `src/index.js`): + +```js +import 'core-js/stable' +``` + +react-app-polyfill also provides [an entry point for polyfilling stable language features using core-js](https://github.com/facebook/create-react-app/tree/master/packages/react-app-polyfill#polyfilling-other-language-features), so nwb's Babel config supports transpiling react-app-polyfill to allow `@babel/preset-env` to do its thing: + +```js +import 'react-app-polyfill/stable' +``` diff --git a/docs/Configuration.md b/docs/Configuration.md index 307b590d..70ea885e 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -144,6 +144,8 @@ If configured, it must be one of the following: Configures [Browserslist](https://github.com/browserslist/browserslist#browserslist-) queries specifying the range of browsers your app supports. +This is used to configure [`@babel/preset-env`](https://babeljs.io/docs/en/babel-preset-env#targets) (so it only transpiles the necessary ECMAScript 2015+ for your target browsers) and [Autoprefixer](https://github.com/postcss/autoprefixer#browsers) (for managing vendor prefixes in your CSS). + If you don't configure this, nwb's default configuration is: - `'last 1 chrome version, last 1 firefox version, last 1 safari version'` for development (when running a development server with `nwb serve`) diff --git a/docs/Features.md b/docs/Features.md index 1524ec54..98e7578e 100644 --- a/docs/Features.md +++ b/docs/Features.md @@ -3,7 +3,7 @@ - **A toolkit, not a boilerplate.** - Uses [Webpack 4](https://webpack.js.org/), [Babel 7](https://babeljs.io/) and [Karma 5](https://karma-runner.github.io/). - Provides tooling for [React](https://facebook.github.io/react/) apps and components, [Preact](https://preactjs.com/) apps, [Inferno](https://infernojs.org/) apps, and vanilla JS web apps and npm modules. -- Use modern JavaScript features, and JSX. +- Use modern JavaScript features and JSX. - Use proposed JavaScript features now. - Import CSS (and font resources) and images to be managed by Webpack. - [Autoprefixed](https://github.com/postcss/autoprefixer#autoprefixer-) CSS, so you don't need to write browser prefixes; you can also configure your own [PostCSS](https://postcss.org/) plugins. diff --git a/package.json b/package.json index 1025558d..acc5324f 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,8 @@ "@babel/cli": "7.8.4", "@babel/core": "7.9.6", + "@babel/plugin-proposal-nullish-coalescing-operator": "7.8.3", + "@babel/plugin-proposal-optional-chaining": "7.9.0", "@babel/plugin-syntax-dynamic-import": "7.8.3", "@babel/plugin-syntax-jsx": "7.8.3", "@babel/plugin-transform-react-constant-elements": "7.9.0", diff --git a/src/appCommands.js b/src/appCommands.js index 7d88b226..30d7c67d 100644 --- a/src/appCommands.js +++ b/src/appCommands.js @@ -6,6 +6,7 @@ import runSeries from 'run-series' import merge from 'webpack-merge' import cleanApp from './commands/clean-app' +import {DEFAULT_BROWSERS_DEV, DEFAULT_BROWSERS_PROD} from './constants' import {directoryExists, install} from './utils' import webpackBuild from './webpackBuild' import webpackServer from './webpackServer' @@ -58,6 +59,14 @@ export function createBuildConfig(args: Object, extra: Object = {}) { let filenamePattern = production ? '[name].[chunkhash:8].js' : '[name].js' let config: Object = { + babel: { + env: { + targets: DEFAULT_BROWSERS_PROD, + useBuiltIns: 'entry', + corejs: 3, + exclude: ['transform-typeof-symbol'], + }, + }, devtool: 'source-map', entry: { app: [entry], @@ -94,6 +103,14 @@ export function createServeConfig(args: Object, ...extra: Object[]) { let dist = path.resolve(args._[2] || 'dist') let config: Object = { + babel: { + env: { + targets: DEFAULT_BROWSERS_DEV, + useBuiltIns: 'entry', + corejs: 3, + exclude: ['transform-typeof-symbol'], + }, + }, entry: [entry], output: { path: dist, diff --git a/src/commands/build-demo.js b/src/commands/build-demo.js index da71e8c4..de82ee14 100644 --- a/src/commands/build-demo.js +++ b/src/commands/build-demo.js @@ -2,6 +2,7 @@ import path from 'path' import runSeries from 'run-series' +import {DEFAULT_BROWSERS_PROD} from '../constants' import {directoryExists} from '../utils' import webpackBuild from '../webpackBuild' import cleanDemo from './clean-demo' @@ -15,6 +16,12 @@ function getCommandConfig(args) { let config = { babel: { + env: { + targets: DEFAULT_BROWSERS_PROD, + useBuiltIns: 'entry', + corejs: 3, + exclude: ['transform-typeof-symbol'], + }, presets: ['react'], }, devtool: 'source-map', diff --git a/src/commands/serve-react-demo.js b/src/commands/serve-react-demo.js index 85934eb6..1634162d 100644 --- a/src/commands/serve-react-demo.js +++ b/src/commands/serve-react-demo.js @@ -1,5 +1,6 @@ import path from 'path' +import {DEFAULT_BROWSERS_DEV} from '../constants' import {directoryExists} from '../utils' import webpackServer from '../webpackServer' @@ -13,6 +14,12 @@ export default function serveReactDemo(args, cb) { let config = { babel: { + env: { + targets: DEFAULT_BROWSERS_DEV, + useBuiltIns: 'entry', + corejs: 3, + exclude: ['transform-typeof-symbol'], + }, presets: ['react'], }, entry: [path.resolve('demo/src/index.js')], diff --git a/src/createBabelConfig.js b/src/createBabelConfig.js index d3e06ac9..8de2df54 100644 --- a/src/createBabelConfig.js +++ b/src/createBabelConfig.js @@ -23,6 +23,11 @@ type BuildOptions = { webpack?: boolean, }; +type BrowserOptions = { + development?: string | string[], + production?: string | string[], +} + type UserOptions = { cherryPick?: string | string[], config?: (BabelConfig) => BabelConfig, @@ -40,11 +45,13 @@ type UserOptions = { export default function createBabelConfig( buildConfig: BuildOptions = {}, userConfig: UserOptions = {}, - userConfigPath: string = '' + userConfigPath: string = '', + userConfigBrowsers: BrowserOptions = {}, ): BabelConfig { let { absoluteRuntime, commonJSInterop, + env: buildEnv = {}, modules = false, plugins: buildPlugins = [], presets: buildPresets, @@ -57,7 +64,7 @@ export default function createBabelConfig( let { cherryPick, config: userConfigFunction, - env = {}, + env: userEnv = {}, loose, plugins: userPlugins = [], presets: userPresets, @@ -69,15 +76,41 @@ export default function createBabelConfig( } = userConfig let presets: BabelPluginConfig[] = [] - let plugins: BabelPluginConfig[] = [] + let plugins: BabelPluginConfig[] = [ + // XXX Webpack can't currently handle untranspiled ?. and ?? syntax + // See https://github.com/webpack/webpack/issues/10227#issuecomment-588409413 + require.resolve('@babel/plugin-proposal-optional-chaining'), + require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'), + ] // Default to loose mode unless explicitly configured if (typeof loose === 'undefined') { loose = true } + // Build config controls whether or not we set browser targets. Users can + // override this using `browsers` or `babel.env.targets` config. + let userTargets = {} + if (buildEnv.targets) { + let targets = userConfigBrowsers && ( + process.env.NODE_ENV === 'production' + ? userConfigBrowsers.production + : userConfigBrowsers.development + ) + if (targets) { + userTargets.targets = targets + } + } presets.push( - [require.resolve('@babel/preset-env'), {loose, modules, ...env}] + [require.resolve('@babel/preset-env'), { + loose, + ...buildEnv, + modules, + // Targets config from top-level browsers config if present + ...userTargets, + // The user gets a last go at all the env options + ...userEnv + }] ) // Additional build presets diff --git a/src/createWebpackConfig.js b/src/createWebpackConfig.js index e25eaf6b..c5f894d2 100644 --- a/src/createWebpackConfig.js +++ b/src/createWebpackConfig.js @@ -340,7 +340,7 @@ export function createRules( createRule('babel', { test: /\.js$/, loader: require.resolve('babel-loader'), - exclude: /node_modules/, + exclude: /node_modules[\\/](?!react-app-polyfill)/, options: { // Don't look for .babelrc files babelrc: false, @@ -591,6 +591,8 @@ export function createPlugins( } function createDefaultPostCSSPlugins(userWebpackConfig) { + // Users can override browser versions for Autoprefixer using `browsers` or + // `webpack.autoprefixer.overrideBrowserslist` config. let overrideBrowserslist = process.env.NODE_ENV === 'production' ? (userWebpackConfig.browsers && userWebpackConfig.browsers.production) || DEFAULT_BROWSERS_PROD @@ -699,7 +701,9 @@ export default function createWebpackConfig( } // Generate config for babel-loader and set it as loader config for the build - buildRulesConfig.babel = {options: createBabelConfig(buildBabelConfig, userConfig.babel, userConfig.path)} + buildRulesConfig.babel = { + options: createBabelConfig(buildBabelConfig, userConfig.babel, userConfig.path, userConfig.browsers) + } let webpackConfig = { mode: process.env.NODE_ENV === 'production' ? 'production' : 'development', diff --git a/src/quickCommands.js b/src/quickCommands.js index 128d1216..1a36091c 100644 --- a/src/quickCommands.js +++ b/src/quickCommands.js @@ -6,6 +6,7 @@ import runSeries from 'run-series' import merge from 'webpack-merge' import cleanApp from './commands/clean-app' +import {DEFAULT_BROWSERS_DEV, DEFAULT_BROWSERS_PROD} from './constants' import {UserError} from './errors' import {install} from './utils' import webpackBuild from './webpackBuild' @@ -80,6 +81,12 @@ export function createBuildConfig(args: Object, options: QuickConfigOptions) { let config: Object = { babel: { + env: { + targets: DEFAULT_BROWSERS_PROD, + useBuiltIns: 'entry', + corejs: 3, + exclude: ['transform-typeof-symbol'], + }, proposals: { all: true } @@ -140,6 +147,12 @@ export function createServeConfig(args: Object, options: QuickConfigOptions) { let config: Object = { babel: { + env: { + targets: DEFAULT_BROWSERS_DEV, + useBuiltIns: 'entry', + corejs: 3, + exclude: ['transform-typeof-symbol'], + }, proposals: { all: true } diff --git a/tests/createBabelConfig-test.js b/tests/createBabelConfig-test.js index fa32130a..458056df 100644 --- a/tests/createBabelConfig-test.js +++ b/tests/createBabelConfig-test.js @@ -23,6 +23,11 @@ let DEFAULT_PROPOSALS_CONFIG = loose: true, }] +let DEFAULT_PLUGINS_CONFIG = [ + require.resolve('@babel/plugin-proposal-optional-chaining'), + require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'), +] + describe('createBabelConfig()', () => { context('without any build or user config', () => { it('generates default Babel config', () => { @@ -32,6 +37,7 @@ describe('createBabelConfig()', () => { DEFAULT_PROPOSALS_CONFIG, ], plugins: [ + ...DEFAULT_PLUGINS_CONFIG, DEFAULT_RUNTIME_CONFIG, require.resolve('@babel/plugin-syntax-dynamic-import'), ] @@ -49,6 +55,7 @@ describe('createBabelConfig()', () => { DEFAULT_PROPOSALS_CONFIG, ], plugins: [ + ...DEFAULT_PLUGINS_CONFIG, [require.resolve('@babel/plugin-transform-runtime'), { absoluteRuntime: ABSOLUTE_RUNTIME_PATH, useESModules: false, @@ -57,6 +64,36 @@ describe('createBabelConfig()', () => { ], }) }) + it('merges env config', () => { + expect(createBabelConfig({ + env: { + targets: 'build browsers', + useBuiltIns: 'entry', + corejs: 3, + exclude: ['transform-typeof-symbol'], + } + })).toEqual({ + presets: [ + [require.resolve('@babel/preset-env'), { + loose: true, + modules: false, + targets: 'build browsers', + useBuiltIns: 'entry', + corejs: 3, + exclude: ['transform-typeof-symbol'], + }], + DEFAULT_PROPOSALS_CONFIG, + ], + plugins: [ + ...DEFAULT_PLUGINS_CONFIG, + [require.resolve('@babel/plugin-transform-runtime'), { + absoluteRuntime: ABSOLUTE_RUNTIME_PATH, + useESModules: true, + }], + require.resolve('@babel/plugin-syntax-dynamic-import'), + ], + }) + }) it('adds the @babel/preset-react preset given a "react" preset', () => { expect(createBabelConfig({ presets: ['react'], @@ -68,6 +105,7 @@ describe('createBabelConfig()', () => { [require.resolve('@babel/preset-react'), {development: true}], ], plugins: [ + ...DEFAULT_PLUGINS_CONFIG, DEFAULT_RUNTIME_CONFIG, require.resolve('@babel/plugin-syntax-dynamic-import'), ], @@ -83,6 +121,7 @@ describe('createBabelConfig()', () => { [require.resolve('@babel/preset-env'), {loose: true, modules: false}], ], plugins: [ + ...DEFAULT_PLUGINS_CONFIG, require.resolve('@babel/plugin-transform-react-constant-elements'), [require.resolve('babel-plugin-transform-react-remove-prop-types'), {}], DEFAULT_RUNTIME_CONFIG, @@ -100,6 +139,7 @@ describe('createBabelConfig()', () => { [require.resolve('@babel/preset-env'), {loose: true, modules: false}], ], plugins: [ + ...DEFAULT_PLUGINS_CONFIG, [require.resolve('babel-plugin-transform-react-remove-prop-types'), {}], DEFAULT_RUNTIME_CONFIG, require.resolve('@babel/plugin-syntax-dynamic-import'), @@ -115,6 +155,7 @@ describe('createBabelConfig()', () => { DEFAULT_PROPOSALS_CONFIG, ], plugins: [ + ...DEFAULT_PLUGINS_CONFIG, [require.resolve('@babel/plugin-transform-runtime'), { absoluteRuntime: false, useESModules: true, @@ -149,6 +190,7 @@ describe('createBabelConfig()', () => { 'test-preset', ], plugins: [ + ...DEFAULT_PLUGINS_CONFIG, 'test-plugin', DEFAULT_RUNTIME_CONFIG, require.resolve('@babel/plugin-syntax-dynamic-import'), @@ -164,6 +206,7 @@ describe('createBabelConfig()', () => { DEFAULT_PROPOSALS_CONFIG, ], plugins: [ + ...DEFAULT_PLUGINS_CONFIG, [require.resolve('@babel/plugin-transform-runtime'), { absoluteRuntime: ABSOLUTE_RUNTIME_PATH, useESModules: true, @@ -173,6 +216,27 @@ describe('createBabelConfig()', () => { ] }) }) + it('uses user browser config when the build has env.targets', () => { + expect(createBabelConfig( + {env: {targets: 'build'}}, + {}, + '', + {development: 'user'} + )).toEqual({ + presets: [ + [require.resolve('@babel/preset-env'), {loose: true, modules: false, targets: 'user'}], + DEFAULT_PROPOSALS_CONFIG, + ], + plugins: [ + ...DEFAULT_PLUGINS_CONFIG, + [require.resolve('@babel/plugin-transform-runtime'), { + absoluteRuntime: ABSOLUTE_RUNTIME_PATH, + useESModules: true, + }], + require.resolve('@babel/plugin-syntax-dynamic-import'), + ] + }) + }) }) context('with build and user config', () => { @@ -191,6 +255,7 @@ describe('createBabelConfig()', () => { }] ], plugins: [ + ...DEFAULT_PLUGINS_CONFIG, DEFAULT_RUNTIME_CONFIG, require.resolve('@babel/plugin-syntax-dynamic-import'), ] @@ -210,6 +275,7 @@ describe('createBabelConfig()', () => { }] ], plugins: [ + ...DEFAULT_PLUGINS_CONFIG, DEFAULT_RUNTIME_CONFIG, require.resolve('@babel/plugin-syntax-dynamic-import'), ] @@ -221,6 +287,7 @@ describe('createBabelConfig()', () => { [require.resolve('@babel/preset-env'), {loose: true, modules: false}], ], plugins: [ + ...DEFAULT_PLUGINS_CONFIG, DEFAULT_RUNTIME_CONFIG, require.resolve('@babel/plugin-syntax-dynamic-import'), ] @@ -233,6 +300,7 @@ describe('createBabelConfig()', () => { DEFAULT_PROPOSALS_CONFIG, ], plugins: [ + ...DEFAULT_PLUGINS_CONFIG, require.resolve('@babel/plugin-syntax-dynamic-import'), ] }) diff --git a/tests/createWebpackConfig-test.js b/tests/createWebpackConfig-test.js index d95b86c1..576d3518 100644 --- a/tests/createWebpackConfig-test.js +++ b/tests/createWebpackConfig-test.js @@ -34,7 +34,7 @@ describe('createWebpackConfig()', () => { .toContain('url-loader') }) it('excludes node_modules from babel-loader', () => { - expect(config.module.rules[0].exclude.test('node_modules')).toBe(true) + expect(config.module.rules[0].exclude.test('node_modules/')).toBe(true) }) it('uses entry config', () => { expect(config.entry).toEqual(['index.js']) From 3a5fde72d8a8f731d5ca2e16af267ed75b65e1b7 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Wed, 20 May 2020 08:14:44 +1000 Subject: [PATCH 61/66] Move changes from 2+ majorish releses ago to an archive file --- CHANGES.md | 2091 +---------------------------------------------- CHANGES.old.md | 2095 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 2097 insertions(+), 2089 deletions(-) create mode 100644 CHANGES.old.md diff --git a/CHANGES.md b/CHANGES.md index 3f8fc8b2..9f649527 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -264,2096 +264,9 @@ - webpack-merge: v4.1.4 → [v4.2.2](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#422--2019-08-27) - whatwg-fetch: v2.0.4 → [v3.0.0](https://github.com/github/fetch/releases/tag/v3.0.0) -# 0.23.0 / 2018-08-03 +--- -## Breaking Changes - -- Updated Inferno config for Inferno 5 - `inferno-*` packages (such as `inferno-compat`) work again with Webpack 4 [[#440](https://github.com/insin/nwb/issues/440)] - -## Added - -- Added `prepublishOnly` to react-component and web-module project package.json scripts, which invokes `npm run build` prior to publishing [[#436](https://github.com/insin/nwb/issues/436)] [[hanford][hanford]] -- Added [`npm.umd.entry` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#entry-string) to specify a different entry point for the UMD build in npm module projects. Currently, the UMD build requires an entry point which *must* have a `default` export [[#411](https://github.com/insin/nwb/issues/411)] - -## Fixed - -- Always add `CopyPlugin` when [`webpack.copy` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#copy-array--object) is provided [[#431](https://github.com/insin/nwb/issues/431)] -- Remove use of object destructuring from render shims - fixes output of quick build commands in IE11 [[#453](https://github.com/insin/nwb/issues/453)] - -## Dependencies - -- autoprefixer: v8.1.0 → [v9.0.2](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#902) -- babel-core: v6.26.0 → [v6.26.3](https://github.com/babel/babel/releases/tag/v6.26.3) -- babel-loader: v7.1.4 → [v7.1.5](https://github.com/babel/babel-loader/releases/tag/v7.1.5) -- babel-plugin-inferno: v4.0.0 → [v5.0.1](https://github.com/infernojs/babel-plugin-inferno/releases) -- babel-plugin-istanbul: v4.1.5 → [v4.1.6](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v4.1.5...v4.1.6) -- babel-plugin-transform-decorators-legacy: v1.3.4 → [v1.3.5](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy/releases/tag/v1.3.5) -- chalk: v2.3.2 → [v2.4.1](https://github.com/chalk/chalk/compare/v2.3.0...v2.4.1) -- copy-template-dir: v1.3.0 → [v1.4.0](https://github.com/yoshuawuyts/copy-template-dir/releases/tag/v1.4.0) -- copy-webpack-plugin: v4.5.1 → [v4.5.2](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#452-2018-06-26) -- css-loader: v0.28.10 → [v1.0.0](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#100-2018-07-06) -- detect-port: v1.2.2 → [v1.2.3](https://github.com/node-modules/detect-port/releases) -- filesize: v3.6.0 → [v3.6.1](https://github.com/avoidwork/filesize.js/compare/3.6.0...3.6.1) -- fs-extra: v6.0.0 → [v7.0.0](https://github.com/jprichardson/node-fs-extra/blob/master/CHANGELOG.md#700--2018-07-16) -- gzip-size: v4.1.0 → [v5.0.0](https://github.com/sindresorhus/gzip-size/compare/v4.1.0...v5.0.0) - dropped Node.js 4 support -- html-webpack-plugin: v3.0.6 → [v3.2.0](https://github.com/jantimon/html-webpack-plugin/blob/master/CHANGELOG.md#320-2018-04-03) -- inquirer: v5.1.0 → [v6.0.0](https://github.com/SBoudrias/Inquirer.js/releases) -- karma: v2.0.0 → [v2.0.5](https://github.com/karma-runner/karma/releases) -- karma-coverage: v1.1.1 → [v1.1.2](https://github.com/karma-runner/karma-coverage/blob/master/CHANGELOG.md#112-2018-05-03) -- karma-webpack: v2.0.13 → [v3.0.0](https://github.com/webpack-contrib/karma-webpack/blob/master/CHANGELOG.md#300-2018-03-19) -- mini-css-extract-plugin v0.2.0 → [v0.4.1](https://github.com/webpack-contrib/mini-css-extract-plugin/releases) -- mocha: v5.0.4 → [v5.2.0](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#520--2018-05-18) -- opn: v5.2.0 → [v5.3.0](https://github.com/sindresorhus/opn/compare/v5.2.0...v5.3.0) -- ora: v2.0.0 → [v3.0.0](https://github.com/sindresorhus/ora/compare/v2.0.0...v3.0.0) -- postcss-loader: v2.1.1 → [v2.1.6](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#216-2018-07-10) -- resolve: v1.5.0 → [v1.8.1](https://github.com/browserify/resolve/compare/v1.5.0...v1.8.1) -- run-series: v1.1.6 → [v1.1.8](https://github.com/feross/run-series/compare/v1.1.6...v1.1.8) -- style-loader: v0.20.2 → [v0.21.0](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0210-2018-04-18) -- uglifyjs-webpack-plugin: v1.2.3 → [v1.2.7](https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/CHANGELOG.md#127-2018-06-25) -- webpack: v4.1.1 → [v4.16.4](https://github.com/webpack/webpack/releases) -- webpack-dev-middleware: v3.0.1 → [v3.1.3](https://github.com/webpack/webpack-dev-middleware/releases) -- webpack-dev-server: v3.1.1 → [v3.1.5](https://github.com/webpack/webpack-dev-server/releases) -- webpack-hot-middleware: v2.21.2 → [v2.22.3](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.21.2...v2.22.3) -- webpack-merge: v4.1.2 → [v4.1.4](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#414--2018-08-01) -- whatwg-fetch: v2.0.3 → [v2.0.4](https://github.com/github/fetch/releases/tag/v2.0.4) - -## Docs - -- Added [instructions for debugging in VS Code](https://github.com/insin/nwb/blob/master/docs/FAQ.md#how-can-i-debug-using-vs-code-when-running-an-app-with-nwb) to the FAQ [[#445](https://github.com/insin/nwb/issues/445)] -- Replaced references to "ES6" with plain old "ES" - -# 0.22.0 / 2018-03-13 - -## Breaking Changes - -- Node.js 4 is no longer supported; Node.js 6.11.5 is now the minimum required version, as per Webpack 4 [[#400](https://github.com/insin/nwb/issues/400)] -- Updated to Webpack 4 - if you were customising your build with `nwb.config.js`, some of the nwb config you depended on may have changed, and the options Webpack accepts may have changed [[#409](https://github.com/insin/nwb/issues/409)] - - Webpack's new `mode` option is now set to activate Webpack 4's new defaults, which removes the need for a bunch of manual configuration nwb was doing: - - `ModuleConcatenationPlugin` is now automatically enabled in `production` mode instead of being explicitly configured, so nwb's `webpack.hoisting` config has been removed. - - `NamedModulesPlugin` is now automatically used in `development` mode instead of being explicitly configured. - - Development UMD builds for modules now use `production` mode with minimization disabled, as the new `development` mode defaults are unsuitable for code which will be published to npm. - - Webpack's `optimization` options are now used for certain pieces of configuration: - - `optimization.noEmitOnErrors` is used instead of `NoEmitOnErrorsPlugin` to prevent emission of assets when using Hot Module Replacement. - - UglifyJS is now configured via `optimization.minimize`/`optimization.minimizer` instead of just adding `UglifyJsPlugin` directly to `plugins`. - - `CommonsChunkPlugin` has been removed in Webpack 4 - `optimization.runtimeChunk` is now configured to create a `runtime` chunk (which replaces the old `manifest` chunk) and `optimization.splitChunks` is configured to create a `vendor` bundle. - - Replaced used of `ExtractTextPlugin` with [`MiniCssExtractPlugin`](https://github.com/webpack-contrib/mini-css-extract-plugin): - - Separate CSS files are now created and loaded on-demand for code splits. - - Replaced `webpack.extractText` config with [`webpack.extractCSS` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#extractcss-object--boolean) - this is not backwards-compatible, as plugin options differ. - - Webpack's default `performance` option size warnings have been disabled (for now). -- Updated Inferno config for Inferno 4 - see the [Inferno v4 migration guide](https://github.com/infernojs/inferno/blob/master/docs/v4-migration.md) for breaking changes [[#429](https://github.com/insin/nwb/issues/429)] - - `nwb new inferno-app` now asks if you want to install `inferno-compat` as it's no longer a single dependency, defaulting to not installing it. -- `nwb new preact-app` now asks if you want to install `preact-compat`, defaulting to not installing it. -- Updated to Mocha 5, which dropped support for IE9 and IE10 and fixed some false positives. -- Removed support for deprecated `webpack.compat.enzyme`, `webpack.compat.sinon` and `webpack.style = 'old'` config. - -## Known Issues - -- Inferno is currently publishing `.mjs` files to npm, [which is breaking `inferno-*` packages with Webpack 4](https://github.com/infernojs/inferno/issues/1296), so e.g. `inferno-compat` won't work if you want to reuse React components. - -## Added - -- Added an `-f/--force` flag to `nwb new` to accept defaults and skip questions. - -## Changed - -- The dev server's fallback `index.html` serving can now be configured with dot arguments - e.g. pass `--fallback.disableDotRule` if you need to use dots in your path when using the HTML5 History API. -- `--no-polyfill` can now be used to disable default polyfills for app projects as well as quick commands. - -## Dependencies - -- autoprefixer: v7.2.5 → [v8.1.0](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#810) -- babel-loader: v7.1.2 → [v7.1.4](https://github.com/babel/babel-loader/releases) -- babel-plugin-inferno: v3.3.1 → [v4.0.0](https://github.com/infernojs/babel-plugin-inferno/releases) -- case-sensitive-paths-webpack-plugin: v2.1.1 → [v2.1.2](https://github.com/Urthen/case-sensitive-paths-webpack-plugin/blob/master/CHANGELOG.md#v212) -- chalk: v2.3.0 → [v2.3.2](https://github.com/chalk/chalk/compare/v2.3.0...v2.3.2) -- copy-webpack-plugin: v4.3.1 → [v4.5.1](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#451-2018-03-09) -- cross-spawn: v6.0.4 → [v6.0.5](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md#605-2018-03-02) -- css-loader: v0.28.9 → [v0.28.10](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#02810-2018-02-22) -- extract-text-webpack-plugin v3.0.0 → [mini-css-extract-plugin v0.2.0](https://github.com/webpack-contrib/mini-css-extract-plugin) -- file-loader: v1.1.6 → [v1.1.11](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#1111-2018-03-01) -- filesize: v3.5.11 → [v3.6.0](https://github.com/avoidwork/filesize.js/compare/3.5.11...3.6.0) -- html-webpack-plugin: v2.30.1 → [v3.0.6](https://github.com/jantimon/html-webpack-plugin/blob/master/CHANGELOG.md#306-2018-03-06) -- inquirer: v3.3.0 → [v5.1.0](https://github.com/SBoudrias/Inquirer.js/releases) - latest version requires Node.js 6 -- karma-webpack: v2.0.9 → [v2.0.13](https://github.com/webpack-contrib/karma-webpack/blob/master/CHANGELOG.md#2013-2018-02-27) -- mocha: v4.1.0 → [v5.0.4](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#504--2018-03-07) -- npm-install-webpack-plugin v4.0.5 → @insin/npm-install-webpack-plugin v5.0.0 - Webpack 4 compatibility -- ora: v1.3.0 → [v2.0.0](https://github.com/sindresorhus/ora/releases/tag/v2.0.0) -- postcss-loader: v2.0.10 → [v2.1.1](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#211-2018-02-26) -- style-loader: v0.20.1 → [v0.20.2](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0202-2018-02-15) - skip empty `url()`s -- uglifyjs-webpack-plugin: v1.1.8 → [v1.2.3](https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/CHANGELOG.md#123-2018-03-10) -- url-loader: v0.6.2 → [v1.0.1](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md#101-2018-03-03) -- webpack: v3.10.0 → [v4.1.1](https://github.com/webpack/webpack/releases) -- webpack-dev-middleware: v1.12.2 → [v3.0.1](https://github.com/webpack/webpack-dev-middleware/releases) -- webpack-dev-server: v2.9.7 → [v3.1.1](https://github.com/webpack/webpack-dev-server/releases) -- webpack-hot-middleware: v2.21.0 → [v2.21.2](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.21.0...v2.21.2) -- webpack-merge: v4.1.1 → [v4.1.2](https://github.com/survivejs/webpack-merge/compare/v4.1.1...v4.1.2) - -## Internal - -- Updated `StatusPlugin` and `InlineRuntimePlugin` to use the Use the new Webpack 4 `.hooks` plugin API. - -## Docs - -- Fixed [`publicPath` docs](https://github.com/insin/nwb/blob/master/docs/Configuration.md#publicpath-string), as Webpack's `output.publicPath` config can't be `null` [[#432](https://github.com/insin/nwb/issues/432)] [[stephenwf][stephenwf]] - -# 0.21.5 / 2018-02-02 - -## Dependencies - -- cross-spawn: v6.0.3 → [v6.0.4](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md#604-2018-01-31) - -# 0.21.4 / 2018-01-30 - -## Fixed - -- Fixed validation of `webpack.compat` locale properties [[#425](https://github.com/insin/nwb/issues/425)] -- Fixed false negative when checking if the port is available when `devServer.port` is specified as a `String` [[#423](https://github.com/insin/nwb/issues/423)] - -## Dependencies - -- uglifyjs-webpack-plugin: v1.1.6 → [v1.1.8](https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/CHANGELOG.md#118-2018-01-29) - reduce memory consumption - -# 0.21.3 / 2018-01-28 - -## Changed - -- `port` config in [`devServer` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#devserver-object) will now be used if configured [[#423](https://github.com/insin/nwb/issues/423)] - -## Dependencies - -- cross-spawn: v5.1.0 → [v6.0.3](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md#603-2018-01-23) -- css-loader: v0.28.7 → [v0.28.9](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#0289-2018-01-17) -- style-loader: v0.19.1 → [v0.20.1](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0201-2018-01-26) - -# 0.21.2 / 2018-01-17 - -## Fixed - -- Fixed validation of `babel.env` config [[#420](https://github.com/insin/nwb/issues/420)] [[ngyikp][ngyikp]] - -## Dependencies - -- autoprefixer: v7.2.4 → [v7.2.5](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#725) -- opn: v5.1.0 → [v5.2.0](https://github.com/sindresorhus/opn/compare/v5.1.0...v5.2.0) -- semver: v5.4.1 → [v5.5.0](https://github.com/npm/node-semver/compare/v5.4.1...v5.5.0) - -# 0.21.1 / 2018-01-12 - -## Fixed - -- Fixed validation of `webpack.extractText = false` config, which disables extraction of imported stylesheets into `.css` files [[#418](https://github.com/insin/nwb/issues/418)] - -## Dependencies - -- postcss-loader: v2.0.9 → [v2.0.10](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#2010-2018-01-03) -- uglifyjs-webpack-plugin: v1.1.5 → [v1.1.6](https://github.com/webpack-contrib/uglifyjs-webpack-plugin/releases/tag/v1.1.6) - -# 0.21.0 / 2018-01-03 - -## Breaking Changes - -- Validation of the configuration object provided by `nwb.config.js` files has been expanded, so previously valid config files may now be invalid [[#136](https://github.com/insin/nwb/issues/136)] - - Unexpected properties in top-level configuration or in `babel`, `karma`, `npm` and `webpack` configuration (i.e. anything that's not documented in the [Configuration docs](https://github.com/insin/nwb/blob/master/docs/Configuration.md)) are now treated as errors [[#193](https://github.com/insin/nwb/issues/193)] - - Basic type checking is now performed for all documented configuration properties. - - After upgrading, run `nwb check-config` to check your configuration file. -- Updated to [UglifyJSPlugin 1.x](https://github.com/webpack-contrib/uglifyjs-webpack-plugin#readme), which supports ES2015 syntax and adds options to enable filesystem caching and use multiple processes to improve build speed, which nwb enables by default [[#412](https://github.com/insin/nwb/issues/412)] - - Review any custom [`webpack.uglify` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#uglify-object--false) you have against the new version's [options documentation](https://github.com/webpack-contrib/uglifyjs-webpack-plugin#options) - options for UglifyJS itself must now be passed as an `uglifyOptions` object and some of UglifyJS' default options have changed. -- Node.js 4.8.0 is now the minimum required version, based on the `engines` config of nwb's dependencies. - -## `nwb.config.js` Config Changes - -- Deprecated the `webpack.compat.sinon` flag for Sinon 1.x compatibility settings, as subsequent major versions since July 2017 support Webpack out of the box. - -## Fixed - -- Fixed testing React component/library and web module projects when using [export extensions](http://babeljs.io/docs/plugins/transform-export-extensions/) - the Babel stage preset wasn't being defaulted to preset-stage-1, which includes the export extensions plugin [[#364](https://github.com/insin/nwb/issues/364)] - -## Added - -- Added an [`--open` flag](https://github.com/insin/nwb/blob/master/docs/Commands.md#options) to open the app in your default browser or in a named browser (e.g. `--open="Google Chrome"`) after starting a Webpack dev server [[#334](https://github.com/insin/nwb/issues/334)] -- You can now provide a [`babel.config()` function](https://github.com/insin/nwb/blob/master/docs/Configuration.md#config-function) which will be given the generated Babel config to do whatever it wants with. -- You can now provide a [`karma.config()` function](https://github.com/insin/nwb/blob/master/docs/Configuration.md#config-function-2) which will be given the generated Karma config to do whatever it wants with [[#408](https://github.com/insin/nwb/issues/408)] - -## Changed - -- Simplified configuration of locales in [`webpack.compat` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#compat-object) - -## Dependencies - -- autoprefixer: v7.1.6 → [v7.2.4](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#724) -- babel-plugin-inferno: v3.3.0 → [v3.3.1](https://github.com/infernojs/babel-plugin-inferno/releases) -- copy-webpack-plugin: v4.2.1 → [v4.3.1](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#431-2017-12-22) -- file-loader: v1.1.5 → [v1.1.6](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#116-2017-12-16) -- gzip-size: v4.0.0 → [v4.1.0](https://github.com/sindresorhus/gzip-size/compare/v4.0.0...v4.1.0) -- karma: v1.7.1 → [v2.0.0](https://github.com/karma-runner/karma/releases/tag/v2.0.0) -- karma-webpack: v2.0.6 → [v2.0.9](https://github.com/webpack-contrib/karma-webpack/blob/master/CHANGELOG.md#209-2017-12-14) -- mocha: v4.0.1 → [v4.1.0](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#410--2017-12-28) -- postcss-loader: v2.0.8 → [v2.0.9](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#209-2017-11-24) -- style-loader: v0.19.0 → [v0.19.1](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0191-2017-12-14) -- webpack: v3.8.1 → [v3.10.0](https://github.com/webpack/webpack/releases) -- webpack-dev-middleware: v1.12.0 → [v1.12.2](https://github.com/webpack/webpack-dev-middleware/releases) -- webpack-dev-server: v2.9.4 → [v2.9.7](https://github.com/webpack/webpack-dev-server/releases) -- webpack-hot-middleware: v2.20.0 → [v2.21.0](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.20.0...v2.21.0) - -## Docs - -- Added missing docs for [`webpack.copy` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#copy-array--object) -- Added more headings to the [Commands docs](https://github.com/insin/nwb/blob/master/docs/Commands.md#commands) to make them easier to browse, and to make feature flags such as `--copy-files` for component builds more visible [[#407](https://github.com/insin/nwb/issues/407)] - -# 0.20.0 / 2017-11-18 - -## Breaking Changes - -- Updated UMD build config to [export the `default` export of the entry point](https://webpack.js.org/configuration/output/#output-libraryexport), rather than an ES modules interop object which looks something like `{__esModule: true, default: Getter}`, which was unintended behaviour. This will break any existing usage of UMD builds which depended on manually accessing the unintended `default` property [[#402](https://github.com/insin/nwb/issues/402)] -- Updated to Mocha 4, which comes with [a number of breaking changes](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#boom-breaking-changes). These are mostly related to dropping support for older versions of Node.js and non-ES5-compliant browsers. - -## Fixed - -- Bump the default React peerDependency version for react-component projects to `16.x` - fixes creating components with npm 2. - -## Dependencies - -- copy-webpack-plugin: v4.2.0 → [v4.2.1](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#421-2017-11-17) -- detect-port: v1.2.1 → [v1.2.2](https://github.com/node-modules/detect-port/releases) -- karma-webpack: v2.0.5 → [v2.0.6](https://github.com/webpack-contrib/karma-webpack/blob/master/CHANGELOG.md#206-2017-11-10) -- mocha: v3.4.2 → [v4.0.1](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#401--2017-10-05) - dropped support for old versions of Node.js and non-ES5-compliant browsers - -## Documentation - -- Documented `--unsafe-perm` workaround for PhantomJS' postinstall step failing on some OSes when installing globally with npm 5 [[#383](https://github.com/insin/nwb/issues/383)] - -# 0.19.2 / 2017-11-09 - -## Fixed - -- Backed out use of `preact/debug` in favour of `preact/devtools`, as the debug module tries to override the preact module's render export, which fails due to Webpack enforcing the read-only nature of ES module exports. - -# 0.19.1 / 2017-11-04 - -## `nwb.config.js` Config Changes - -- Deprecated the `webpack.compat.enzyme` flag for Enzyme v2 compatibility settings. Upgrade to Enzyme v3 when you can, which supports React all the way back to v0.13. - - [An example of configuring Enzyme v3](https://github.com/insin/nwb/blob/master/docs/Testing.md#configuring-testing-libraries) has been added to the [testing docs](https://github.com/insin/nwb/blob/master/docs/Testing.md#testing). - -## Fixed - -- Added `'createClass'` and `'createReactClass'` to the factory function names [React Transform](https://github.com/gaearon/babel-plugin-react-transform) looks for, so React component hot reloading will work for apps using [`create-react-class`](https://www.npmjs.com/package/create-react-class) imported as one of those names. - -## Changed - -- nwb is now also tested against Node 8 now that it's the Long Term Support version. -- Reverted the Webpack settings change for `webpack.compat.enzyme` config in v0.19.0, as it only applied while the version numbers of published React packages were out of sync. The compatibility settings assume Enzyme v2 and React >= v15.5. -- `style-loader`'s new `hmr` option is set to `false` when creating builds to prevent inclusion of its HMR code. - -## Dependencies - -- autoprefixer: v7.1.4 → [v7.1.6](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#716) -- babel-plugin-inferno: v3.2.0 → [v3.3.0](https://github.com/infernojs/babel-plugin-inferno/releases) -- babel-plugin-transform-react-remove-prop-types: v0.4.8 → [v0.4.10](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/releases) -- babel-preset-env: v1.6.0 → v1.7.0 -- chalk: v2.1.0 → [v2.3.0](https://github.com/chalk/chalk/compare/v2.1.0...v2.3.0) -- copy-webpack-plugin: v4.1.0 → [v4.2.0](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#420-2017-10-19) -- extract-text-webpack-plugin: v3.0.0 → [v3.0.2](https://github.com/webpack-contrib/extract-text-webpack-plugin/blob/master/CHANGELOG.md#302-2017-10-25) -- file-loader: v1.1.4 → [v1.1.5](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#115-2017-10-05) -- filesize: v3.5.10 → [v3.5.11](https://github.com/avoidwork/filesize.js/compare/3.5.10...3.5.11) -- karma-mocha-reporter: v2.2.4 → [v2.2.5](https://github.com/litixsoft/karma-mocha-reporter/blob/master/CHANGELOG.md#225-2017-10-17) -- karma-webpack: v2.0.4 → [v2.0.5](https://github.com/webpack-contrib/karma-webpack/blob/master/CHANGELOG.md#205-2017-10-08) -- phantomjs-prebuilt: v2.1.15 → v2.1.16 -- postcss-loader: v2.0.6 → [v2.0.8](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#208-2017-10-14) -- resolve: v1.4.0 → [v1.5.0](https://github.com/browserify/resolve/compare/v1.4.0...v1.5.0) -- style-loader: v0.18.2 → [v0.19.0](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0190-2017-10-03) -- url-loader: v0.5.9 → [v0.6.2](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md#062-2017-10-04) -- webpack: v3.6.0 → [v3.8.1](https://github.com/webpack/webpack/releases) -- webpack-dev-server: v2.9.1 → [v2.9.4](https://github.com/webpack/webpack-dev-server/releases) -- webpack-hot-middleware: v2.19.1 → [v2.20.0](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.19.1...v2.20.0) -- webpack-merge: v4.1.0 → [v4.1.1](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#411--2017-11-01) - -# 0.19.0 / 2017-10-02 - -## Breaking Changes - -- Removed hooking of React, Preact and Inferno `render()` functions in quick commands, as this won't work with ES modules builds (which are used by default in Webpack v3). This affected the current version of Preact at the time of writing. - - If you're manually using `render()` with quick commands, you must now handle providing the target DOM node too - `document.getElementById('app')` is available in the default HTML template. - -## Added - -- Added [`babel.env` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#env-object) to pass additional [options for `babel-preset-env`](https://github.com/babel/babel-preset-env#options). -- Added additional Enzyme [`webpack.compat`](https://github.com/insin/nwb/blob/master/docs/Configuration.md#compat-object) for recent versions of React 15. - -## Changed - -- Now using `babel-preset-env` instead of deprecated `babel-preset-es201X` presets [[#375](https://github.com/insin/nwb/issues/375)] -- Use `beautify: true` for `webpack.debug` output so code split bundles are readable. - -## Dependencies - -- autoprefixer: v7.1.2 → [v7.1.4](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#714) -- babel-cli: v6.24.1 → [v6.26.0][babel6260] -- babel-core: v6.24.1 → [v6.26.0][babel6260] -- babel-loader: v7.1.1 → [v7.1.2](https://github.com/babel/babel-loader/releases/tag/v7.1.2) -- babel-plugin-istanbul: v4.1.4 → v4.1.5 -- babel-plugin-react-transform: v2.0.2 → [v3.0.0](https://github.com/gaearon/babel-plugin-react-transform/releases) - add `React.PureComponent` to the list of default super classes -- babel-plugin-transform-react-remove-prop-types: v0.4.6 → [v0.4.8](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/releases) -- babel-polyfill: v6.23.0 → [v6.26.0][babel6260] -- babel-runtime: v6.25.0 → [v6.26.0][babel6260] -- chalk: v2.0.1 → [v2.1.0](https://github.com/chalk/chalk/compare/v2.0.1...v2.1.0) -- copy-webpack-plugin: v4.0.1 → [v4.1.0](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#410-2017-09-29) -- css-loader: v0.28.4 → [v0.28.7](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#0287-2017-08-30) -- file-loader: v0.11.2 → [v1.1.4](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#114-2017-09-30) -- gzip-size: v3.0.0 → v4.0.0 - async interface now uses Promises -- html-webpack-plugin: v2.29.0 → [v2.30.1](https://github.com/jantimon/html-webpack-plugin/blob/master/CHANGELOG.md#v2301) -- inquirer: v3.2.1 → [v3.3.0](https://github.com/SBoudrias/Inquirer.js/releases) -- karma-mocha-reporter: v2.2.3 → [v2.2.4](https://github.com/litixsoft/karma-mocha-reporter/blob/master/CHANGELOG.md#224-2017-08-24) -- karma: v1.7.0 → [v1.7.1](https://github.com/karma-runner/karma/releases/tag/1.7.1) -- mocha: v3.4.2 → [v3.5.3](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#353--2017-09-11) -- phantomjs-prebuilt: v2.1.14 → v2.1.15 - fix security issues with dependencies -- webpack-dev-middleware: v1.11.0 → [v1.12.0](https://github.com/webpack/webpack-dev-middleware/releases/tag/v1.12.0) -- webpack-dev-server: v2.6.1 → [v2.9.1](https://github.com/webpack/webpack-dev-server/releases) -- webpack-hot-middleware: v2.18.2 → [v2.19.0](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.18.2...v2.19.0) -- webpack: v3.4.1 → [v3.6.0](https://github.com/webpack/webpack/releases) - -[babel6260]: https://github.com/babel/babel/blob/master/CHANGELOG.md#6260-2017-08-16 - -# 0.18.10 / 2017-07-27 - -## Fixed - -- Fix dev server HMR for people running on different hosts or a different localhost port [[#356](https://github.com/insin/nwb/issues/356)] [[DethAriel][DethAriel]] - -## Dependencies - -- babel-runtime: v6.23.0 → v6.25.0 -- resolve: v1.3.3 → [v1.4.0](https://github.com/browserify/resolve/compare/v1.3.3...v1.4.0) -- webpack: v3.4.0 → [v3.4.1](https://github.com/webpack/webpack/releases/tag/v3.4.1) - -# 0.18.9 / 2017-07-26 - -## Changed - -- Now using preact/debug instead of preact/devtools in quick Preact commands and the Preact project skeleton - requires Preact >= 8.2.0 - -## Dependencies - -- inquirer: v3.2.0 → [v3.2.1](https://github.com/SBoudrias/Inquirer.js/releases/tag/v3.2.1) -- promise: v8.0.0 → v8.0.1 -- webpack: v3.2.0 → [v3.4.0](https://github.com/webpack/webpack/releases) - bug fixes; now watches for missing directories being added; perf improvements -- webpack-dev-server: v2.5.1 → [v2.6.1](https://github.com/webpack/webpack-dev-server/releases) - -# 0.18.8 / 2017-07-16 - -## Dependencies - -- promise: v8.0.0 → v8.0.1 -- webpack: v3.2.0 → [v3.3.0](https://github.com/webpack/webpack/releases/tag/v3.3.0) - bug fixes; now watches for missing directories being added - -# 0.18.7 / 2017-07-12 - -## Changed - -- You can now set [`webpack.extractText` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#extracttext-object--boolean) to `false` to disable extraction of stylesheets in builds [[#343](https://github.com/insin/nwb/issues/343)] - -## Dependencies - -- extract-text-webpack-plugin: v3.0.0-rc.2 → v3.0.0 -- webpack: v3.1.0 → [v3.2.0](https://github.com/webpack/webpack/releases/tag/v3.2.0) - bug fixes - -## Documentation - -- Documented default [`webpack.extractText` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#extracttext-object--boolean). - -# 0.18.6 / 2017-07-10 - -## Dependencies - -- extract-text-webpack-plugin: v3.0.0-rc.1 → v3.0.0-rc.2 - fix module sorting type error -- inquirer: v3.1.1 → [v3.2.0](https://github.com/SBoudrias/Inquirer.js/releases/tag/v3.2.0) - -# 0.18.5 / 2017-07-09 - -## Dependencies - -- extract-text-webpack-plugin: v3.0.0-beta.3 → v3.0.0-rc.1 -- karma-webpack: v2.0.3 → [v2.0.4](https://github.com/webpack-contrib/karma-webpack/blob/master/CHANGELOG.md#204-2017-07-07) - Webpack 3 support -- webpack-dev-server: v2.5.0 → [v2.5.1](https://github.com/webpack/webpack-dev-server/releases/tag/v2.5.1) - Webpack 3 support - -# 0.18.4 / 2017-07-07 - -## Fixed - -- Fixed use of `@import` in CSS by adding `ident` back to `postcss-loader` config [[#311](https://github.com/insin/nwb/issues/311)] -- Fixed config validation error being thrown when using `webpack.styles` config for custom preprocessor plugin rules [[#342](https://github.com/insin/nwb/issues/342)] -- Fixed display of valid properties when an invalid property is used when configuring a custom `webpack.styles` rule. - -## Added - -- Added [`webpack.debug` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#debug-boolean) to trigger creation of a more debuggable production build [[#336](https://github.com/insin/nwb/issues/336)] - - The recommended way to use this is via a [config argument](https://github.com/insin/nwb/blob/master/docs/Configuration.md#configuration-via-arguments): - - ```sh - npm run build -- --webpack.debug - ``` - -- Added support for the following arguments when building a React component's demo: - - `--title` - set the generated demo `index.html`'s `<title>` - - `--vendor` - enable creation of a vendor bundle for modules imported from `node_modules/` [[#335](https://github.com/insin/nwb/issues/335)] - -## Dependencies - -- autoprefixer: v7.1.1 → [v7.1.2](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#711) -- babel-loader: v7.1.0 → [v7.1.1](https://github.com/babel/babel-loader/releases/tag/v7.1.1) - don't read `.babelrc` for cache identifier when `babelrc=false` (nwb uses this option) -- chalk: v1.1.3 → [v2.0.1](https://github.com/chalk/chalk/compare/v1.1.3...v2.0.1) -- extract-text-webpack-plugin: v2.1.2 → [v3.0.0-beta.3](https://github.com/webpack-contrib/extract-text-webpack-plugin/releases) - Webpack 3 support -- html-webpack-plugin: v2.28.0 → [v2.29.0](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2290) - Webpack 3 support -- karma-chrome-launcher: v2.1.1 → [v2.2.0](https://github.com/karma-runner/karma-chrome-launcher/blob/master/CHANGELOG.md#220-2017-06-23) -- webpack: v3.0.0 → [v3.1.0](https://github.com/webpack/webpack/releases/tag/v3.1.0) - perf boost; fix ordering in `ExtractTextPlugin` -- webpack-hot-middleware: v2.18.0 → [v2.18.2](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.18.0...v2.18.2) - -# 0.18.3 / 2017-06-22 - -## Fixed - -- Quick `build` command config was being created before the default `NODE_ENV = production` was applied, so output filenames didn't include a chunkhash by default. - -## Dependencies - -- webpack-dev-middleware: v1.10.2 → [v1.11.0](https://github.com/webpack/webpack-dev-middleware/releases/tag/v1.11.0) - Webpack 3 support - -# 0.18.2 / 2017-06-22 - -## Fixed - -- Fixed clearing the console by default when running the development server. - -## Dependencies - -- babel-loader: v7.0.0 → [v7.1.0](https://github.com/babel/babel-loader/releases/tag/v7.1.0) - Webpack 3 support - -## Documentation - -- Updated [Quick Development with nwb](https://github.com/insin/nwb/blob/master/docs/guides/QuickDevelopment.md#quick-development-with-nwb) for v0.18. - -# 0.18.1 / 2017-06-20 - -## Dependencies - -- npm-install-webpack2-plugin: v5.0.0 → v5.0.1 - fix Webpack 3 support - -# 0.18.0 / 2017-06-20 - -## Breaking Changes - -- Updated to Webpack 3 - potentially breaking for some plugins [[#326](https://github.com/insin/nwb/issues/326)] - - See the [official release post](https://medium.com/webpack/webpack-3-official-release-15fd2dd8f07b) for changes. - -- Removed support for configuration which was [deprecated in nwb v0.15.0](#0150--2017-01-25). - -## Fixed - -- Fixed display of user config errors when running the dev server. - -## Added - -- Added [`webpack.hoisting` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#hoisting-boolean) to enable use of Webpack 3's new `ModuleConcatenationPlugin` for scope hoisting in production builds [[#326](https://github.com/insin/nwb/issues/326)] -- [`babel`, `webpack`, `devServer`, `karma` and `npm` configuration](https://github.com/insin/nwb/blob/master/docs/Configuration.md#configuration-object) can now be provided via [arguments using dotted paths](https://github.com/insin/nwb/blob/master/docs/Configuration.md#configuration-via-arguments) [[#327](https://github.com/insin/nwb/issues/327)] - - ```sh - nwb react build app.js \ - --babel.plugins=react-html-attrs \ - --babel.stage=2 \ - --webpack.hoisting - ``` - - If you have a config file, arguments will override properties in it. This is primarily intended for one-off feature toggles without having to edit your config file, and to provide some level of configuration for [quick development commands](https://github.com/insin/nwb/blob/master/docs/guides/QuickDevelopment.md#quick-development-with-nwb) without needing a config file. - -## Changed - -- [`babel.plugins`](https://github.com/insin/nwb/blob/master/docs/Configuration.md#plugins-string--array), [`babel.presets`](https://github.com/insin/nwb/blob/master/docs/Configuration.md#presets-string--array) and locales in [`webpack.compat`](https://github.com/insin/nwb/blob/master/docs/Configuration.md#compat-object) config now also accept single configuration as a String to make them usable via arguments [[#327](https://github.com/insin/nwb/issues/327)] - -## Dependencies - -- inquirer: v3.1.0 → [v3.1.1](https://github.com/SBoudrias/Inquirer.js/releases/tag/v3.1.1) -- npm-install-webpack2-plugin: v4.1.1 → v5.0.0 - drop Webpack 1 and add Webpack 3 to peerDeps -- promise: v7.3.0 → v8.0.0 -- webpack: v2.6.1 → [v3.0.0](https://github.com/webpack/webpack/releases/tag/v3.0.0) -- webpack-dev-server: v2.4.5 → [v2.5.0](https://github.com/webpack/webpack-dev-server/releases/tag/v2.5.0) - -# 0.17.3 / 2017-07-07 - -## Fixed - -Backported fixes from 0.18: - -- Fixed use of `@import` in CSS by adding `ident` back to `postcss-loader` config [[#311](https://github.com/insin/nwb/issues/311)] -- Fixed display of valid properties when an invalid property is used when configuring a custom `webpack.styles` rule. - -# 0.17.2 / 2017-07-04 - -## Fixed - -Backported fixes from 0.18: - -- Fixed display of user config errors when running the development server. -- Fixed clearing the console by default when running the development server. -- Quick build command config was being created before the default `NODE_ENV = production` was applied, so output filenames didn't include a chunkhash by default. -- Fixed config validation error when running the development server and using `webpack.styles` config for custom preprocessor plugin rules. - -# 0.17.1 / 2017-06-19 - -## Fixed - -- Fixed using a custom port for the dev server - Webpack Dev Server's client didn't like the format we were specifying the URL for the Hot Module Reloading connection in [[#328](https://github.com/insin/nwb/issues/328)] -- Use the correct protocol in the `'The app is running at...'` successful compilation message when using HTTPS. - -# 0.17.0 / 2017-06-17 - -## Breaking Changes - -- Now using [Webpack Dev Server](https://github.com/webpack/webpack-dev-server) (instead of running a basic Express development server). - - Webpack Dev Server has [security features](https://github.com/insin/inputmask-core) which you may need to configure your way around if you're using `--host` or if your development setup involves hitting the dev server from a different host. - - Please [create an issue](https://github.com/insin/nwb/issues/new) if you're affected by this change and there's something nwb can do to mitigate dev server problems without compromising security. - -**React components/libraries** - -- A [`--[keep-]proptypes` flag](https://github.com/insin/nwb/blob/master/docs/guides/ReactComponents.md#--keep-proptypes) replaces `--no[-wrap]-proptypes` to disable wrapping of `propTypes` in React component project builds so they'll be stripped from a production build. - -## Fixed - -- The process will now exit with a non-zero code when a Webpack build completes with errors [[#290](https://github.com/insin/nwb/issues/290)] -- Fixed transpiling of ES2017 features when use of a stage-X preset is disabled with [`babel.stage = false` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#stage-number--false). -- Fixed `hmre = false` [Express middleware option](https://github.com/insin/nwb/blob/master/docs/Middleware.md#options) for disabling use of [React Transform](https://github.com/gaearon/babel-plugin-react-transform#readme) to attempt to handle Hot Module Reloading for React components and `render()` error display [[#263](https://github.com/insin/nwb/issues/263)] - -**Preact** - -- Fixed importing React components when serving a Preact app - this was missed when fixing `preact-compat` configuration issues from v0.16.0. - -## Added - -**Arguments** - -- Added a [`--no-clear[-console]` flag](https://github.com/insin/nwb/blob/master/docs/Commands.md#nwb-serve) to disable clearing of the console when running the dev server. -- Added a [`--no-html` flag](https://github.com/insin/nwb/blob/master/docs/Commands.md#nwb-build) to disable creation of an `index.html` file if you don't need one (e.g. you're serving your built apps via another means) [[#278](https://github.com/insin/nwb/issues/278)] [[bwendt-mylo][bwendt-mylo]] - -**Commands** - -- Added an `nwb web (run|build)` command for [quick development](https://github.com/insin/nwb/blob/master/docs/guides/QuickDevelopment.md#quick-development-with-nwb) with vanilla JavaScript (i.e. you're in charge of rendering). - -**Configuration** - -- Added [`devServer` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#devserver-object) to configure [Webpack Dev Server options](https://webpack.js.org/configuration/dev-server/#devserver), which include: - - `devServer.historyApiFallback.disableDotRule` can be enabled if you need to use dots in your path when using the HTML5 History API - - `devServer.https` can be used to enable HTTPS - - `devServer.proxy` can be used to proxy certain URLs to a separate API backend development server -- Added a [`type` option](https://github.com/insin/nwb/blob/master/docs/Middleware.md#options) to nwb's Express middleware to set the project type (one of `react`, `preact`, `inferno` or `web`) manually, enabling use of the middleware without a config file. - -**React** - -- Added [`babel.removePropTypes` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#removeproptypes-object--false) to disable or configure [removal of `propTypes`](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types) in React app production builds. -- Added [`babel.reactConstantElements` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#reactconstantelements-false) to disable the use of the [React constant element hoisting transform](https://babeljs.io/docs/plugins/transform-react-constant-elements/) in React app production builds. - -## Changed - -**npm modules** - -- Default Babel config for `react-component` and `web-module` projects now uses [`babel-preset-stage-1`](http://babeljs.io/docs/plugins/preset-stage-1/), so you can use [export extensions](http://babeljs.io/docs/plugins/transform-export-extensions/) by default if you need to re-export a library's modules in `src/index.js` [[#284](https://github.com/insin/nwb/issues/284)] -- Default Travis CI config for `react-component` and `web-module` projects now only uses Node 6 by default for quicker builds. - -**Preact** - -- [`preact/devtools`](https://github.com/developit/preact#developer-tools) is now imported in development mode to enable use of React Developer Tools when using `nwb preact run`. This has also been added to the `preact-app` template. - - For existing Preact apps, add the following to its entry point to enable this: - - ``` - if (process.env.NODE_ENV === 'development') { - require('preact/devtools') - } - ``` - -**React components/libraries** - -- [`prop-types`](https://github.com/facebook/prop-types#prop-types) imports are now also removed from React component UMD production builds. - -## Documentation - -- Document the [`--copy-files` flag](https://github.com/insin/nwb/blob/master/docs/guides/ReactComponents.md#--copy-files) properly [[#317](https://github.com/insin/nwb/issues/317)] - -## Dependencies - -- babel-core: v6.24.1 → [v6.25.0](https://github.com/babel/babel/releases/tag/v6.25.0) -- babel-plugin-transform-react-remove-prop-types: v0.4.5 → [v0.4.6](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/releases/tag/v0.4.6) - fix use in Node 4 -- babel-preset-es2017: v6.24.1 -- detect-port: v1.1.3 → [v1.2.1](https://github.com/node-modules/detect-port/releases) -- extract-text-webpack-plugin: v2.1.0 → [v2.1.2](https://github.com/webpack-contrib/extract-text-webpack-plugin/blob/master/CHANGELOG.md#212-2017-06-08) -- file-loader: v0.11.1 → [v0.11.2](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#0112-2017-06-05) - `publicPath` option changes -- inquirer: v3.0.6 → [v3.1.0](https://github.com/SBoudrias/Inquirer.js/releases/tag/v3.1.0) -- ora: v1.2.0 → v1.3.0 -- postcss-loader: v2.0.5 → [v2.0.6](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#206-2017-06-14) -- promise: v7.1.1 → v7.3.0 -- style-loader: v0.18.1 → [v0.18.2](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0182-2017-06-05) -- url-loader: v0.5.8 → [v0.5.9](https://github.com/webpack-contrib/url-loader/releases/tag/v0.5.9) -- [webpack-dev-server](https://github.com/webpack/webpack-dev-server/): v2.4.5 - -# 0.16.3 / 2017-05-31 - -**Dependencies:** - -- case-sensitive-paths-webpack-plugin: v2.0.0 → [v2.1.1](https://github.com/Urthen/case-sensitive-paths-webpack-plugin/blob/master/CHANGELOG.md#211) - don't intercept Webpack "File not found" error, resolve issue with not recognising when a new file is added - -# 0.16.2 / 2017-05-31 - -**Fixed:** - -- Fixed validation of `webpack.styles` config to allow it to be set to `false` [[#312](https://github.com/insin/nwb/pull/312)] [[seanofw][seanofw]] - -**Dependencies:** - -- css-loader: v0.28.3 → [v0.28.4](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#0284-2017-05-30) - preserve leading underscore in class names - -# 0.16.1 / 2017-05-31 - -**Fixed:** - -- Fixed bad render shim paths which were breaking the `nwb react`, `nwb preact` and `nwb inferno` quick development commands. -- Fixed `nwb preact` commands and `nwb react`'s `--preact[-compat]` when used with Preact 8 by removing a workaround for an old preact-compat distribution issue. - -**Added:** - -- Added support for [create-react-class](https://facebook.github.io/react/docs/react-without-es6.html) when using `preact-compat`. - -**Dependencies:** - -- css-loader: v0.28.3 → [v0.28.4](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#0284-2017-05-30) - preserve leading underscore in class names - -# 0.16.0 / 2017-05-29 - -**Breaking Changes:** - -- Global `react`, `preact`, and `inferno` commands are no longer installed when nwb is installed globally [[#308](https://github.com/insin/nwb/issues/308)] - - These are now subcommands of the global `nwb` command, to avoid conflicting with global commands installed by official tools for these libraries, e.g. [`preact-cli`](https://github.com/developit/preact-cli) is now available, which provides a global `preact` command. -- Node.js 4.6.0 is now the minimum required version, based on the `engines` config of nwb's dependencies, -- A separate Webpack rule for stylesheets imported from `node_modules/` is no longer created by default. - - > For backwards compatibility you can set [`webpack.style` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#styles-object--false--old) to `'old'` to use the old default behaviour - this capability will be removed in a future release. -- The Babel plugin for Inferno now requires Inferno >= 1.5 and is not backwards-compatible with 1.4. -- Default Webpack config now sets `module.strictExportPresence = true` so a missing export is now a compile error. -- Default `ExtractTextPlugin` now sets `allChunks = true` to extract stylesheets from all chunks and avoid including the `style-loader` runtime in builds by default. - -**Added:** - -- You can now control [how Webpack rules are created for stylesheets](https://github.com/insin/nwb/blob/master/docs/Stylesheets.md#stylesheets) via [`webpack.styles` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#styles-object--false--old). - - This allows you to set up multiple rules for your own stylesheets (e.g. using CSS Modules only for stylesheets in a particular directory) and to provide rules for dependencies which need a specific Webpack rule for their stylesheets. - - You can also disable creation of stylesheet rules by setting `webpack.styles` to `false`. -- Re-enabled the `react-constant-elements` transform for React production builds, due to significant bug fixes. -- Added a `--no-hmre` flag for use when serving a React app, to disable use of [React Transform](https://github.com/gaearon/babel-plugin-react-transform#readme) to attempt to automatically handle Hot Module Replacement for React components and display an overlay with `render()` errors [[#263](https://github.com/insin/nwb/issues/263)] -- Added support for [intl](https://github.com/andyearnshaw/Intl.js/) and [react-intl](https://github.com/yahoo/react-intl) in [`webpack.compat` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#compat-object) [[#260](https://github.com/insin/nwb/pull/260)] [[grahamlyus][grahamlyus]] -- You can now provide a [`webpack.config()` function](https://github.com/insin/nwb/blob/master/docs/Configuration.md#config-function) which will be given the generated Webpack config to do whatever it wants with [[#256](https://github.com/insin/nwb/issues/256)] -- You can now provide [`use` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#customising-loaders) with a list of loaders in `webpack.rules` to replace a rule's default loader with chained loaders [[#256](https://github.com/insin/nwb/issues/256)] -- You can now [disable a default Webpack config rule](https://github.com/insin/nwb/blob/master/docs/Configuration.md#disabling-default-rules) by setting it to `false` [[#256](https://github.com/insin/nwb/issues/256)] - -**Changed:** - -- Default options are no longer used if you provide a custom `loader` for a rule in `webpack.rules` [[#256](https://github.com/insin/nwb/issues/256)] -- React project templates now use classes and `React.Component` instead of `React.createClass()`, which is deprecated as of React v15.5 [[#216](https://github.com/insin/nwb/issues/216)] - -**Fixed:** - -- Fixed chunk hash not changing when imports in a split chunk are changed, by dropping use of the `webpack-md5-hash` plugin [[#301](https://github.com/insin/nwb/issues/301)] [[grahamlyus][grahamlyus]] -- Added missing config for `CopyWebpackPlugin` when serving a `react-component` project's demo app, so any static content in `demo/public/` will be also served by the dev server [[#307](https://github.com/insin/nwb/issues/307)] -- Removed `node_modules/` caching from default Travis CI config in project skeletons, as it's been reported to cause build failures [[#271](https://github.com/insin/nwb/issues/271)] -- An output directory specified with a trailing slash is now cleaned properly when creating a build. -- A `loader` configured for a Webpack rule is no longer moved into the `options` object when an options object hasn't been explicitly configured [[#256](https://github.com/insin/nwb/issues/256)] -- Fixed cleaning nested dirs, including a demo app's `demo/dist/` dir. -- Fixed cleaning output directories specified with a trailing slash. - -**Dependencies:** - -- autoprefixer: v6.7.0 → [v7.1.1](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#711) -- babel-cli: v6.22.2 → [v6.24.1][babel6241] -- babel-core: v6.22.1 → [v6.24.1][babel6241] -- babel-loader: v6.2.10 → [v7.0.0](https://github.com/babel/babel-loader/releases/tag/v7.0.0) -- babel-plugin-inferno: v1.7.0 → [v3.2.0](https://github.com/infernojs/babel-plugin-inferno/releases) - adds support for Inferno 1.5, not backwards-compatible with 1.4 -- babel-plugin-istanbul: v3.1.2 → [v4.1.4](https://github.com/istanbuljs/babel-plugin-istanbul/blob/master/CHANGELOG.md#414-2017-05-27) - drop support for Node.js 0.10 and v0.12 -- babel-plugin-transform-react-jsx: v6.22.0 → [v6.24.1][babel6241] -- babel-plugin-transform-react-remove-prop-types: v0.2.11 → [v0.4.5](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/releases) - dropped support for `React.createClass()` in favour of the new `create-react-class` package -- babel-plugin-transform-runtime: v6.22.0 → [v6.23.0][babel6230] -- babel-polyfill: v6.22.0 → [v6.23.0][babel6230] -- babel-preset-es2015: v6.22.0 → [v6.24.1][babel6241] -- babel-preset-es2016: v6.22.0 → [v6.24.1][babel6241] -- babel-preset-react: v6.22.0 → [v6.24.1][babel6241] -- babel-preset-stage-0: v6.22.0 → [v6.24.1][babel6241] -- babel-preset-stage-1: v6.22.0 → [v6.24.1][babel6241] -- babel-preset-stage-2: v6.22.0 → [v6.24.1][babel6241] -- babel-preset-stage-3: v6.22.0 → [v6.24.1][babel6241] -- babel-runtime: v6.22.0 → [v6.23.0][babel6230] -- case-sensitive-paths-webpack-plugin: v1.1.4 → [v2.0.0](https://github.com/Urthen/case-sensitive-paths-webpack-plugin/blob/master/CHANGELOG.md#2017-3-31) - use the file system exposed by the compiler -- css-loader: v0.26.1 → [v0.28.3](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#0283-2017-05-25) - added an [`alias` option](https://github.com/webpack-contrib/css-loader#alias) -- detect-port: v1.1.0 → [v1.1.3](https://github.com/node-modules/detect-port/blob/master/HISTORY.md#113--2017-05-24) -- express: v4.14.0 → [v4.15.3](https://github.com/expressjs/express/blob/master/History.md#4153--2017-05-16) -- file-loader: v0.9.0 → [v0.11.1](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#0111-2017-04-01) - added `useRelativePath` option -- filesize: v3.4.3 → [v3.5.10](https://github.com/avoidwork/filesize.js/compare/3.4.3...3.5.10) -- inquirer: v3.0.1 → [v3.0.6](https://github.com/SBoudrias/Inquirer.js/releases/) -- karma: v1.4.0 → [v1.7.0](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md#170-2017-05-06) -- karma-chrome-launcher: v2.0.0 → [v2.1.1](https://github.com/karma-runner/karma-chrome-launcher/blob/master/CHANGELOG.md#211-2017-05-05) - add support for headless Chrome/ChromeCanary -- karma-mocha-reporter: v2.2.2 → [v2.2.3](https://github.com/litixsoft/karma-mocha-reporter/blob/master/CHANGELOG.md#223-2017-03-20) -- karma-phantomjs-launcher: v1.0.2 → [v1.0.4](https://github.com/karma-runner/karma-phantomjs-launcher/blob/master/CHANGELOG.md#104-2017-03-10) - fixed more path issues -- karma-webpack: v2.0.1 → [v2.0.3](https://github.com/webpack-contrib/karma-webpack/blob/master/CHANGELOG.md#203-2017-03-15) - don't swallow configuration errors -- mocha: v3.2.0 → [v3.4.2](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#342--2017-05-24) -- ora: v1.1.0 → v1.2.0 - added `warn()` and `info()` utilities -- postcss-loader: v1.2.2 → [v2.0.5](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#205-2017-05-10) - validate options -- resolve: v1.2.0 → [v1.3.3](https://github.com/browserify/resolve/compare/v1.2.0...v1.3.3) -- style-loader: v0.13.1 → [v0.18.1](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0181-2017-05-23) -- url-loader: v0.5.7 → [v0.5.8](https://github.com/webpack-contrib/url-loader/releases/tag/v0.5.8) - fix loader util deprecation warning -- webpack: v2.2.1 → [v2.6.1](https://github.com/webpack/webpack/releases) - `import()` can now configure a chunk name, `require.ensure()` can now take an error callback, added `module.strictExportPresence` -- webpack-dev-middleware: v1.9.0 → [v1.10.2](https://github.com/webpack/webpack-dev-middleware/releases) - CORS security fix -- webpack-hot-middleware: v2.15.0 → [v2.18.0](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.15.0...v2.18.0) - client overlay style can now be customised with CSS using `#webpack-hot-middleware-clientOverlay` -- webpack-merge: v2.4.0 → [v4.1.0](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#410--2017-03-16) -- whatwg-fetch: v2.0.2 → [v2.0.3](https://github.com/github/fetch/releases/tag/v2.0.3) - -[babel6230]: https://github.com/babel/babel/blob/master/CHANGELOG.md#6230-2017-02-13 -[babel6241]: https://github.com/babel/babel/blob/master/CHANGELOG.md#6240-2017-03-13 - -**Internal:** - -- Use `fs` and `fs-extra` instead of `glob` and `rimraf`, which are now only `devDependencies`. - -# 0.15.8 / 2017-05-11 - -**Dependencies:** - -- extract-text-webpack-plugin: [v2.1.0](https://github.com/webpack-contrib/extract-text-webpack-plugin/blob/master/CHANGELOG.md#210-2017-03-05) - fix bad scoped version in nwb v0.15.7 -- html-webpack-plugin: v2.26.0 → [v2.28.0](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2280) - revert relative loader resolving change from v2.25.0 back to a full path -- webpack: v2.2.0 → [v2.2.1](https://github.com/webpack/webpack/releases/tag/v2.2.1) - `ident` is now automatic, fixes issue passing options to postcss-loader - -# 0.15.7 / 2017-05-11 - -**Added:** - -- Added [`npm.cjs` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#cjs-boolean) to disable creation of a CommonJS build in `lib/` if you don't need it [[#285](https://github.com/insin/nwb/issues/285)] [[treshugart][treshugart]] - -**Changed:** - -- Disable creation of a minified UMD build when [`webpack.uglify` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#uglify-object--false) is `false` [[#288](https://github.com/insin/nwb/issues/288)] [[treshugart][treshugart]] -- Support use of Karma `customLaunchers` which start with "Chrome" [[#296](https://github.com/insin/nwb/pull/296)] [[michaelsbradleyjr][michaelsbradleyjr]] - -**Fixed:** - -- Fixed typo in `clean` command in `react-component` skeleton [[#283](https://github.com/insin/nwb/pull/283)] [[totaldis][totaldis]] - -**Documentation:** - -- [Document use of Karma's `usePolling` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#karma-configuration) to reduce CPU usage on macOS [[#297](https://github.com/insin/nwb/issues/297)] [[michaelsbradleyjr][michaelsbradleyjr]] - -# 0.15.6 / 2017-02-11 - -**Changed:** - -- Explicitly call `process.exit(0)` from the `nwb` command when there are no errors running a command [[#262](https://github.com/insin/nwb/pull/262)] - -# 0.15.5 / 2017-02-06 - -**Fixed:** - -- Fixed blank version being set for the React `peerDependency` in new `react-component` projects. -- Use the transpiled ES5 version of `preact-compat` for compatibility builds using `react build` with the `--preact` flag, to prevent UglifyJS errors [[#244](https://github.com/insin/nwb/issues/244)] - -# 0.15.4 / 2017-01-26 - -**Changed:** - -- Support the Array version of deprecated `webpack.postcss` config. -- Tell the user they're including redundant config if they've manually configured `inferno-compat` or `preact-compat` aliases for React modules [[#247](https://github.com/insin/nwb/issues/247)] - -# 0.15.3 / 2017-01-25 - -**Fixed:** - -- Added a missing `.default` to the Preact project skeleton where CommonJS `require()` was being used to import an ES module [[#245](https://github.com/insin/nwb/issues/245)] - - `.default` must now be used to access the default export from an ES module when importing with CommonJS `require()` as Webpack 2 prevents module format mixing, which was previously used to provide CommonJS interop. - -# 0.15.2 / 2017-01-25 - -**Fixed:** - -- Use the transpiled ES5 version of `preact-compat`, as UglifyJS can't handle the ES `module` build [[#244](https://github.com/insin/nwb/issues/244)] - -# 0.15.1 / 2017-01-25 - -**Removed:** - -- Remove hints about possibly not needing `babel.cherryPick` due to Webpack 2 tree shaking, as this doesn't currently appear to be true. - -# 0.15.0 / 2017-01-25 - -**Breaking Changes:** - -- **Upgraded from Webpack 1 to Webpack 2** [[#110](https://github.com/insin/nwb/issues/110)] - - **Minimum Node.js version increased from 4.2 to 4.3** - this is Webpack 2's minimum supported Node.js version. - - **Strict Webpack configuration** - Webpack 2 is strict about what appears in its configuration object. If you're using [`webpack.extra` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#extra-object), it **must** conform to [Webpack 2's configuration format](https://webpack.js.org/configuration/) or your build will fail with a validation error. - - **Dropped CommonJS compatibility when importing ES modules** - Webpack 2 no longer allows you to mix CommonJS modules with ECMAScript modules - if a module uses `import` or `export` syntax, `exports` will be `undefined` and `module.exports` will be read-only and `undefined`. - - As a result, we can no longer provide CommonJS interop by default for ES Modules - you will need to check your code for usage of CommonJS `require()` to import ES modules and tack a `.default` on the end if you need to use the module's `export default`. - - > If you used nwb's Preact project skeleton, the `init()` function in `index.js` needs to have a `.default` tacked on when the `App` component is being imported. - - **Custom top-level properties no longer allowed in Webpack configuration** - Webpack 2 no longer allows custom top-level properties in its configuration. Loader configuration which can't be serialised, such as plugin objects, can now be provided directly as loader options instead using [`webpack.rules` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#rules-object) instead. - - This includes `postcss-loader`, which is now configured via `webpack.rules` instead of having its own special `webpack.postcss` config. - -**`nwb.config.js` Config Format Changes:** - -> For deprecations, nwb will continue to support the old format for the next couple of releases, displaying warning messages about the changes required and adapting deprecated config for use in the current version where possible. -> -> If you have an `nwb.config.js` file, run [`nwb check-config`](https://github.com/insin/nwb/blob/master/docs/Commands.md#check-config-command) after updating nwb to find out if there's anything you need to change. - -- Deprecated `karma.testDirs`, renaming this config to `karma.excludeFromCoverage`, as it can be configured to exclude any paths from code coverage, not just directories [[#236](https://github.com/insin/nwb/issues/236)] - - ```js - // < v0.15 // v0.15 - module.exports = { module.exports = { - karma: { karma: { - testDirs: [ => excludeFromCoverage: [ - 'test/', 'test/', - 'path/to/ignorethis.js' 'path/to/ignorethis.js' - ] ] - } } - } } - ``` - -- Deprecated `webpack.loaders`, renaming this config to `webpack.rules` to match Webpack 2's new config format: - - ```js - // < v0.15 // v0.15 - module.exports = { module.exports = { - webpack: { webpack: { - loaders: { => rules: { - /* ... */ /* ... */ - } } - } } - } } - ``` - -- Deprecated use of a `query` property to configure Webpack rule options as a separate object - an `options` property should now be used as per Webpack 2's new config format: - - ```js - // < v0.15 // v0.15 - module.exports = { module.exports = { - webpack: { webpack: { - loaders: { rules: { - css: { css: { - query: { => options: { - modules: /* ... */ modules: /* ... */ - } } - } } - } } - } } - } } - ``` - - You can also still configure loader options as a flat object to make this particular change irrelevant: - - ```js - module.exports = { - webpack: { - rules: { - css: { - modules: /* ... */ - } - } - } - } - ``` - -- Deprecated configuring PostCSS plugins with special `webpack.postcss` config - postcss-loader can now be configured like any other loader using [`webpack.rules` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#configuring-postcss): - - ```js - // < v0.15 // v0.15 - module.exports = { module.exports = { - webpack: { webpack: { - postcss: [ => rules: { - require('precss')(), postcss: { - require('autoprefixer')() plugins: [ - ] require('precss')(), - } require('autoprefixer')() - } ] - } - } - } - } - ``` - -**Removed:** - -- Removed support for configuration which was deprecated in nwb v0.12. -- Removed support for `json-schema` in `webpack.compat` config, as this library has now been fixed [[#227](https://github.com/insin/nwb/issues/227)] - -**Dependencies:** - -- autoprefixer: v6.6.1 → [v6.7.0](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#670) -- babel-cli: v6.18.0 → [v6.22.2](https://github.com/babel/babel/blob/master/CHANGELOG.md#6222-2017-01-19) -- babel-core: v6.21.0 → [v6.22.1](https://github.com/babel/babel/blob/master/CHANGELOG.md#6221-2017-01-19) -- babel-plugin-inferno: v1.5.0 → v1.7.0 - make plugin ES5-environment compatible; add option to import `createVNode` -- babel-plugin-transform-react-jsx: v6.8.0 → [v6.22.0][babel6220] -- babel-plugin-transform-react-jsx-self: v6.11.0 → [v6.22.0][babel6220] -- babel-plugin-transform-react-jsx-source: v6.9.0 → [v6.22.0][babel6220] -- babel-plugin-transform-runtime: v6.15.0 → [v6.22.0][babel6220] -- babel-polyfill: v6.20.0 → [v6.22.0][babel6220] -- babel-preset-es2015: v6.18.0 → [v6.22.0][babel6220] -- babel-preset-es2016: v6.16.0 → [v6.22.0][babel6220] -- babel-preset-react : v6.16.0 → [v6.22.0][babel6220] -- babel-preset-stage-0: v6.16.0 → [v6.22.0][babel6220] -- babel-preset-stage-1: v6.16.0 → [v6.22.0][babel6220] -- babel-preset-stage-2: v6.18.0 → [v6.22.0][babel6220] -- babel-preset-stage-3: v6.17.0 → [v6.22.0][babel6220] -- babel-runtime: v6.20.0 → [v6.22.0][babel6220] -- detect-port: v1.0.7 → [v1.1.0](https://github.com/node-modules/detect-port/compare/1.0.7...1.1.0) -- filesize: v3.3.0 → [v3.4.3](https://github.com/avoidwork/filesize.js/compare/3.3.0...3.4.3) -- html-webpack-plugin: v2.24.1 → [v2.26.0](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2260) - Webpack 2 RC support -- inquirer: v2.0.0 → [v3.0.1](https://github.com/SBoudrias/Inquirer.js/releases/) - drop Node.js 0.12 support -- karma: v1.3.0 → [v1.4.0](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md#140-2017-01-14) -- karma-mocha-reporter: v2.2.1 → [v2.2.2](https://github.com/litixsoft/karma-mocha-reporter/blob/master/CHANGELOG.md#222-2017-01-19) -- karma-webpack: v1.8.0 → v2.0.1 - Webpack 2 RC support -- object-assign: v4.1.0 → [v4.1.1](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#122) -- ora: v0.4.1 → v1.1.0 - text can now be changed while stopping and persisting -- postcss-loader: v1.2.1 → [v1.2.2](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#122) -- webpack: v1.14.0 → [v2.2.0](https://medium.com/webpack/webpack-2-2-the-final-release-76c3d43bf144) - \o/ -- webpack-merge: v2.3.1 → [v2.4.0](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#240--2017-01-12) -- whatwg-fetch: v2.0.1 → [v2.0.2](https://github.com/github/fetch/releases/tag/v2.0.2) - -[babel6220]: https://github.com/babel/babel/blob/master/CHANGELOG.md#6220-2017-01-19 - -**Temporarily Scoped Dependencies:** - -These are being scoped to both make use of unreleased features and to test them out: - -- @insin/extract-text-webpack-plugin - scoped until [this PR](https://github.com/webpack/extract-text-webpack-plugin/pull/343) is merged and released -- @insin/npm-install-webpack-plugin - scoped until new features are merged and released - -**Internal:** - -- Dropped unused `fs-extra` dependency. -- Use [`babel-preset-env`](https://github.com/babel/babel-preset-env/) when transpiling to `lib/`, targeting Node.js 4 [[#233](https://github.com/insin/nwb/issues/233)] -- Use ES2015 `String` methods available in Node.js 4 instead of `String.prototype.indexOf` comparisons [[#222](https://github.com/insin/nwb/issues/222)] - -# 0.14.3 / 2017-01-21 - -**Fixed:** - -- Fix `inferno build` command [[#241](https://github.com/insin/nwb/issues/241)] [[balazs4][balazs4]] - -# 0.14.2 / 2017-01-20 - -**Fixed:** - -- Fix using Express middleware with a config file which exports a function [[#238](https://github.com/insin/nwb/issues/238)] - -# 0.14.1 / 2017-01-13 - -**Fixed:** - -- Fix running tests with base config only (`web-app` and `web-module` projects). - -**Dependencies:** - -- Downgrade `html-webpack-plugin` to v2.24.1 while issues later versions cause with `npm-install-webpack-plugin` are unresolved. - -# 0.14.0 / 2017-01-13 - -**Fixed:** - -- To prevent version compatibility issues using project commands from a globally-installed `nwb`, it will now exit with a warning if the project specifies a different version of nwb in `package.json` [[#167](https://github.com/insin/nwb/issues/167)] - - The ability to run project commands like `build`, `serve` etc. from a global `nwb` install is provided so you don't have to reinstall the entirety of nwb when creating new projects, but it's *recommended* that you switch to a locally-installed version later, as relying on globally-installed tool versions is brittle. -- Fix `clean` commands in paths with spaces [[#181](https://github.com/insin/nwb/issues/181)] - -**Added:** - -- Added an `inferno` command for quick Inferno prototyping and building. Use `inferno run <entry.js>` to serve a module and `inferno build <entry.js> [dist/]` to build it. -- Added a `preact` command for quick Preact prototyping and building. Use `preact run <entry.js>` to serve a module and `preact build <entry.js> [dist/]` to build it. -- The `inferno` and `preact` commands use a render shim module by default which hooks into `Inferno.render()` and `Preact.render()` to intercept the incoming VNode and re-render it from the top when accepting Hot Module Replacement, so if you're calling `render()` yourself you don't have to specify a DOM node, or a `root` when re-rendering in Preact. - - If you want to take full control of rendering, use the `--force` flag and nwb will skip the render shim and use your entry module directly. - - The `react` command's render shim doesn't hook into `ReactDOM.render()` and only handles rendering exported components or elements for convenient prototyping, as [react-transform-hmr](https://github.com/gaearon/react-transform-hmr) handles the details of accepting Hot Module Replacement and patching/re-rendering at the component/module level. -- Added new features which are available in the `inferno` and `preact` commands to the existing `react` command: - - Added a `--plugins` option to specify nwb plugins which should be installed and used without having to set up a `package.json`. - - Added a `--force` option to force use of the provided entry module directly instead of the render shim module which is used by default to support quick prototyping. - - Added a `--no-polyfill` option to disable inclusion of nwb's default polyfills for `Promise`, `fetch()` and `Object.assign()` if you're not using them or don't need them polyfilled. - - Inferno compat and Preact compat dependencies are now automatically installed if missing. - - `react build` can now build a module which exports a React component or element, for quick sharing of prototypes. -- Inferno and Preact apps are now configured to use their respective React compatibility modules by default if `react` or `react-dom` are imported, allowing use of existing React code out of the box. - -**Changed:** - -- The Webpack manifest module is now generated when building an app (as well as being inlined into the generated `index.html`) - you will need to include this first if manually handling HTML generation after building. -- Express middleware now supports Inferno, Preact and plain JavaScript apps, not just React. -- When building a React app using the `--inferno` or `--preact` flags, the required compatibility dependencies are now installed automatically if they can't be resolved from your project directory. -- When creating new projects, the latest version of dependencies will be installed, rather than using a a version range hardcoded in nwb. -- Skip initialising a Git repo if a `.git/` directory already exists, e.g. you may want to use `nwb init` in an existing repo. -- The default build for a React component demo app now supports use of a `demo/public/` directory for static content. -- An `args` property is now included in the object passed to user configs which export a function - this contains parsed arguments, e.g. `args.preact` will be `true` if you passed `--preact` when calling `nwb`. - -**Removed:** - -- Removed support for using `--set-env-VAR_NAME` arguments to set environment variables. -- `jsnext:main` is no longer included `package.json` for new `react-component` and `web-module` projects - only the "more standard" `module` property is used to point to an ES2015 modules build [[#215](https://github.com/insin/nwb/issues/215)] - -**Dependencies:** - -- autoprefixer: v6.5.3 → [v6.6.1](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#661) -- babel-core: v6.20.1 → v6.21.0 -- babel-loader: v6.2.9 → [v6.2.10](https://github.com/babel/babel-loader/blob/master/CHANGELOG.md#v6210) - Webpack 2 RC support -- babel-plugin-inferno: v1.4.0 → v1.5.0 - use import instead of global Inferno reference -- babel-plugin-istanbul: v3.0.0 → [v3.1.2](https://github.com/istanbuljs/babel-plugin-istanbul/blob/master/CHANGELOG.md#312-2017-01-04) -- babel-plugin-lodash: v3.2.10 → [v3.2.11](https://github.com/lodash/babel-plugin-lodash/compare/3.2.10...3.2.11) -- detect-port: v1.0.6 → [v1.0.7](https://github.com/node-modules/detect-port/releases/tag/1.0.7) -- html-webpack-plugin: v2.24.1 → [v2.26.0](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2260) - Webpack 2 RC support -- karma-webpack: v1.8.0 → v1.8.1 - Webpack 2 RC support -- ora: v0.3.0 → v0.4.1 -- phantomjs-prebuilt: v2.1.13 → [v2.1.14](https://github.com/Medium/phantomjs/releases/tag/2.1.14) -- postcss-loader: v1.2.0 → [v1.2.1](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#121) -- resolve: v1.1.7 → [v1.2.0](https://github.com/browserify/resolve/compare/1.1.7...v1.2.0) -- webpack-dev-middleware: v1.8.4 → [v1.9.0](https://github.com/webpack/webpack-dev-middleware/releases/tag/v1.9.0) - Webpack 2 RC support -- webpack-hot-middleware: v2.13.2 → [v2.15.0](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.13.2...v2.15.0) - add cache for warnings -- webpack-merge: v1.0.2 → [v2.3.1](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#231--2017-01-06) - providing an empty array/object no longer overrides when merging - -# 0.13.8 / 2016-12-31 - -**Changed:** - -- Inferno apps now use Inferno 1.x by default. - -**Dependencies:** - -- babel-plugin-inferno: v1.3.0-beta17 → v1.4.0 - -# 0.13.7 / 2016-12-25 - -**Fixed:** - -- Updated Inferno Babel plugin to fix whitespace trimming issue. - -**Changed:** - -- Updated default Inferno version for new apps to 1.0.0-beta42. - -**Dependencies:** - -- babel-plugin-inferno: v1.2.0-beta13 → v1.3.0-beta17 - fixes whitespace trimming around newlines - -# 0.13.6 / 2016-12-13 - -**Fixed:** - -* Don't configure the [babel runtime transform](https://babeljs.io/docs/plugins/transform-runtime/)'s `moduleName` path when transpiling code for npm [[#205](https://github.com/insin/nwb/issues/205)] - - If you depend on `babel-runtime` in a React component or Web module (by using `async`/`await` or [enabling any of the runtime transform's other features](https://github.com/insin/nwb/blob/master/docs/Configuration.md#runtime-string--boolean) it needs to be resolvable from the end-user's dependencies, so should be added to your project's `peerDependencies`. - -# 0.13.5 / 2016-12-13 - -**Fixed:** - -* Fix bad char in initial Git commit [[#182](https://github.com/insin/nwb/issues/182) by [ntwcklng][ntwcklng]] - -# 0.13.4 / 2016-12-11 - -**Fixed:** - -* Fix default test in the `preact-app` skeleton [[#206](https://github.com/insin/nwb/pull/206) by [ntwcklng][ntwcklng]] - -# 0.13.3 / 2016-12-10 - -**Fixed:** - -* Fix npm scripts in the `inferno-app` skeleton. - -# 0.13.2 / 2016-12-10 - -**Fixed:** - -* Initialise a Git repo for a new project *after* installing dependencies, so package.json includes dependencies saved by npm in the initial commit. - -# 0.13.1 / 2016-12-10 - -**Added:** - -* Added a `--copy-files` flag for React component builds to copy files which will not be transpiled over to the build directories [[#58](https://github.com/insin/nwb/issues/58)] - -# 0.13.0 / 2016-12-09 - -**Added:** - -- Added new project types: `inferno-app` and `preact-app` - use these with `nwb new` or `nwb init` to develop [Inferno](https://infernojs.com/) and [Preact](https://preactjs.com/) apps [[#194](https://github.com/insin/nwb/issues/194)] -- Added an [`--inferno` flag](https://github.com/insin/nwb/blob/next/docs/Commands.md#build-1) to React app builds to create an [`inferno-compat`](https://github.com/trueadm/inferno/tree/master/packages/inferno-compat) build [[#194](https://github.com/insin/nwb/issues/194)] -- [`react-jsx-source`](https://babeljs.io/docs/plugins/transform-react-jsx-source/) and [`react-jsx-self`](https://babeljs.io/docs/plugins/transform-react-jsx-self/) Babel transforms are now enabled for React apps in development mode for improved debugging. -- A Git repo with an initial commit is now created by default when creating a new project. Pass a `--no-git` flag to disable this. -- Added project-specific variants of `nwb test`: `nwb test-react`, `nwb-test-inferno` and `nwb-test-preact`. -- Added an `audio` loader and an `svg` loader. - -**Removed:** - -- Removed hardcoded React preset from default Babel config when running tests - instead, `nwb test` will run the new `nwb test-react` command if you have a `react-app` or `react-component` project type in `nwb.config.js`. -- Dependencies are no longer bundled. As a result, Babel 6 dependencies will no longer be deduplicated for npm2 users, so an nwb install will be slower and larger - consider upgrading to npm3 or [yarn](https://yarnpkg.com/) if you can. -- Removed support for deprecated `webpack.plugins` config in `nwb.config.js` - this config must now be moved up into `webpack` instead. - -**Changed:** - -- Handling of`.svg` files has been moved from the `graphics` loader to the new `svg` loader so inlining can be configured separately. This matters if you're using a [sprite system](http://una.im/svg-icons/), as base64 inlining SVGs breaks [fragment identifiers](https://css-tricks.com/svg-fragment-identifiers-work/). -- Changed `babel-plugin-transform-runtime` configuration to make use of new `moduleName` config; Webpack module resolution no longer uses a blanket fallback to nwb's `node_modules/` for serving and builds. -- [`webpack.uglify` config](https://github.com/insin/nwb/blob/next/docs/Configuration.md#uglify-object--false) can now be set to `false` to disable use of `UglifyJSPlugin` in production builds for debugging [[#160](https://github.com/insin/nwb/issues/160)] - -**Dependencies:** - -- autoprefixer: v6.4.0 → [v6.5.3](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#653) -- babel-cli: v6.11.4 → v6.18.0 -- babel-core: v6.13.2 → v6.20.0 -- babel-loader: v6.2.4 → [v6.2.9](https://github.com/babel/babel-loader/blob/master/CHANGELOG.md) - better syntax error messages -- babel-plugin-istanbul: v2.0.0 → [v3.0.0](https://github.com/istanbuljs/babel-plugin-istanbul/blob/master/CHANGELOG.md#300-2016-11-14) -- babel-plugin-lodash: v3.2.8 → [v3.2.10](https://github.com/lodash/babel-plugin-lodash/compare/3.2.8...3.2.10) -- babel-plugin-transform-react-remove-prop-types: v0.2.9 → [v0.2.11](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/compare/v0.2.9...v0.2.11) -- babel-plugin-transform-runtime: v6.12.0 → [v6.15.0](https://github.com/babel/babel/blob/master/CHANGELOG.md#v6150-2016-08-31) - add `moduleName` config to specify runtime path -- babel-polyfill: v6.13.0 → v6.20.0 -- babel-preset-es2015: v6.14.0 → v6.18.0 -- babel-preset-es2016: v6.11.3 → v6.16.0 -- babel-preset-react: v6.11.1 → v6.16.0 -- babel-preset-stage-0: v6.5.0 → v6.16.0 -- babel-preset-stage-1: v6.13.0 → v6.16.0 -- babel-preset-stage-2: v6.13.0 → v6.18.0 -- babel-preset-stage-3: v6.11.0 → v6.17.0 -- babel-runtime: v6.11.6 → v6.20.0 -- case-sensitive-paths-webpack-plugin: v1.1.3 → v1.1.4 - handle cwd being incorrect case -- copy-webpack-plugin: v3.0.1 → [v4.0.1](https://github.com/kevlened/copy-webpack-plugin/releases) -- css-loader: v0.23.1 → [v0.26.1](https://github.com/webpack/css-loader/compare/v0.23.0...v0.26.1) - cssnano's use of autoprefixer is now disabled by default -- detect-port: v1.0.0 → v1.0.6 -- figures: v1.7.0 → v2.0.0 -- html-webpack-plugin: v2.22.0 → [v2.24.1](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2241) -- inquirer: v1.1.2 → [v2.0.0](https://github.com/SBoudrias/Inquirer.js/releases/tag/v2.0.0) -- glob: v7.0.5 → [v7.1.1](https://github.com/isaacs/node-glob/compare/v7.0.5...v7.1.1) -- karma: v1.2.0 → [v1.3.0](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md#130-2016-09-09) -- karma-chrome-launcher: v1.0.1 → [v2.0.0](https://github.com/karma-runner/karma-chrome-launcher/blob/master/CHANGELOG.md#200-2016-08-18) - chromium support -- karma-mocha: v1.1.1 → [v1.3.0](https://github.com/karma-runner/karma-mocha/compare/v1.1.1...v1.23.0) -- karma-mocha-reporter: v2.1.0 → [v2.2.1](https://github.com/litixsoft/karma-mocha-reporter/blob/master/CHANGELOG.md#221-2016-11-18) -- karma-phantomjs-launcher: v1.0.1 → [v1.0.2](https://github.com/karma-runner/karma-phantomjs-launcher/blob/master/CHANGELOG.md#102-2016-08-31) - fix phantomjs path calculation -- mocha: v3.0.2 → [v3.2.0](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#320--2016-11-24) -- phantomjs-prebuilt: v2.1.12 → [v2.1.13](https://github.com/Medium/phantomjs/releases/tag/2.1.13) -- postcss-loader: v0.10.0 → [v1.2.0](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#12) -- qs: v6.2.1 → [v6.3.0](https://github.com/ljharb/qs/blob/master/CHANGELOG.md#630) -- webpack: v1.13.1 → [v1.14.0](https://github.com/webpack/webpack/compare/v1.13.1...v1.14.0) - updated node-libs-browser and uglifyjs versions - `screw_ie8` is now enabled by default; fix for Babel sourcemap issue -- webpack-merge: v0.14.1 → [v1.0.2](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#102--2016-11-29) -- webpack-dev-middleware: v1.6.1 → [v1.8.4](https://github.com/webpack/webpack-dev-middleware/blob/master/CHANGELOG.md#184-2016-10-08) -- webpack-hot-middleware: v2.12.2 → [v2.13.2](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.12.2...v2.13.2) -- whatwg-fetch: v1.0.0 → [v2.0.1](https://github.com/github/fetch/releases) - changes behaviour of `Headers` to be spec-compliant - -# 0.12.2 / 2016-09-29 - -**Removed:** - -- Dropped the production `react-constant-elements` transform for now due to bugs. - -# 0.12.1 / 2016-09-15 - -**Experimental:** - -- `react run` can now run modules which export a React component or element. - -**Added:** - -- Added a `reload` option to [Express middleware](https://github.com/insin/nwb/blob/master/docs/Middleware.md#middlewareexpress-options-object) to enable reloading the page if Hot Module Reloading is unsuccessful [[#168](https://github.com/insin/nwb/issues/168)] - -# 0.12.0 / 2016-08-16 - -**Breaking Changes:** - -- **Dropped Node.js 0.12 support** - - Based on the `engines` config of nwb's dependencies, Node.js 4.2.0 is now the minimum required version. -- **Upgraded from Babel 5 to Babel 6** [[#12](https://github.com/insin/nwb/issues/12)] [[#31](https://github.com/insin/nwb/issues/31)] [[@geowarin](https://github.com/geowarin/)] - - Babel 6 introduced [a number of breaking changes](https://github.com/babel/babel/blob/master/CHANGELOG.md#600) which you may need to account for in your codebase if you're using nwb or were otherwise using Babel 5. - - [`babel` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#babel-configuration) in `nwb.config.js` is **no longer directly equivalent to what you would put in a [`.babelrc` file](https://babeljs.io/docs/usage/babelrc/)**. -- **Added support for long-term caching** [[#73](https://github.com/insin/nwb/issues/73)] - - A deterministic hash is now included in the filenames of generated `.js` and `.css` files. - - The Webpack manifest (required for module loading) is now extracted and automatically injected prior to the `</body>` tag, so **your HTML template *must* have a `</body>` tag**. - - **If you do any post-build processing on generated files it might need to be updated**, as production app builds will now generate files as `[name].[hash].[ext]` instead of `[name].[ext]`. -- **Dropped support for the `.jsx` extension** - - [It's dead, Jim](https://github.com/facebookincubator/create-react-app/issues/87#issuecomment-234627904). - - > You can use [`webpack.loaders` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#loaders-object) to set `/\.jsx?$/` as `babel-loader`'s `test` config and [`webpack.extra config`](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#extra-object) to add `.jsx` back to the `resolve.extensions` list if you're using `.jsx` files and can't reasonably migrate away. -- **Dropped `build-module` and `build-umd/clean-umd`commands** - - These were a confusing middle layer which split the implementation of building a React component or browser-focused npm module in two. They both required a config file to provide a project `type` for nwb to figure out what to do. - - They've been **replaced with `build-react-component` and `build-web-module` commands**, which are now used in `package.json` `scripts` in the corresponding project skeletons. - - As a result **having a config file is now optional for all project types**. If you don't need configuration, you can delete the `nwb.config.js` file created as a convenience by project skeletons. - - A config file is now only required if you want to use the generic `build`, `clean` and `serve` commands. -- **Changed ES6 module build directory from `es6/` to `es/`** - - Upgrade steps: - - - Replace `"es6/index.js"` with `"es/index.js"` in `package.json` `"jsnext:main"` config - - Also add `"module": "es/index.js"`, as this is part of [a proposal for native module support](https://github.com/dherman/defense-of-dot-js/blob/master/proposal.md) which is being supported by multiple bundlers. - - Replace `"es6"` with `"es"` in `package.json` `files` config - -- **Dropped `webpack.vendorBundle` config in favour of a `--no-vendor` flag** - - Making this feature toggle a command line argument makes it easier to try, and to combine with other feature toggles like `--preact`. - - Tweak your `package.json` `"build"` script instead if you were using `webpack.vendorBundle: false` config: - - ```json - { - "scripts": { - "build": "nwb build-react-app --no-vendor" - } - } - ``` - -**`nwb.config.js` Config Format Changes:** - -- **`build` config is deprecated in favour of new [`npm` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#npm-object)**, which is a slightly different format. - - nwb will adapt any `build` config it finds for the current build and log out the equivalent `npm` config. - - ``` - // < v0.12 // v0.12 - module.exports = { module.exports = { - build: { => npm: { - jsNext: true, esModules: true, - umd: true, => umd: { - global: 'MyComponent', global: 'MyComponent', - externals: {'react': 'React'} externals: {'react': 'React'} - } } - } } - } - ``` - ``` - // < v0.12 // v0.12 - simple UMD config without externals - module.exports = { module.exports = { - build: { => npm: { - jsNext: true, esModules: true, - umd: true, => umd: 'myLib' - global: 'MyLib' } - } } - } - ``` - -- **The Babel [runtime transform](https://babeljs.io/docs/plugins/transform-runtime/) is now configured using new [`babel.runtime` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#runtime-string--boolean)** instead of Babel 5's `optional` config. - - **The runtime transform is now partially-enabled by default** to support use of `async`/`await` and generators, so update your configuration accordingly. nwb will adapt `['runtime']` config for the current build by converting it to `true`. - - ``` - // < v0.12 // v0.12 - enabled by default for regenerator - module.exports = { - babel: { - optional: ['runtime'] => // You can remove your config if you were - } // using it for async/await or generators - } - ``` - ``` - // < v0.12 // v0.12 - also import helpers from - module.exports = { module.exports = { - babel: { babel: { - optional: ['runtime'] => runtime: 'helpers' - } } - } } - ``` - -- **[`babel.loose` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#loose-boolean) is now Boolean** instead of Babel 5's string config. - - **[Loose mode](http://www.2ality.com/2015/12/babel6-loose-mode.html) is now enabled by default**, so `loose` config is only used if you need to disable loose mode. - - ``` - // < v0.12 // v0.12 - enabled by default - module.exports = { - babel: { - loose: 'all' => (none) - } - } - ``` - ``` - // < v0.12 - loose mode not used // v0.12 - disabling loose mode - module.exports = { - babel: { - (none) => loose: false - } - } - ``` - -- **`karma.tests` config is deprecated in favour of new [`karma.testContext`](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#testcontext-string) and [`karma.testFiles` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#testfiles-string--arraystring)**, depending on which was being specified. If `karma.tests` is present, nwb will attempt to detect the appropriate new config to use it for, or will otherwise fall back to the new default config. - - ``` - // < v0.12 // v0.12 - using a Webpack context module - module.exports = { module.exports = { - karma: { karma: { - tests: 'tests.webpack.js' => testContext: 'tests.webpack.js' - } } - } } - ``` - ``` - // < v0.12 // v0.12 - custom test file glob - module.exports = { module.exports = { - karma: { karma: { - tests: 'test/**.test.js' => testFiles: 'test/**.test.js' - } } - } } - ``` - -**Developer Experience Improvements:** - -- **Added a `check-config` command which checks your nwb configuration file** for errors and deprecated usage, and provides some usage hints (e.g. where more convenient config is available). - - Run this after upgrading your nwb version and it will tell you what needs to be changed. -- **New user-friendly output for Webpack builds based on [create-react-app](https://github.com/facebookincubator/create-react-app)'s**. - - This provides friendlier error and warning reporting, reports the gzipped size of generated files and uses a persistent console for development server logging. - - **Windows Note:** running a development server will clear the current screen in your console - in Windows the escape codes used to do this have the unfortunate effect of clearing *all* the scrollback history in your current console. - - To avoid this **use the `start` command to spawn a new command window when running the development server in Windows**, e.g.: - - ``` - start npm start - start react run app.js - ``` -- **Apps can now use `fetch`, `async`/`await` and generators out of the box without any configuration.** - - `Promise`, `fetch`, `Object.assign` polyfills and the regenerator runtime are now provided by default. -- You can now **transform destructured imports to cherry-picked imports for specified modules** using new [`babel.cherryPick` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#cherrypick-string--arraystring) [[#141](https://github.com/insin/nwb/issues/141)] -- Case-sensitivity of `require`/`import` paths is now enforced by [`CaseSensitivePathsPlugin`](https://github.com/Urthen/case-sensitive-paths-webpack-plugin), avoiding an easy-to-overlook cause of CI build failure if you don't develop on Linux. -- If the intended dev server port is not available, you will now be prompted to continue with a different, free port. - -**React App Optimisations:** - -- **Production React builds now remove `propTypes` from ES6 class and stateless functional components** (but not from your dependencies) using [react-remove-prop-types](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types) [[#97](https://github.com/insin/nwb/issues/97)] - -- **Added a [`--preact` flag](https://github.com/insin/nwb/blob/0.12/docs/Commands.md#build-1)** to React app builds to create a [`preact-compat`](https://github.com/developit/preact-compat) build. - - This is an easy way to try [Preact](https://preactjs.com/) with your React apps, resulting in a much smaller bundle if your app is compatible [[#124](https://github.com/insin/nwb/issues/124)] - -**Babel:** - -- **nwb implements its own support for a Babel 6 equivalent of Babel 5's `stage` configuration** to [choose which experimental features are enabled](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#stage-number--false), including defaulting to [Stage 2](https://babeljs.io/docs/plugins/preset-stage-2/). - - For stage 2 and below, **decorators can be use by default**, as nwb will include the [Babel Legacy Decorator transform plugin](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy). See [the plugin's Best Effort documentation](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy#best-effort) for differences you will need to take into account if you were using Babel 5 decorators. -- **nwb preserves CommonJS interop for apps and component ES5 builds** using the [`add-module-exports`](https://github.com/59naga/babel-plugin-add-module-exports) plugin. - - This means a `.default`doesn't need to be tagged on when you're using `require()` with Webpack's code-splitting, or when people import your npm modules using `require()` directly. - - Babel 6 removed interop with CommonJS exports, as it allowed you to write broken ES6 code. Kent C. Dodds has [a post about this which is well worth reading](https://medium.com/@kentcdodds/misunderstanding-es6-modules-upgrading-babel-tears-and-a-solution-ad2d5ab93ce0) to understand what *not* to do. -- **[Loose mode](http://www.2ality.com/2015/12/babel6-loose-mode.html) is now enabled by default.** -- **Changed [`babel.loose` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#loose-boolean) to Boolean**. - - This is now only needed if you want to disable loose mode (e.g. in non-production environments to check for ES6 compliance errors in normal mode). -- **Added [`babel.runtime` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#runtime-string--boolean)** to configure the Babel runtime transform, replacing Babel 5's `optional` config. - - This is turned on by default, configured to import the regenerator runtime when `async`/`await` or generators are used. -- **Removed the inline element transform optimisation for React app production builds**, as the Babel 6 version of it currently depends on polyfilling `Symbol`. - -**Karma:** - -- **Changed default testing configuration** to support co-location of tests and a wider range of test file names and locations. This should be backwards-compatible with the previous defaults. - - Test files included by default are now `-test.js`, `.test.js` or `.spec.js` files anywhere underneath a `src/`, `test/` or `tests/` directory. - - Code coverage also ignores all code underneath `test/`, `tests/` or any `__tests__/` directory inside `src/` by default, as well as test files. -- **Added [`karma.browsers` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#browsers-string--arrayplugin)** to customise which browsers tests are run in. - - The plugin to support use of `'Chrome'` in this config is also available by default. -- **Added [`karma.testDirs` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#testdirs-string--arraystring)** to control which directories are excluded from code coverage reporting. -- **[`babel-plugin-istanbul`](https://github.com/istanbuljs/babel-plugin-istanbul) is now used to instrument code for test coverage** instead of `isparta-loader`. - -**Webpack:** - -*Default Loader Config* - -- **Disabled `css-loader`'s use of Autoprefixer** - nwb's PostCSS configuration is now the only source of prefix addition and removal [[#132](https://github.com/insin/nwb/issues/132)] -- All static file loaders now use `url-loader` (which falls back to `file-loader`) to allow you to configure inlining for any group of static files if needed. -- **Changed default `limit` config for all static file loaders to `1`**, effectively disabling inlining by default - if you want resources smaller than a given size to be inlined, configure `limit` using [`webpack.loaders` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#loaders-object). -- Moved handling of `.svg` files from the `fonts` loader to the `graphics` loader. -- Moved handling of `.eot` files to the `fonts` loader and removed the `eot` loader. -- Added a `video` loader for `.mp4'`, `.ogg` and `.webm`. -- Added `.webp` to the `graphics` loader. - -*Default Plugin Config* - -- **Updated default `UglifyJsPlugin` options** to strip comments from output and use the `screw_ie8` setting in every minification step. - -*Configuration* - -- **Added [`webpack.aliases` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#aliases-object)** to set up module resolving aliases, as a convenient alternative to using `webpack.extra.resolve.alias` [[#125](https://github.com/insin/nwb/issues/125)] -- **Added [`webpack.autoprefixer` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#autoprefixer-string--object)** to configure Autoprefixer in nwb's default PostCSS configuration [[#132](https://github.com/insin/nwb/issues/132)] -- **Added [`webpack.publicPath` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#publicpath-string)** to set up or clear the path/URL used for static resources, as a convenient alternative to using `webpack.extra.output.publicPath`. -- **Added [`webpack.uglify` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#uglify-object)** to allow customisation of Webpack `UglifyJsPlugin` options. -- **[`webpack.compat` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#compat-object) now supports `'json-schema': true`** to prevent a transitive [`json-schema`](https://github.com/kriszyp/json-schema) dependency breaking Webpack builds. This usually manifests itself as an `Uncaught Error: define cannot be used indirect` error. -- **Generated `module.noParse` config is now an `Array`**, so any user-provided config for it in `webpack.extra` (which should also be specified as an `Array`) can now be merged into it. - -**npm Build:** - -- When creating a project with an ES6 modules build enabled, a `"module"` property will be added to the project's `package.json` as well as `"jsnext:main"` [[#137](https://github.com/insin/nwb/issues/137)] - - This is the default property Webpack 2 uses to look for an ES6 modules build. -- `build` config is deprecated in favour of new [`npm` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#npm-object). -- **React component builds now wrap `propTypes` for ES6 class and stateless functional components with an environment check** - `if (process.env.NODE_ENV !== 'production')` - so they'll automatically be stripped from the production build in apps which use them. [[#145](https://github.com/insin/nwb/issues/145)] - - `propTypes` will be stripped from the minified UMD build. - - This can be disabled by passing a `--no-proptypes` flag. -- Building a React demo app during a React component build can now be skipped by passing a `--no-demo` flag [[#155](https://github.com/insin/nwb/issues/155)] - -**Other Configuration:** - -- **Fallback index serving for HTML5 History apps is now enabled by default** in the development server. This can be disabled by passing a `--no-fallback` flag. -- **Added [`polyfill` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#polyfill-boolean)** to disable default polyfilling of `Promise` and `fetch` for apps if you don't need it and want to shave a few KB off your build. -- **The dev server port can now be specified via a `PORT` environment variable**. The CLI `--port` takes precedence if both are provided. - -**CLI:** - -- Added a `nwb check-config` command. -- CLI now uses spinners for build commands, with gzipped filesize logging. -- **Reworked build commands for React components and npm modules** to remove a needless middle layer and add specific build commands for these project types. -- **Removed the `-g, --global` argument for enabling a UMD build** when creating a React component or web module project, in favour of passing a name to the `--umd` argument instead. -- **Removed the `--info` flag for showing webpack output**, as this is now handled in a more developer-friendly manner. - -**Starter Projects:** - -- The react-app project skeleton now includes examples of importing CSS and images. -- Required `<meta>` tags in HTML templates are now all first thing in `<head>`. -- Added `shrink-to-fit=no` to the `viewport` `<meta>` tag in HTML templates for Safari. - -**Dependencies:** - -- autoprefixer: v6.3.6 → [v6.4.0](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#640) -- babel\* v5 → babel\* v6 -- [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul/): v2.0.0 -- [babel-plugin-lodash](https://github.com/lodash/babel-plugin-lodash): v3.2.8 -- [babel-plugin-transform-react-remove-prop-types](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types): v0.2.9 -- [case-sensitive-paths-webpack-plugin](https://github.com/Urthen/case-sensitive-paths-webpack-plugin): v1.1.3 -- connect-history-api-fallback: v1.2.0 → [v1.3.0](https://github.com/bripkens/connect-history-api-fallback/blob/master/CHANGELOG.md#v130) - allow disabling of the dot rule -- copy-template-dir: v1.2.1 → v1.3.0 - support vars in filenames -- expect: v1.20.1 → [v1.20.2](https://github.com/mjackson/expect/compare/v1.20.1...v1.20.2) -- express: v4.13.4 → [v4.14.0](https://github.com/expressjs/express/blob/master/History.md#4140--2016-06-16) -- [figures](https://github.com/sindresorhus/figures): v1.7.0 -- file-loader: v0.8.5 → [v0.9.0](https://github.com/webpack/file-loader/compare/v0.8.5...v0.9.0) -- glob: v7.0.3 → [v7.0.5](https://github.com/isaacs/node-glob/compare/v7.0.3...v7.0.5) -- html-webpack-plugin: v2.19.0 → [v2.22.0](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2220) -- inquirer: v1.0.3 → [v1.1.2](https://github.com/SBoudrias/Inquirer.js/compare/v1.0.3...v1.1.2) -- karma: v0.13.22 → [v1.2.0](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md#120-2016-08-11) -- karma-chrome-launcher v1.0.1 -- karma-coverage: v1.0.0 → [v1.1.1](https://github.com/karma-runner/karma-coverage/blob/master/CHANGELOG.md#111-2016-07-23) -- karma-mocha-reporter: v2.0.3 → [v2.1.0](https://github.com/litixsoft/karma-mocha-reporter/compare/v2.0.3...v2.1.0) -- karma-phantomjs-launcher: v1.0.0 → [v1.0.1](https://github.com/karma-runner/karma-phantomjs-launcher/blob/master/CHANGELOG.md#101-2016-06-23) -- karma-webpack: v1.7.0 → [v1.8.0](https://github.com/webpack/karma-webpack/blob/master/CHANGELOG.md#180-2016-08-07) - remove dist from scm -- mocha: v2.5.3 → [v3.0.2](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#302--2016-08-08) -- npm-install-webpack-plugin: v4.0.1 → [v4.0.4](https://github.com/ericclemmons/npm-install-webpack-plugin/blob/master/CHANGELOG.md#404-2016-06-30) -- phantomjs-prebuilt: v2.1.7 → v2.1.12 - npm packaging fun -- postcss-loader: : v0.9.1 → [v0.10.0](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#0100) -- qs: v6.2.0 → [v6.2.1](https://github.com/ljharb/qs/blob/master/CHANGELOG.md#621) -- rimraf: v2.5.2 → [v2.5.3](https://github.com/isaacs/rimraf/compare/v2.5.2...v2.5.3) -- [webpack-fail-plugin](https://github.com/TiddoLangerak/webpack-fail-plugin): v1.0.5 -- webpack-hot-middleware: v2.10.0 → [v2.12.2](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.10.0...v2.12.2) -- [webpack-md5-hash](https://github.com/erm0l0v/webpack-md5-hash): v0.0.5 -- webpack-merge: v0.14.0 → [v0.14.1](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#0141--2016-07-25) - -# 0.11.1 / 2016-07-16 - -**Fixed:** - -- PostCSS config was not being created for the vendor/`node_modules/` loader for CSS preprocessor plugins [[#129](https://github.com/insin/nwb/issues/129)] - -# 0.11.0 / 2016-06-08 - -**Breaking Changes:** - -- Replaced the deprecated `autoprefixer-loader` with `postcss-loader` in default style pipelines - it's configured to do the same autoprefixing by default [[#57](https://github.com/insin/nwb/issues/57)] - - If you were configuring vendor prefixing using `webpack.loaders.autoprefixer`, you will now need to manage an `autprefixer` dependency yourself and use [`webpack.postcss`](https://github.com/insin/nwb/blob/0.11/docs/Configuration.md#postcss-object) to perform this configuration. - -**`nwb.config.js` Config Format Changes:** - -* `webpack.plugins` is deprecated - config under `webpack.plugins` should be moved up into `webpack` instead. Having certain config under a `plugins` prop was an implementation detail which wasn't relevant to end-users [[#113](https://github.com/insin/nwb/issues/113)] - - ```js - // < v0.11 - module.exports = { - webpack: { - plugins: { - define: {...}, - html: {...} - } - } - } - ``` - ```js - // v0.11 - module.exports = { - webpack: { - define: {...}, - html: {...} - } - } - ``` -* Support for flatter [Webpack loader configuration](https://github.com/insin/nwb/blob/0.11/docs/Configuration.md#loaders-object) was added. Having a `query` object is now optional - loader query configuration can now be placed directly under the loader's id [[#113](https://github.com/insin/nwb/issues/113)] - - ```js - // < v0.11 - module.exports = { - webpack: { - loaders: { - css: { - query: { - modules: true - } - } - } - } - } - ``` - ```js - // v0.11 - module.exports = { - webpack: { - loaders: { - css: { - modules: true - } - } - } - } - ``` - -**Added:** - -- Installing globally now adds a `react` command for quick React development starting from a single file. - - `react run entry.js` runs a development server. - - `react build entry.js` creates a static build. - - For these commands, Babel is preconfigured to allow you to use all of its Stage 0 features out of the box, including `async`/`await`. - - These are implemented by (the previously undocumented) `serve-react` and (new) `build-react` nwb commands. -- The entry point for apps and npm module UMD builds can now be specified as an argument to [`build` and `serve` commands](https://github.com/insin/nwb/blob/0.11/docs/Commands.md#project-type-specific-commands). The default is still `src/index.js`. [[#115](https://github.com/insin/nwb/issues/115)] -- The directory web apps are built into can now be specified as an argument to [`build`, `clean` and `serve` commands](https://github.com/insin/nwb/blob/0.11/docs/Commands.md#project-type-specific-commands). The default is still `dist/`. -- Added [`webpack.compat` config](https://github.com/insin/nwb/blob/0.11/docs/Configuration.md#compat-object) to enable compatibility tweaks for modules which are known to be problematic with Webpack - initially this includes support for Enzyme, Moment.js and Sinon.js 1.x [[#108](https://github.com/insin/nwb/issues/108)] -- Added [`webpack.postcss` config](https://github.com/insin/nwb/blob/0.11/docs/Configuration.md#postcss-array--object) to customise the PostCSS plugins applied to each style pipeline [[#57](https://github.com/insin/nwb/issues/57)] -- Added [`webpack.vendorBundle` config](https://github.com/insin/nwb/blob/0.11/docs/Configuration.md#vendorbundle-boolean) to disable automatically extracting anything imported from `node_modules/` out into a separate `vendor` chunk [[#106](https://github.com/insin/nwb/issues/106)] -- Added [documentation for creating and using a test context module](https://github.com/insin/nwb/blob/0.11/docs/Testing.md#using-a-test-context-module) if there's code you need to run prior to tests running, such as configuring your assertion library with additional assertions. -- Added a `--config` option to allow you to specify your own config file instead of `nwb.config.js`. - -**Changed:** - -- Apps are no longer required to provide their own HTML template. The default template path of `src/index.html` will continue to be used if a file exists there. If an alternative template is not provided via [`webpack.html` config](https://github.com/insin/nwb/blob/0.11/docs/Configuration.md#html-object), nwb will now fall back to using a basic template. -- Restored default use of the Babel polyfill in Karma config so tests (and their dependencies) can assume a modern environment. -- Default `babel-loader` config now uses [`cacheDirectory: true` for a speedup](https://github.com/babel/babel-loader#babel-loader-is-slow). -- Improved debug output (activated with a `DEBUG=nwb` environment variable) to print config objects in full - if you're configuring plugin objects (e.g. PostCSS plugins), it's recommended to create instances of them if you want to use debug output. -- `webpack.optimize.DedupePlugin` is now only used for production builds, as recommended in the Webpack docs. - -**Dependencies:** - -- html-webpack-plugin: v2.17.0 → [v2.19.0](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2190) -- inquirer: v1.0.2 → [v1.0.3](https://github.com/SBoudrias/Inquirer.js/compare/v1.0.2...v1.0.3) -- mocha: v2.4.5 → [v2.5.3](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#253--2016-05-25) -- npm-install-webpack-plugin: v3.1.2 → [v4.0.1](https://github.com/ericclemmons/npm-install-webpack-plugin/blob/master/CHANGELOG.md#401-2016-06-06) - saving is on by default and [a new `dev` option controls](https://github.com/ericclemmons/npm-install-webpack-plugin#usage) where installed dependencies get saved to -- [postcss-loader](https://github.com/postcss/postcss-loader): v0.9.1 -- redbox-noreact: v1.0.0 → [v1.1.0](https://github.com/insin/redbox-noreact/blob/master/CHANGES.md#110--2016-05-29) -- webpack: v1.13.0 → [v1.13.1](https://github.com/webpack/webpack/compare/v1.13.0...v1.13.1) -- webpack-merge: v0.12.0 → [v0.14.0](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#0140--2016-06-05) - -# 0.10.0 / 2016-05-16 - -**Breaking Changes:** - -- React v15 is now installed into React app/component skeletons by default. - -**Changed:** - -- Default Karma config now includes `showDiff: true` config for the default Mocha reporter. -- The dev server now logs an initial `webpack building...` message so you know you're waiting for the initial build. -- npm scripts in the skeletons generated for `react-app` and `web-app` projects now use project type-specific commands, so the `nwb.config.js` included with them can be deleted if you don't need any config tweaks. -- nwb now passes the `--save` option to npm when installing React dependencies, to honour any npm [save-exact](https://docs.npmjs.com/misc/config#save-exact) (recommended!) or [save-prefix](https://docs.npmjs.com/misc/config#save-exact) config you have set. - -**Added:** - -- Extra Karma config can now be configured via a `karma.extra` Object. -- Added a `--react` option to allow you to set the version of React which will be installed when creating apps or components. This defaults to whatever the stable version of React was when the version of `nwb` you're using was released. - -**Dependencies:** - -- chalk: v1.1.1 → [v1.1.3](https://github.com/chalk/chalk/compare/v1.1.1...v1.1.3) - update deps -- cross-spawn: v2.1.5 → [v2.2.3](https://github.com/IndigoUnited/node-cross-spawn/compare/2.1.5...2.2.3) - update deps -- [detect-port](https://github.com/xudafeng/detect-port/): v1.0.0 -- expect: v1.16.0 → [v1.20.1](https://github.com/mjackson/expect/blob/master/CHANGES.md#v1201) -- html-webpack-plugin: v2.14.0 → [v2.17.0](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2170) -- inquirer: v0.12.0 → [v1.0.2](https://github.com/SBoudrias/Inquirer.js/compare/v0.12.0...v1.0.2) - switch to Promise-based API -- karma-coverage: v0.5.5 → [v1.0.0](https://github.com/karma-runner/karma-coverage/compare/v0.5.5...v1.0.0) -- karma-mocha: v0.2.2 → [v1.0.1](https://github.com/karma-runner/karma-mocha/compare/v0.2.2...v1.0.1) -- karma-mocha-reporter: v2.0.0 → [v2.0.3](https://github.com/litixsoft/karma-mocha-reporter/compare/v2.0.0...v2.0.3) -- npm-install-webpack-plugin: v3.0.0 → [v3.1.2](https://github.com/ericclemmons/npm-install-webpack-plugin/blob/master/CHANGELOG.md#v312-2016-05-12) [[#77](https://github.com/insin/nwb/issues/77)] -- phantomjs-prebuilt: v2.1.6 → [v2.1.7](https://github.com/Medium/phantomjs/releases/tag/v2.1.7) -- qs: v6.1.0 → [v6.2.0](https://github.com/ljharb/qs/blob/master/CHANGELOG.md#620) -- webpack: v1.12.14 → [v1.13.0](https://github.com/webpack/webpack/compare/v1.12.14...v1.13.0) -- webpack-merge: v0.8.4 → [v0.12.0](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#0120--2016-04-19) - -# 0.9.2 / 2016-03-27 - -**Dependencies:** - -- webpack-dev-middleware: v1.6.0 → [v1.6.1](https://github.com/webpack/webpack-dev-middleware/compare/v1.6.0...v1.6.1) - fixes request path issue introduced in 1.6.0 - -# 0.9.1 / 2016-03-26 - -**Fixed:** - -- `style-loader` was not being specified to apply styles from additional chunks when extracting CSS. - -# 0.9.0 / 2016-03-26 - -**Breaking Changes:** - -- Changes to how React and plain JS web apps are built: - - Builds are now generated in `dist/` instead of `public/build/` - - `index.html` for builds is now generated based on a template in `src/index.html`, instead of using a static `public/index.html` [[#34](https://github.com/insin/nwb/issues/34)] - - **Upgrading existing projects:** - - - move your `public/index.html` to `src/index.html` and delete the `<link>` and `<script>` tags for `vendor` and `app` resources. These will now be injected at build time. - - replace `/public/build` in your `.gitignore` with `/dist/` - - - `public/` is now only for public files - any contents in this directory will now be copied to `dist/` at the start of a build. The development server will also serve static content from `public/`. - -**Removed:** - -- Backwards compatibility for `nwb.config.js` format changes made in 0.8 has been removed. - -**Added:** - -- Added a `--host` option when running the dev server [[#50](https://github.com/insin/nwb/issues/50)] -- `ExtractTextPlugin` (used to extract CSS when building) can now be configured using `webpack.plugins.extractText` config - this allows you to configure the `allChunks` setting if you want all CSS to be extracted when using code splitting. -- `HtmlWebpackPlugin` (used to generate an `index.html` when building) can now be configured using `webpack.plugins.html` config. - -**Changed:** - -- `breakConfig: true` has been added to default `babel-loader` config to avoid `.babelrc` files being resolved by Babel - all Babel configuration is expected to be in `nwb.config.js` [[#63](https://github.com/insin/nwb/issues/63)] -- Static resources handled by Webpack's `file-loader` now include a hash in their filenames for cachebusting when they change [[#38](https://github.com/insin/nwb/issues/38)] - -**Dependencies:** - -- babel: v5.8.34 → v5.8.38 - left-pad transitive dependency drama -- babel-core: v5.8.34 → v5.8.38 - left-pad transitive dependency drama -- connect-history-api-fallback: v1.1.0 → v1.2.0 - support custom `Accept` headers -- copy-template-dir: v1.2.0 → v1.2.1 - support large template folders -- expect: v1.14.0 → [v1.16.0](https://github.com/mjackson/expect/compare/v1.14.0...v1.16.0) - mostly packaging changes? -- glob: v7.0.0 → [v7.0.3](https://github.com/isaacs/node-glob/compare/v7.0.0...v7.0.3) - misc fixes -- html-webpack-plugin: v2.9.0 → [v2.14.0](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2140) -- karma: v0.13.21 → [v0.13.22](https://github.com/karma-runner/karma/releases/tag/v0.13.22) - removed a large test file from npm package -- karma-coverage: v0.5.3 → [v0.5.5](https://github.com/karma-runner/karma-coverage/blob/master/CHANGELOG.md#055-2016-03-07) - bug fixes -- karma-mocha-reporter: v1.2.3 → [v2.0.0](https://github.com/litixsoft/karma-mocha-reporter/compare/v1.2.3...v2.0.0) - add karma to peerDeps; wait for all browsers to run -- npm-install-webpack-plugin: v2.0.2 → [v3.0.0](https://github.com/ericclemmons/npm-install-webpack-plugin/blob/master/CHANGELOG.md#300-2016-03-07) - `resolve.alias` and `resolve.root` support [[#83](https://github.com/insin/nwb/issues/83)] -- phantomjs-prebuilt: v2.1.4 → v2.1.6 - minor fixes to custom CA handling -- react-transform-hmr: v1.0.2 → [v1.0.4](https://github.com/gaearon/react-transform-hmr/releases/tag/v1.0.4) - update react-proxy to fix a few correctness issues -- style-loader: v0.13.0 → [v0.13.1](https://github.com/webpack/style-loader/compare/v0.13.0...v0.13.1) - add query to style/useable -- webpack-dev-middleware: v1.5.1 → [v1.6.0](https://github.com/webpack/webpack-dev-middleware/compare/v1.5.1...v1.6.0) -- webpack-hot-middleware: v2.7.1 → [v2.10.0](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.7.1...v2.10.0) - improved error overlay styling -- webpack-merge: v0.7.3 → [v0.8.4](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#084--2016-03-17) - change merging behavior so only loaders get prepended - -# 0.8.1 / 2016-03-03 - -**Dependencies:** - -- karma-mocha-reporter: v1.2.2 → [v1.2.3](https://github.com/litixsoft/karma-mocha-reporter/compare/v1.2.2...v1.2.3) - don't fail test suites containing skipped tests - -# 0.8.0 / 2016-02-26 - -**Breaking Changes:** - -- [`npm-install-webpack-plugin`](https://github.com/ericclemmons/npm-install-webpack-plugin) is now used instead of `npm-install-loader` to implement `nwb serve --auto-install`. - - If you were configuring automatic npm installation using a `loaders.install.query.cli` config object, this should be moved to `webpack.plugins.install` instead. - -**`nwb.config.js` Config Format Changes:** - -* React component and vanilla JS module npm build configuration must now be specificed as a `build` object: - - ```js - // < v0.9 - module.exports = { - type: 'react-component', - externals: {react: 'React'}, - global: 'MyComponent', - jsNext: true, - umd: true - } - ``` - ```js - // v0.9 - module.exports = { - type: 'react-component', - build: { - externals: {react: 'React'}, - global: 'MyComponent', - jsNext: true, - umd: true - } - } - ``` -* Webpack configuration must now be specified as a `webpack` object: - - ```js - // < v0.9 - module.exports = { - type: 'react-app', - loaders: { - css: { - query: { - modules: true - } - } - } - } - ``` - ```js - // v0.9 - module.exports = { - type: 'react-app', - webpack: { - loaders: { - css: { - query: { - modules: true - } - } - } - } - } - ``` -* Webpack `define` config must now be specified in a `plugins` object: - - ```js - // < v0.9 - module.exports = { - type: 'react-app', - define: { - __VERSION__: JSON.stringify(require('./package.json').version) - } - } - ``` - ```js - // v0.9 - module.exports = { - type: 'react-app', - webpack: { - plugins: { - define: { - __VERSION__: JSON.stringify(require('./package.json').version) - } - } - } - } - ``` -* All "extra" Webpack config must be specified in a an `extra` object, including extra loaders. The new object must correspond with Webpack's config file layout. - - ```js - // < v0.9 - module.exports = { - type: 'react-app', - loaders: { - extra: [/* ... */] - } - } - ``` - ```js - // v0.9 - module.exports = { - type: 'react-app', - webpack: { - extra: { - module: { - loaders: [/* ... */] - } - } - } - } - ``` - -**Changes:** - -- `nwb.config.js` is now only required when running generic build commands: `build`, `clean`, `serve`, `test` - - `type` config is only required when running a generic build command, but if provided it must be valid. -- Karma tests now always run just once in a CI environment regardless of the `--server` flag - this allows you to use `--server` in your default `npm test` command if you want to, without needing a separate run script for CI. -- Development instructions in project skeletons were moved from `README.md` to a `CONTRIBUTING.md` file, and are now documented using `npm` and `npm run` commands instead of global `nwb` commands. -- All commands are now run in the current working directory - you no longer need to `require.resolve()` full paths to extra Babel plugins configured in `nwb.config.js`, just use their names as normal and Babel will now be able to import them. -- Upgraded to PhantomJS v2 for Karma tests. - - Babel polyfills are no longer included in Webpack config for Karma, as PhantomJS v2 uses a more recent version of WebKit. - -**Added:** - -- Extra webpack config can now be configured via a `webpack.extra` Object. - - To support adding other webpack built-in plugins via `extra`, if a function is exported from `nwb.config.js`, it will now be called with an object containing the following properties: - - `command` - the nwb command being executed - - `webpack` - the webpack module (for configuring extra plugins using nwb's version of webpack) -- Project type-specific versions of the `build`, `clean` and `serve` commands are now officially documented for direct use. -- A `test:watch` npm script was added to project template `package.json`. - -**Dependencies:** - -- autoprefixer-loader: v3.1.0 → v3.2.0 -- cross-spawn: v2.1.4 → [v2.1.5](https://github.com/IndigoUnited/node-cross-spawn/compare/2.1.4...2.1.5) - update `which` dependency (minor) -- expect: v1.13.4 → [v1.14.0](https://github.com/mjackson/expect/blob/master/CHANGES.md#v1140) - new features -- express: v4.13.3 → v4.13.4 - deps -- extract-text-webpack-plugin: v0.9.1 → [v1.0.1](https://github.com/webpack/extract-text-webpack-plugin/compare/v0.9.1...v1.0.1) - use webpack-sources -- glob: v6.0.3 → v7.0.0 - throw if cwd is not a directory -- html-webpack-plugin: v1.7.0 → v2.9.0 -- inquirer: v0.11.2 → [v0.12.0](https://github.com/SBoudrias/Inquirer.js/compare/v0.11.2...v0.12.0) -- karma: v0.13.18 → v0.13.21 - socket.io 1.4.5 seems to have fixed the post-test hanging issue, [bug fixes and new features](https://github.com/karma-runner/karma/releases/tag/v0.13.20) -- karma-mocha: v0.2.1 → [v0.2.2](https://github.com/karma-runner/karma-mocha/compare/v0.2.1...v0.2.2) -- karma-mocha-reporter: v1.1.5 → [v1.2.2](https://github.com/litixsoft/karma-mocha-reporter/compare/v1.1.5...v1.2.2) - add diff output for failed tests -- karma-phantomjs-launcher: v0.2.3 → [v1.0.0](https://github.com/karma-runner/karma-phantomjs-launcher/blob/master/CHANGELOG.md#100-2016-01-28) - use phantomjs-prebuild -- mocha: v2.3.4 → [v2.4.5](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#245--2016-01-28) -- phantomjs v1.9.19 → phantomjs-prebuilt v2.1.4 - update installer to PhantomJS 2.x, renamed package -- qs: v5.2.0 → [v6.1.0](https://github.com/ljharb/qs/blob/master/CHANGELOG.md#610) - revert ES6 requirement, new `allowDots` option and some fixes -- react-transform-catch-errors: v1.0.1 → v1.0.2 - remove some files from the npm package -- react-transform-hmr: v1.0.1 → v1.0.2 - remove some files from the npm package -- resolve: v1.1.6 → [v1.1.7](https://github.com/browserify/resolve/compare/1.1.6...1.1.7) - fix `node_modules` paths on Windows -- rimraf: v2.5.0 → [v2.5.2](https://github.com/isaacs/rimraf/compare/v2.5.0...v2.5.2) -- webpack: v1.12.11 → [v1.12.14](https://github.com/webpack/webpack/compare/v1.12.11...v1.12.14) - fix Windows filename backslash incompatibility -- webpack-dev-middleware: v1.4.0 → [v1.5.1](https://github.com/webpack/webpack-dev-middleware/compare/v1.4.0...v1.5.1) - platform-agnostic path joining, use `res.send` when available -- webpack-hot-middleware: v2.6.0 → [v2.7.1](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.6.0...v2.7.1) - improve hint when hot reloads aren't accepted, update `strip-ansi` dependency (major), update stats handling - -# 0.7.2 / 2016-01-15 - -**Fixed:** - -- `react-app` and `web-app` Webpack build config didn't have `output.publicPath` set, so images required from JavaScript weren't being found [[#55](https://github.com/insin/nwb/issues/55)] -- Test runs no longer hang for up to a minute after completion [[#49](https://github.com/insin/nwb/issues/49)] - -**Dependencies:** - -- inquirer: v0.11.1 → [v0.11.2](https://github.com/SBoudrias/Inquirer.js/releases/tag/v0.11.2) - display fixes -- karma: v0.13.19 → v0.13.18 - downgraded due to the test hanging issue being introduced -- karma-sourcemap-loader: v0.3.6 → v0.3.7 - avoid EMFILE errors; fix charset bug; fix RangeError exception -- socket.io: v1.3.7 - temporarily pinned in nwb's dependencies until the Karma test hang issue is resolved -- webpack: v1.12.10 → [v1.12.11](https://github.com/webpack/webpack/compare/v1.12.10...v1.12.11) -- webpack-merge: v0.7.2 → v0.7.3 - bugfix - -# 0.7.1 / 2016-01-10 - -**Fixed:** - -- Express middleware had a broken import. - -**Added:** - -- Added an `autoInstall` option to Express middleware. - -**Dependencies:** - -- glob: v6.0.3 → v6.0.4 - remove `util._extend` to avoid deprecation warnings -- karma: v0.13.18 → [v0.13.19](https://github.com/karma-runner/karma/releases/tag/v0.13.19) - handle new socket.io internal format -- webpack: v1.12.9 → [v1.12.10](https://github.com/webpack/webpack/compare/v1.12.9...v1.12.10) -- webpack-merge: v0.7.1 → v0.7.2 - fix inclusion of removed `changelog` dependency - -# 0.7.0 / 2016-01-05 - -**Fixed:** - -- Fall back to nwb's dependencies in Webpack config instead of using an alias so `babel-runtime` can be picked up when `optional: ['runtime']` is used [hopefully fixing the weird `/node_modules/node_modules/` issue seen in [[#37](https://github.com/insin/nwb/issues/37)] - -**Added:** - -- Added an `--auto-install` flag to `nwb serve` which automatically installs npm dependencies and saves them to your package.json while developing. - -**Removed:** - -- `jsNext` config no longer defaults to `true` if not present. - -**Changed:** - -- Use `.x` for dependencies when generating skeleton project `package.json` instead of range sigils. - -**Dependencies:** - -- babel-runtime: v5.8.34 → v5.8.29 - downgraded due to a regression in typeof-react-element.js when used in conjunction with `optional: ['runtime']` -- karma: v0.13.16 → [v0.13.18](https://github.com/karma-runner/karma/releases/tag/v0.13.18) -- karma-phantomjs-launcher: v0.2.2 → v0.2.3 - correct cli argument order -- webpack-merge: v0.7.0 → v0.7.1 - performance improvements - -# 0.6.4 / 2016-01-02 - -**Fixed:** - -- `nwb build-umd` no longer errors if there is no `externals` config. - -**Changed:** - -- `nwb clean` now deletes the `coverage/` directory. - -**Dependencies:** - -- inquirer: v0.11.0 → [v0.11.1](https://github.com/SBoudrias/Inquirer.js/releases/tag/v0.11.1) - fix list overflow bug - -# 0.6.3 / 2015-12-31 - -**Fixed:** - -- Exit the process correctly with a non-zero exit code when an async command fails, such as `nwb test` [[#36](https://github.com/insin/nwb/pull/36)] [[jihchi][jihchi]] - -**Dependencies:** - -- karma-mocha-reporter: v1.1.4 → v1.1.5 - show error message when karma runner ends with error -- webpack-merge: v0.5.1 → v0.7.0 - bug fix for merging arrays within nested structures - -# 0.6.2 / 2015-12-30 - -**Dependencies:** - -- argv-set-env: v1.0.0 → [v1.0.1](https://github.com/kentcdodds/argv-set-env/releases/tag/v1.0.1) - docs -- glob: v6.0.1 → v6.0.3 - v6.0.2 was reverted -- karma: v0.13.15 → [v0.13.16](https://github.com/karma-runner/karma/releases/tag/v0.13.16) -- karma-mocha-reporter: v1.1.3 → v1.1.4 - handle duplicate descriptions -- karma-phantomjs-launcher: v0.2.1 → v0.2.2 -- react-transform-catch-errors: v1.0.0 → [v1.0.1](https://github.com/gaearon/react-transform-catch-errors/releases/tag/v1.0.1) - display the offending call stack more prominently -- rimraf: v2.4.5 → v2.5.0 - add glob option -- webpack-merge: v0.3.2 → v0.5.1 - fix recursive merging - -# 0.6.1 / 2015-12-30 - -**Fixed:** - -- The `es6/` directory wasn't included in the default `.gitignore` for npm module project skeletons. - -# 0.6.0 / 2015-12-23 - -**Added:** - -- Added an `nwb init` command - same as `nwb new` but creates a project in the current directory and uses the directory name by default [[#25](https://github.com/insin/nwb/issues/25)] -- Added a new `web-app` project type - this is for anyone who wants to use nwb's build/serve/test setup but isn't using React [[#24](https://github.com/insin/nwb/issues/24)] -- Added a `--reload` option to auto-reload the page when webpack hot module replacement gets stuck. This is primarily intended for use with the new `web-app` project type. -- Command-line arguments can now be used to configure settings for `nwb new`. - -**Fixed:** - -- Production optimisations weren't being applied to React app builds. -- Demo apps weren't generating sourcemaps when bundling. -- Use a non-zero exit code when displaying usage or otherwise exiting due to missing arguments [[#23](https://github.com/insin/nwb/issues/23)] - -**Changed:** - -- Reorganised and coloured `nwb help` output. -- Commands which create files now log details of what they've created [[#26](https://github.com/insin/nwb/issues/26)] -- The ES6 modules build for npm modules is now optional, controlled by a `jsNext` setting in `nwb.config.js`, defaulting to `true` [[#27](https://github.com/insin/nwb/issues/27)] - - nwb 0.6 will default `jsNext` to `true` and log a warning when it's missing from a config file - this behaviour will be removed in nwb v0.7. - -**Dependencies:** - -- copy-template-dir: v1.1.0 → v1.2.0 - provide created file paths in callback -- css-loader: v0.23.0 → v0.23.1 -- expect: v1.13.3 → v1.13.4 - comparing arrays of nested objects fix -- rimraf: v2.4.4 → v2.4.5 - -# 0.5.0 / 2015-12-15 - -**Added:** - -- Top-level Webpack config can now be provided for loaders which support it, as a `config` object in their `nwb.config.js` `loaders` configuration. This is intended for loaders which can't use serialisable `query` config due to plugins, such as some CSS preprocessors [[#18](https://github.com/insin/nwb/issues/18)] - -**Fixed:** - -- `files` config from template `package.json` was being used when packing nwb for publishing. Renamed them to `_package.json` to avoid this [[#22](https://github.com/insin/nwb/issues/22)] - -**Changed:** - -- Downgraded qs dependency so nwb can be used with Node.js 0.12.x [[#19](https://github.com/insin/nwb/issues/19)] - -**Dependencies:** - -- copy-template-dir: v1.0.5 → v1.1.0 - rename all files beginning with `_` -- expect: v1.13.0 → v1.13.3 - `Map`, `Set` and circular comparison fixes -- qs: v6.0.0 → v5.2.0 - downgrade to lose Node.js >= 4.0.0 requirement - -# 0.4.1 / 2015-12-13 - -**Fixed:** - -- Bad npm package for 0.4.0 - npm was reading the new `files` config from `package.json` in templates for React component/web module skeletons and applying it when packing nwb itself for publishing [[#21](https://github.com/insin/nwb/issues/21)] - -# 0.4.0 / 2015-12-11 - -**Added:** - -- Added `--fallback` option to `nwb serve`, for serving the index page from any path when developing React apps which use the HTML5 History API [[#16](https://github.com/insin/nwb/issues/16)] -- Added `"engines": {"node": ">=4.0.0"}` to `package.json` - nwb accidentally depends on this because it uses [qs](https://github.com/hapijs/qs) v6 [[#19](https://github.com/insin/nwb/issues/19)] -- Added `files` config to React component/web module skeleton `package.json`. - - The `files` config for the React component skeleton assumes that components published to npm with `require()` calls for CSS which ships with it will use a `css/` dir. -- Added a default ES6 build with untranspiled ES6 module usage [[#15](https://github.com/insin/nwb/issues/15)] - - This is pointed to by `"jsnext:main"` in project skeleton `package.json` for use by tree-shaking ES6 bundlers. - -**Fixed:** - -- Added missing `main` config to React component/web module skeleton `package.json`, pointing at the ES5 build in `lib/`. -- Express middleware wasn't included in npm package. - -**Changed:** - -- 1.0.0 is now the default version for project skeletons. - -# 0.3.1 / 2015-12-09 - -**Fixed:** - -- Generic `nwb build` was broken for React components/web modules in 0.3.0. - -# 0.3.0 / 2015-12-07 - -**Added:** - -- Support for CSS preprocessor plugin packages [[#6](https://github.com/insin/nwb/issues/6)] - - Loading of configuration objects exported by `'nwb-*'` dependencies found in `package.json`. - - Creation of style loading pipelines for plugins which provide `cssPreprocessors` configuration. - - [nwb-less](https://github.com/insin/nwb-less) - - [nwb-sass](https://github.com/insin/nwb-sass) - -**Fixed:** - -- Babel config is now passed to Babel when transpiling modules [[#13](https://github.com/insin/nwb/issues/13)] - -# 0.2.0 / 2015-12-05 - -**Added:** - -- Express [middleware](https://github.com/insin/nwb/blob/master/docs/Middleware.md#middleware) for running a React app on your own development server using nwb's Webpack config generation [[#8](https://github.com/insin/nwb/issues/8)] - -**Changed:** - -- Webpack loader config objects are now merged with [webpack-merge](https://github.com/survivejs/webpack-merge); query objects will now be deep merged, with lists occurring at the same position in build and user config being concatenated instead of overwritten. - -**Fixed:** - -- babel-runtime can now be resolved from nwb's dependencies when using `optional: ['runtime']` Babel config [[#10](https://github.com/insin/nwb/issues/10)] -- Paths to resources required from CSS in React app builds [[#9](https://github.com/insin/nwb/issues/9)] - -# 0.1.0 / 2015-12-02 - -First 0.x release. +Older changelogs are available in [the CHANGES archive](CHANGES.old.md). -[balazs4]: https://github.com/balazs4 -[bwendt-mylo]: https://github.com/bwendt-mylo -[DethAriel]: https://github.com/DethAriel -[grahamlyus]: https://github.com/grahamlyus -[hanford]: https://github.com/hanford -[jihchi]: https://github.com/jihchi -[michaelsbradleyjr]: https://github.com/michaelsbradleyjr [Muhnad]: https://github.com/Muhnad -[ngyikp]: https://github.com/ngyikp -[ntwcklng]: https://github.com/ntwcklng [rrapiteanu]: https://github.com/rrapiteanu -[seanofw]: https://github.com/seanofw -[stephenwf]: https://github.com/stephenwf -[totaldis]: https://github.com/totaldis -[treshugart]: https://github.com/treshugart diff --git a/CHANGES.old.md b/CHANGES.old.md new file mode 100644 index 00000000..58983dab --- /dev/null +++ b/CHANGES.old.md @@ -0,0 +1,2095 @@ +Newer changelogs are available in [the main CHANGES file](CHANGES.md). + +--- + +# 0.23.0 / 2018-08-03 + +## Breaking Changes + +- Updated Inferno config for Inferno 5 - `inferno-*` packages (such as `inferno-compat`) work again with Webpack 4 [[#440](https://github.com/insin/nwb/issues/440)] + +## Added + +- Added `prepublishOnly` to react-component and web-module project package.json scripts, which invokes `npm run build` prior to publishing [[#436](https://github.com/insin/nwb/issues/436)] [[hanford][hanford]] +- Added [`npm.umd.entry` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#entry-string) to specify a different entry point for the UMD build in npm module projects. Currently, the UMD build requires an entry point which *must* have a `default` export [[#411](https://github.com/insin/nwb/issues/411)] + +## Fixed + +- Always add `CopyPlugin` when [`webpack.copy` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#copy-array--object) is provided [[#431](https://github.com/insin/nwb/issues/431)] +- Remove use of object destructuring from render shims - fixes output of quick build commands in IE11 [[#453](https://github.com/insin/nwb/issues/453)] + +## Dependencies + +- autoprefixer: v8.1.0 → [v9.0.2](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#902) +- babel-core: v6.26.0 → [v6.26.3](https://github.com/babel/babel/releases/tag/v6.26.3) +- babel-loader: v7.1.4 → [v7.1.5](https://github.com/babel/babel-loader/releases/tag/v7.1.5) +- babel-plugin-inferno: v4.0.0 → [v5.0.1](https://github.com/infernojs/babel-plugin-inferno/releases) +- babel-plugin-istanbul: v4.1.5 → [v4.1.6](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v4.1.5...v4.1.6) +- babel-plugin-transform-decorators-legacy: v1.3.4 → [v1.3.5](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy/releases/tag/v1.3.5) +- chalk: v2.3.2 → [v2.4.1](https://github.com/chalk/chalk/compare/v2.3.0...v2.4.1) +- copy-template-dir: v1.3.0 → [v1.4.0](https://github.com/yoshuawuyts/copy-template-dir/releases/tag/v1.4.0) +- copy-webpack-plugin: v4.5.1 → [v4.5.2](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#452-2018-06-26) +- css-loader: v0.28.10 → [v1.0.0](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#100-2018-07-06) +- detect-port: v1.2.2 → [v1.2.3](https://github.com/node-modules/detect-port/releases) +- filesize: v3.6.0 → [v3.6.1](https://github.com/avoidwork/filesize.js/compare/3.6.0...3.6.1) +- fs-extra: v6.0.0 → [v7.0.0](https://github.com/jprichardson/node-fs-extra/blob/master/CHANGELOG.md#700--2018-07-16) +- gzip-size: v4.1.0 → [v5.0.0](https://github.com/sindresorhus/gzip-size/compare/v4.1.0...v5.0.0) - dropped Node.js 4 support +- html-webpack-plugin: v3.0.6 → [v3.2.0](https://github.com/jantimon/html-webpack-plugin/blob/master/CHANGELOG.md#320-2018-04-03) +- inquirer: v5.1.0 → [v6.0.0](https://github.com/SBoudrias/Inquirer.js/releases) +- karma: v2.0.0 → [v2.0.5](https://github.com/karma-runner/karma/releases) +- karma-coverage: v1.1.1 → [v1.1.2](https://github.com/karma-runner/karma-coverage/blob/master/CHANGELOG.md#112-2018-05-03) +- karma-webpack: v2.0.13 → [v3.0.0](https://github.com/webpack-contrib/karma-webpack/blob/master/CHANGELOG.md#300-2018-03-19) +- mini-css-extract-plugin v0.2.0 → [v0.4.1](https://github.com/webpack-contrib/mini-css-extract-plugin/releases) +- mocha: v5.0.4 → [v5.2.0](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#520--2018-05-18) +- opn: v5.2.0 → [v5.3.0](https://github.com/sindresorhus/opn/compare/v5.2.0...v5.3.0) +- ora: v2.0.0 → [v3.0.0](https://github.com/sindresorhus/ora/compare/v2.0.0...v3.0.0) +- postcss-loader: v2.1.1 → [v2.1.6](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#216-2018-07-10) +- resolve: v1.5.0 → [v1.8.1](https://github.com/browserify/resolve/compare/v1.5.0...v1.8.1) +- run-series: v1.1.6 → [v1.1.8](https://github.com/feross/run-series/compare/v1.1.6...v1.1.8) +- style-loader: v0.20.2 → [v0.21.0](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0210-2018-04-18) +- uglifyjs-webpack-plugin: v1.2.3 → [v1.2.7](https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/CHANGELOG.md#127-2018-06-25) +- webpack: v4.1.1 → [v4.16.4](https://github.com/webpack/webpack/releases) +- webpack-dev-middleware: v3.0.1 → [v3.1.3](https://github.com/webpack/webpack-dev-middleware/releases) +- webpack-dev-server: v3.1.1 → [v3.1.5](https://github.com/webpack/webpack-dev-server/releases) +- webpack-hot-middleware: v2.21.2 → [v2.22.3](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.21.2...v2.22.3) +- webpack-merge: v4.1.2 → [v4.1.4](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#414--2018-08-01) +- whatwg-fetch: v2.0.3 → [v2.0.4](https://github.com/github/fetch/releases/tag/v2.0.4) + +## Docs + +- Added [instructions for debugging in VS Code](https://github.com/insin/nwb/blob/master/docs/FAQ.md#how-can-i-debug-using-vs-code-when-running-an-app-with-nwb) to the FAQ [[#445](https://github.com/insin/nwb/issues/445)] +- Replaced references to "ES6" with plain old "ES" + +# 0.22.0 / 2018-03-13 + +## Breaking Changes + +- Node.js 4 is no longer supported; Node.js 6.11.5 is now the minimum required version, as per Webpack 4 [[#400](https://github.com/insin/nwb/issues/400)] +- Updated to Webpack 4 - if you were customising your build with `nwb.config.js`, some of the nwb config you depended on may have changed, and the options Webpack accepts may have changed [[#409](https://github.com/insin/nwb/issues/409)] + - Webpack's new `mode` option is now set to activate Webpack 4's new defaults, which removes the need for a bunch of manual configuration nwb was doing: + - `ModuleConcatenationPlugin` is now automatically enabled in `production` mode instead of being explicitly configured, so nwb's `webpack.hoisting` config has been removed. + - `NamedModulesPlugin` is now automatically used in `development` mode instead of being explicitly configured. + - Development UMD builds for modules now use `production` mode with minimization disabled, as the new `development` mode defaults are unsuitable for code which will be published to npm. + - Webpack's `optimization` options are now used for certain pieces of configuration: + - `optimization.noEmitOnErrors` is used instead of `NoEmitOnErrorsPlugin` to prevent emission of assets when using Hot Module Replacement. + - UglifyJS is now configured via `optimization.minimize`/`optimization.minimizer` instead of just adding `UglifyJsPlugin` directly to `plugins`. + - `CommonsChunkPlugin` has been removed in Webpack 4 - `optimization.runtimeChunk` is now configured to create a `runtime` chunk (which replaces the old `manifest` chunk) and `optimization.splitChunks` is configured to create a `vendor` bundle. + - Replaced used of `ExtractTextPlugin` with [`MiniCssExtractPlugin`](https://github.com/webpack-contrib/mini-css-extract-plugin): + - Separate CSS files are now created and loaded on-demand for code splits. + - Replaced `webpack.extractText` config with [`webpack.extractCSS` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#extractcss-object--boolean) - this is not backwards-compatible, as plugin options differ. + - Webpack's default `performance` option size warnings have been disabled (for now). +- Updated Inferno config for Inferno 4 - see the [Inferno v4 migration guide](https://github.com/infernojs/inferno/blob/master/docs/v4-migration.md) for breaking changes [[#429](https://github.com/insin/nwb/issues/429)] + - `nwb new inferno-app` now asks if you want to install `inferno-compat` as it's no longer a single dependency, defaulting to not installing it. +- `nwb new preact-app` now asks if you want to install `preact-compat`, defaulting to not installing it. +- Updated to Mocha 5, which dropped support for IE9 and IE10 and fixed some false positives. +- Removed support for deprecated `webpack.compat.enzyme`, `webpack.compat.sinon` and `webpack.style = 'old'` config. + +## Known Issues + +- Inferno is currently publishing `.mjs` files to npm, [which is breaking `inferno-*` packages with Webpack 4](https://github.com/infernojs/inferno/issues/1296), so e.g. `inferno-compat` won't work if you want to reuse React components. + +## Added + +- Added an `-f/--force` flag to `nwb new` to accept defaults and skip questions. + +## Changed + +- The dev server's fallback `index.html` serving can now be configured with dot arguments - e.g. pass `--fallback.disableDotRule` if you need to use dots in your path when using the HTML5 History API. +- `--no-polyfill` can now be used to disable default polyfills for app projects as well as quick commands. + +## Dependencies + +- autoprefixer: v7.2.5 → [v8.1.0](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#810) +- babel-loader: v7.1.2 → [v7.1.4](https://github.com/babel/babel-loader/releases) +- babel-plugin-inferno: v3.3.1 → [v4.0.0](https://github.com/infernojs/babel-plugin-inferno/releases) +- case-sensitive-paths-webpack-plugin: v2.1.1 → [v2.1.2](https://github.com/Urthen/case-sensitive-paths-webpack-plugin/blob/master/CHANGELOG.md#v212) +- chalk: v2.3.0 → [v2.3.2](https://github.com/chalk/chalk/compare/v2.3.0...v2.3.2) +- copy-webpack-plugin: v4.3.1 → [v4.5.1](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#451-2018-03-09) +- cross-spawn: v6.0.4 → [v6.0.5](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md#605-2018-03-02) +- css-loader: v0.28.9 → [v0.28.10](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#02810-2018-02-22) +- extract-text-webpack-plugin v3.0.0 → [mini-css-extract-plugin v0.2.0](https://github.com/webpack-contrib/mini-css-extract-plugin) +- file-loader: v1.1.6 → [v1.1.11](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#1111-2018-03-01) +- filesize: v3.5.11 → [v3.6.0](https://github.com/avoidwork/filesize.js/compare/3.5.11...3.6.0) +- html-webpack-plugin: v2.30.1 → [v3.0.6](https://github.com/jantimon/html-webpack-plugin/blob/master/CHANGELOG.md#306-2018-03-06) +- inquirer: v3.3.0 → [v5.1.0](https://github.com/SBoudrias/Inquirer.js/releases) - latest version requires Node.js 6 +- karma-webpack: v2.0.9 → [v2.0.13](https://github.com/webpack-contrib/karma-webpack/blob/master/CHANGELOG.md#2013-2018-02-27) +- mocha: v4.1.0 → [v5.0.4](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#504--2018-03-07) +- npm-install-webpack-plugin v4.0.5 → @insin/npm-install-webpack-plugin v5.0.0 - Webpack 4 compatibility +- ora: v1.3.0 → [v2.0.0](https://github.com/sindresorhus/ora/releases/tag/v2.0.0) +- postcss-loader: v2.0.10 → [v2.1.1](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#211-2018-02-26) +- style-loader: v0.20.1 → [v0.20.2](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0202-2018-02-15) - skip empty `url()`s +- uglifyjs-webpack-plugin: v1.1.8 → [v1.2.3](https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/CHANGELOG.md#123-2018-03-10) +- url-loader: v0.6.2 → [v1.0.1](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md#101-2018-03-03) +- webpack: v3.10.0 → [v4.1.1](https://github.com/webpack/webpack/releases) +- webpack-dev-middleware: v1.12.2 → [v3.0.1](https://github.com/webpack/webpack-dev-middleware/releases) +- webpack-dev-server: v2.9.7 → [v3.1.1](https://github.com/webpack/webpack-dev-server/releases) +- webpack-hot-middleware: v2.21.0 → [v2.21.2](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.21.0...v2.21.2) +- webpack-merge: v4.1.1 → [v4.1.2](https://github.com/survivejs/webpack-merge/compare/v4.1.1...v4.1.2) + +## Internal + +- Updated `StatusPlugin` and `InlineRuntimePlugin` to use the Use the new Webpack 4 `.hooks` plugin API. + +## Docs + +- Fixed [`publicPath` docs](https://github.com/insin/nwb/blob/master/docs/Configuration.md#publicpath-string), as Webpack's `output.publicPath` config can't be `null` [[#432](https://github.com/insin/nwb/issues/432)] [[stephenwf][stephenwf]] + +# 0.21.5 / 2018-02-02 + +## Dependencies + +- cross-spawn: v6.0.3 → [v6.0.4](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md#604-2018-01-31) + +# 0.21.4 / 2018-01-30 + +## Fixed + +- Fixed validation of `webpack.compat` locale properties [[#425](https://github.com/insin/nwb/issues/425)] +- Fixed false negative when checking if the port is available when `devServer.port` is specified as a `String` [[#423](https://github.com/insin/nwb/issues/423)] + +## Dependencies + +- uglifyjs-webpack-plugin: v1.1.6 → [v1.1.8](https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/CHANGELOG.md#118-2018-01-29) - reduce memory consumption + +# 0.21.3 / 2018-01-28 + +## Changed + +- `port` config in [`devServer` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#devserver-object) will now be used if configured [[#423](https://github.com/insin/nwb/issues/423)] + +## Dependencies + +- cross-spawn: v5.1.0 → [v6.0.3](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md#603-2018-01-23) +- css-loader: v0.28.7 → [v0.28.9](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#0289-2018-01-17) +- style-loader: v0.19.1 → [v0.20.1](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0201-2018-01-26) + +# 0.21.2 / 2018-01-17 + +## Fixed + +- Fixed validation of `babel.env` config [[#420](https://github.com/insin/nwb/issues/420)] [[ngyikp][ngyikp]] + +## Dependencies + +- autoprefixer: v7.2.4 → [v7.2.5](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#725) +- opn: v5.1.0 → [v5.2.0](https://github.com/sindresorhus/opn/compare/v5.1.0...v5.2.0) +- semver: v5.4.1 → [v5.5.0](https://github.com/npm/node-semver/compare/v5.4.1...v5.5.0) + +# 0.21.1 / 2018-01-12 + +## Fixed + +- Fixed validation of `webpack.extractText = false` config, which disables extraction of imported stylesheets into `.css` files [[#418](https://github.com/insin/nwb/issues/418)] + +## Dependencies + +- postcss-loader: v2.0.9 → [v2.0.10](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#2010-2018-01-03) +- uglifyjs-webpack-plugin: v1.1.5 → [v1.1.6](https://github.com/webpack-contrib/uglifyjs-webpack-plugin/releases/tag/v1.1.6) + +# 0.21.0 / 2018-01-03 + +## Breaking Changes + +- Validation of the configuration object provided by `nwb.config.js` files has been expanded, so previously valid config files may now be invalid [[#136](https://github.com/insin/nwb/issues/136)] + - Unexpected properties in top-level configuration or in `babel`, `karma`, `npm` and `webpack` configuration (i.e. anything that's not documented in the [Configuration docs](https://github.com/insin/nwb/blob/master/docs/Configuration.md)) are now treated as errors [[#193](https://github.com/insin/nwb/issues/193)] + - Basic type checking is now performed for all documented configuration properties. + - After upgrading, run `nwb check-config` to check your configuration file. +- Updated to [UglifyJSPlugin 1.x](https://github.com/webpack-contrib/uglifyjs-webpack-plugin#readme), which supports ES2015 syntax and adds options to enable filesystem caching and use multiple processes to improve build speed, which nwb enables by default [[#412](https://github.com/insin/nwb/issues/412)] + - Review any custom [`webpack.uglify` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#uglify-object--false) you have against the new version's [options documentation](https://github.com/webpack-contrib/uglifyjs-webpack-plugin#options) - options for UglifyJS itself must now be passed as an `uglifyOptions` object and some of UglifyJS' default options have changed. +- Node.js 4.8.0 is now the minimum required version, based on the `engines` config of nwb's dependencies. + +## `nwb.config.js` Config Changes + +- Deprecated the `webpack.compat.sinon` flag for Sinon 1.x compatibility settings, as subsequent major versions since July 2017 support Webpack out of the box. + +## Fixed + +- Fixed testing React component/library and web module projects when using [export extensions](http://babeljs.io/docs/plugins/transform-export-extensions/) - the Babel stage preset wasn't being defaulted to preset-stage-1, which includes the export extensions plugin [[#364](https://github.com/insin/nwb/issues/364)] + +## Added + +- Added an [`--open` flag](https://github.com/insin/nwb/blob/master/docs/Commands.md#options) to open the app in your default browser or in a named browser (e.g. `--open="Google Chrome"`) after starting a Webpack dev server [[#334](https://github.com/insin/nwb/issues/334)] +- You can now provide a [`babel.config()` function](https://github.com/insin/nwb/blob/master/docs/Configuration.md#config-function) which will be given the generated Babel config to do whatever it wants with. +- You can now provide a [`karma.config()` function](https://github.com/insin/nwb/blob/master/docs/Configuration.md#config-function-2) which will be given the generated Karma config to do whatever it wants with [[#408](https://github.com/insin/nwb/issues/408)] + +## Changed + +- Simplified configuration of locales in [`webpack.compat` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#compat-object) + +## Dependencies + +- autoprefixer: v7.1.6 → [v7.2.4](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#724) +- babel-plugin-inferno: v3.3.0 → [v3.3.1](https://github.com/infernojs/babel-plugin-inferno/releases) +- copy-webpack-plugin: v4.2.1 → [v4.3.1](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#431-2017-12-22) +- file-loader: v1.1.5 → [v1.1.6](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#116-2017-12-16) +- gzip-size: v4.0.0 → [v4.1.0](https://github.com/sindresorhus/gzip-size/compare/v4.0.0...v4.1.0) +- karma: v1.7.1 → [v2.0.0](https://github.com/karma-runner/karma/releases/tag/v2.0.0) +- karma-webpack: v2.0.6 → [v2.0.9](https://github.com/webpack-contrib/karma-webpack/blob/master/CHANGELOG.md#209-2017-12-14) +- mocha: v4.0.1 → [v4.1.0](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#410--2017-12-28) +- postcss-loader: v2.0.8 → [v2.0.9](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#209-2017-11-24) +- style-loader: v0.19.0 → [v0.19.1](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0191-2017-12-14) +- webpack: v3.8.1 → [v3.10.0](https://github.com/webpack/webpack/releases) +- webpack-dev-middleware: v1.12.0 → [v1.12.2](https://github.com/webpack/webpack-dev-middleware/releases) +- webpack-dev-server: v2.9.4 → [v2.9.7](https://github.com/webpack/webpack-dev-server/releases) +- webpack-hot-middleware: v2.20.0 → [v2.21.0](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.20.0...v2.21.0) + +## Docs + +- Added missing docs for [`webpack.copy` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#copy-array--object) +- Added more headings to the [Commands docs](https://github.com/insin/nwb/blob/master/docs/Commands.md#commands) to make them easier to browse, and to make feature flags such as `--copy-files` for component builds more visible [[#407](https://github.com/insin/nwb/issues/407)] + +# 0.20.0 / 2017-11-18 + +## Breaking Changes + +- Updated UMD build config to [export the `default` export of the entry point](https://webpack.js.org/configuration/output/#output-libraryexport), rather than an ES modules interop object which looks something like `{__esModule: true, default: Getter}`, which was unintended behaviour. This will break any existing usage of UMD builds which depended on manually accessing the unintended `default` property [[#402](https://github.com/insin/nwb/issues/402)] +- Updated to Mocha 4, which comes with [a number of breaking changes](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#boom-breaking-changes). These are mostly related to dropping support for older versions of Node.js and non-ES5-compliant browsers. + +## Fixed + +- Bump the default React peerDependency version for react-component projects to `16.x` - fixes creating components with npm 2. + +## Dependencies + +- copy-webpack-plugin: v4.2.0 → [v4.2.1](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#421-2017-11-17) +- detect-port: v1.2.1 → [v1.2.2](https://github.com/node-modules/detect-port/releases) +- karma-webpack: v2.0.5 → [v2.0.6](https://github.com/webpack-contrib/karma-webpack/blob/master/CHANGELOG.md#206-2017-11-10) +- mocha: v3.4.2 → [v4.0.1](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#401--2017-10-05) - dropped support for old versions of Node.js and non-ES5-compliant browsers + +## Documentation + +- Documented `--unsafe-perm` workaround for PhantomJS' postinstall step failing on some OSes when installing globally with npm 5 [[#383](https://github.com/insin/nwb/issues/383)] + +# 0.19.2 / 2017-11-09 + +## Fixed + +- Backed out use of `preact/debug` in favour of `preact/devtools`, as the debug module tries to override the preact module's render export, which fails due to Webpack enforcing the read-only nature of ES module exports. + +# 0.19.1 / 2017-11-04 + +## `nwb.config.js` Config Changes + +- Deprecated the `webpack.compat.enzyme` flag for Enzyme v2 compatibility settings. Upgrade to Enzyme v3 when you can, which supports React all the way back to v0.13. + - [An example of configuring Enzyme v3](https://github.com/insin/nwb/blob/master/docs/Testing.md#configuring-testing-libraries) has been added to the [testing docs](https://github.com/insin/nwb/blob/master/docs/Testing.md#testing). + +## Fixed + +- Added `'createClass'` and `'createReactClass'` to the factory function names [React Transform](https://github.com/gaearon/babel-plugin-react-transform) looks for, so React component hot reloading will work for apps using [`create-react-class`](https://www.npmjs.com/package/create-react-class) imported as one of those names. + +## Changed + +- nwb is now also tested against Node 8 now that it's the Long Term Support version. +- Reverted the Webpack settings change for `webpack.compat.enzyme` config in v0.19.0, as it only applied while the version numbers of published React packages were out of sync. The compatibility settings assume Enzyme v2 and React >= v15.5. +- `style-loader`'s new `hmr` option is set to `false` when creating builds to prevent inclusion of its HMR code. + +## Dependencies + +- autoprefixer: v7.1.4 → [v7.1.6](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#716) +- babel-plugin-inferno: v3.2.0 → [v3.3.0](https://github.com/infernojs/babel-plugin-inferno/releases) +- babel-plugin-transform-react-remove-prop-types: v0.4.8 → [v0.4.10](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/releases) +- babel-preset-env: v1.6.0 → v1.7.0 +- chalk: v2.1.0 → [v2.3.0](https://github.com/chalk/chalk/compare/v2.1.0...v2.3.0) +- copy-webpack-plugin: v4.1.0 → [v4.2.0](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#420-2017-10-19) +- extract-text-webpack-plugin: v3.0.0 → [v3.0.2](https://github.com/webpack-contrib/extract-text-webpack-plugin/blob/master/CHANGELOG.md#302-2017-10-25) +- file-loader: v1.1.4 → [v1.1.5](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#115-2017-10-05) +- filesize: v3.5.10 → [v3.5.11](https://github.com/avoidwork/filesize.js/compare/3.5.10...3.5.11) +- karma-mocha-reporter: v2.2.4 → [v2.2.5](https://github.com/litixsoft/karma-mocha-reporter/blob/master/CHANGELOG.md#225-2017-10-17) +- karma-webpack: v2.0.4 → [v2.0.5](https://github.com/webpack-contrib/karma-webpack/blob/master/CHANGELOG.md#205-2017-10-08) +- phantomjs-prebuilt: v2.1.15 → v2.1.16 +- postcss-loader: v2.0.6 → [v2.0.8](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#208-2017-10-14) +- resolve: v1.4.0 → [v1.5.0](https://github.com/browserify/resolve/compare/v1.4.0...v1.5.0) +- style-loader: v0.18.2 → [v0.19.0](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0190-2017-10-03) +- url-loader: v0.5.9 → [v0.6.2](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md#062-2017-10-04) +- webpack: v3.6.0 → [v3.8.1](https://github.com/webpack/webpack/releases) +- webpack-dev-server: v2.9.1 → [v2.9.4](https://github.com/webpack/webpack-dev-server/releases) +- webpack-hot-middleware: v2.19.1 → [v2.20.0](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.19.1...v2.20.0) +- webpack-merge: v4.1.0 → [v4.1.1](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#411--2017-11-01) + +# 0.19.0 / 2017-10-02 + +## Breaking Changes + +- Removed hooking of React, Preact and Inferno `render()` functions in quick commands, as this won't work with ES modules builds (which are used by default in Webpack v3). This affected the current version of Preact at the time of writing. + - If you're manually using `render()` with quick commands, you must now handle providing the target DOM node too - `document.getElementById('app')` is available in the default HTML template. + +## Added + +- Added [`babel.env` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#env-object) to pass additional [options for `babel-preset-env`](https://github.com/babel/babel-preset-env#options). +- Added additional Enzyme [`webpack.compat`](https://github.com/insin/nwb/blob/master/docs/Configuration.md#compat-object) for recent versions of React 15. + +## Changed + +- Now using `babel-preset-env` instead of deprecated `babel-preset-es201X` presets [[#375](https://github.com/insin/nwb/issues/375)] +- Use `beautify: true` for `webpack.debug` output so code split bundles are readable. + +## Dependencies + +- autoprefixer: v7.1.2 → [v7.1.4](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#714) +- babel-cli: v6.24.1 → [v6.26.0][babel6260] +- babel-core: v6.24.1 → [v6.26.0][babel6260] +- babel-loader: v7.1.1 → [v7.1.2](https://github.com/babel/babel-loader/releases/tag/v7.1.2) +- babel-plugin-istanbul: v4.1.4 → v4.1.5 +- babel-plugin-react-transform: v2.0.2 → [v3.0.0](https://github.com/gaearon/babel-plugin-react-transform/releases) - add `React.PureComponent` to the list of default super classes +- babel-plugin-transform-react-remove-prop-types: v0.4.6 → [v0.4.8](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/releases) +- babel-polyfill: v6.23.0 → [v6.26.0][babel6260] +- babel-runtime: v6.25.0 → [v6.26.0][babel6260] +- chalk: v2.0.1 → [v2.1.0](https://github.com/chalk/chalk/compare/v2.0.1...v2.1.0) +- copy-webpack-plugin: v4.0.1 → [v4.1.0](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#410-2017-09-29) +- css-loader: v0.28.4 → [v0.28.7](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#0287-2017-08-30) +- file-loader: v0.11.2 → [v1.1.4](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#114-2017-09-30) +- gzip-size: v3.0.0 → v4.0.0 - async interface now uses Promises +- html-webpack-plugin: v2.29.0 → [v2.30.1](https://github.com/jantimon/html-webpack-plugin/blob/master/CHANGELOG.md#v2301) +- inquirer: v3.2.1 → [v3.3.0](https://github.com/SBoudrias/Inquirer.js/releases) +- karma-mocha-reporter: v2.2.3 → [v2.2.4](https://github.com/litixsoft/karma-mocha-reporter/blob/master/CHANGELOG.md#224-2017-08-24) +- karma: v1.7.0 → [v1.7.1](https://github.com/karma-runner/karma/releases/tag/1.7.1) +- mocha: v3.4.2 → [v3.5.3](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#353--2017-09-11) +- phantomjs-prebuilt: v2.1.14 → v2.1.15 - fix security issues with dependencies +- webpack-dev-middleware: v1.11.0 → [v1.12.0](https://github.com/webpack/webpack-dev-middleware/releases/tag/v1.12.0) +- webpack-dev-server: v2.6.1 → [v2.9.1](https://github.com/webpack/webpack-dev-server/releases) +- webpack-hot-middleware: v2.18.2 → [v2.19.0](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.18.2...v2.19.0) +- webpack: v3.4.1 → [v3.6.0](https://github.com/webpack/webpack/releases) + +[babel6260]: https://github.com/babel/babel/blob/master/CHANGELOG.md#6260-2017-08-16 + +# 0.18.10 / 2017-07-27 + +## Fixed + +- Fix dev server HMR for people running on different hosts or a different localhost port [[#356](https://github.com/insin/nwb/issues/356)] [[DethAriel][DethAriel]] + +## Dependencies + +- babel-runtime: v6.23.0 → v6.25.0 +- resolve: v1.3.3 → [v1.4.0](https://github.com/browserify/resolve/compare/v1.3.3...v1.4.0) +- webpack: v3.4.0 → [v3.4.1](https://github.com/webpack/webpack/releases/tag/v3.4.1) + +# 0.18.9 / 2017-07-26 + +## Changed + +- Now using preact/debug instead of preact/devtools in quick Preact commands and the Preact project skeleton - requires Preact >= 8.2.0 + +## Dependencies + +- inquirer: v3.2.0 → [v3.2.1](https://github.com/SBoudrias/Inquirer.js/releases/tag/v3.2.1) +- promise: v8.0.0 → v8.0.1 +- webpack: v3.2.0 → [v3.4.0](https://github.com/webpack/webpack/releases) - bug fixes; now watches for missing directories being added; perf improvements +- webpack-dev-server: v2.5.1 → [v2.6.1](https://github.com/webpack/webpack-dev-server/releases) + +# 0.18.8 / 2017-07-16 + +## Dependencies + +- promise: v8.0.0 → v8.0.1 +- webpack: v3.2.0 → [v3.3.0](https://github.com/webpack/webpack/releases/tag/v3.3.0) - bug fixes; now watches for missing directories being added + +# 0.18.7 / 2017-07-12 + +## Changed + +- You can now set [`webpack.extractText` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#extracttext-object--boolean) to `false` to disable extraction of stylesheets in builds [[#343](https://github.com/insin/nwb/issues/343)] + +## Dependencies + +- extract-text-webpack-plugin: v3.0.0-rc.2 → v3.0.0 +- webpack: v3.1.0 → [v3.2.0](https://github.com/webpack/webpack/releases/tag/v3.2.0) - bug fixes + +## Documentation + +- Documented default [`webpack.extractText` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#extracttext-object--boolean). + +# 0.18.6 / 2017-07-10 + +## Dependencies + +- extract-text-webpack-plugin: v3.0.0-rc.1 → v3.0.0-rc.2 - fix module sorting type error +- inquirer: v3.1.1 → [v3.2.0](https://github.com/SBoudrias/Inquirer.js/releases/tag/v3.2.0) + +# 0.18.5 / 2017-07-09 + +## Dependencies + +- extract-text-webpack-plugin: v3.0.0-beta.3 → v3.0.0-rc.1 +- karma-webpack: v2.0.3 → [v2.0.4](https://github.com/webpack-contrib/karma-webpack/blob/master/CHANGELOG.md#204-2017-07-07) - Webpack 3 support +- webpack-dev-server: v2.5.0 → [v2.5.1](https://github.com/webpack/webpack-dev-server/releases/tag/v2.5.1) - Webpack 3 support + +# 0.18.4 / 2017-07-07 + +## Fixed + +- Fixed use of `@import` in CSS by adding `ident` back to `postcss-loader` config [[#311](https://github.com/insin/nwb/issues/311)] +- Fixed config validation error being thrown when using `webpack.styles` config for custom preprocessor plugin rules [[#342](https://github.com/insin/nwb/issues/342)] +- Fixed display of valid properties when an invalid property is used when configuring a custom `webpack.styles` rule. + +## Added + +- Added [`webpack.debug` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#debug-boolean) to trigger creation of a more debuggable production build [[#336](https://github.com/insin/nwb/issues/336)] + + The recommended way to use this is via a [config argument](https://github.com/insin/nwb/blob/master/docs/Configuration.md#configuration-via-arguments): + + ```sh + npm run build -- --webpack.debug + ``` + +- Added support for the following arguments when building a React component's demo: + - `--title` - set the generated demo `index.html`'s `<title>` + - `--vendor` - enable creation of a vendor bundle for modules imported from `node_modules/` [[#335](https://github.com/insin/nwb/issues/335)] + +## Dependencies + +- autoprefixer: v7.1.1 → [v7.1.2](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#711) +- babel-loader: v7.1.0 → [v7.1.1](https://github.com/babel/babel-loader/releases/tag/v7.1.1) - don't read `.babelrc` for cache identifier when `babelrc=false` (nwb uses this option) +- chalk: v1.1.3 → [v2.0.1](https://github.com/chalk/chalk/compare/v1.1.3...v2.0.1) +- extract-text-webpack-plugin: v2.1.2 → [v3.0.0-beta.3](https://github.com/webpack-contrib/extract-text-webpack-plugin/releases) - Webpack 3 support +- html-webpack-plugin: v2.28.0 → [v2.29.0](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2290) - Webpack 3 support +- karma-chrome-launcher: v2.1.1 → [v2.2.0](https://github.com/karma-runner/karma-chrome-launcher/blob/master/CHANGELOG.md#220-2017-06-23) +- webpack: v3.0.0 → [v3.1.0](https://github.com/webpack/webpack/releases/tag/v3.1.0) - perf boost; fix ordering in `ExtractTextPlugin` +- webpack-hot-middleware: v2.18.0 → [v2.18.2](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.18.0...v2.18.2) + +# 0.18.3 / 2017-06-22 + +## Fixed + +- Quick `build` command config was being created before the default `NODE_ENV = production` was applied, so output filenames didn't include a chunkhash by default. + +## Dependencies + +- webpack-dev-middleware: v1.10.2 → [v1.11.0](https://github.com/webpack/webpack-dev-middleware/releases/tag/v1.11.0) - Webpack 3 support + +# 0.18.2 / 2017-06-22 + +## Fixed + +- Fixed clearing the console by default when running the development server. + +## Dependencies + +- babel-loader: v7.0.0 → [v7.1.0](https://github.com/babel/babel-loader/releases/tag/v7.1.0) - Webpack 3 support + +## Documentation + +- Updated [Quick Development with nwb](https://github.com/insin/nwb/blob/master/docs/guides/QuickDevelopment.md#quick-development-with-nwb) for v0.18. + +# 0.18.1 / 2017-06-20 + +## Dependencies + +- npm-install-webpack2-plugin: v5.0.0 → v5.0.1 - fix Webpack 3 support + +# 0.18.0 / 2017-06-20 + +## Breaking Changes + +- Updated to Webpack 3 - potentially breaking for some plugins [[#326](https://github.com/insin/nwb/issues/326)] + + See the [official release post](https://medium.com/webpack/webpack-3-official-release-15fd2dd8f07b) for changes. + +- Removed support for configuration which was [deprecated in nwb v0.15.0](#0150--2017-01-25). + +## Fixed + +- Fixed display of user config errors when running the dev server. + +## Added + +- Added [`webpack.hoisting` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#hoisting-boolean) to enable use of Webpack 3's new `ModuleConcatenationPlugin` for scope hoisting in production builds [[#326](https://github.com/insin/nwb/issues/326)] +- [`babel`, `webpack`, `devServer`, `karma` and `npm` configuration](https://github.com/insin/nwb/blob/master/docs/Configuration.md#configuration-object) can now be provided via [arguments using dotted paths](https://github.com/insin/nwb/blob/master/docs/Configuration.md#configuration-via-arguments) [[#327](https://github.com/insin/nwb/issues/327)] + + ```sh + nwb react build app.js \ + --babel.plugins=react-html-attrs \ + --babel.stage=2 \ + --webpack.hoisting + ``` + + If you have a config file, arguments will override properties in it. This is primarily intended for one-off feature toggles without having to edit your config file, and to provide some level of configuration for [quick development commands](https://github.com/insin/nwb/blob/master/docs/guides/QuickDevelopment.md#quick-development-with-nwb) without needing a config file. + +## Changed + +- [`babel.plugins`](https://github.com/insin/nwb/blob/master/docs/Configuration.md#plugins-string--array), [`babel.presets`](https://github.com/insin/nwb/blob/master/docs/Configuration.md#presets-string--array) and locales in [`webpack.compat`](https://github.com/insin/nwb/blob/master/docs/Configuration.md#compat-object) config now also accept single configuration as a String to make them usable via arguments [[#327](https://github.com/insin/nwb/issues/327)] + +## Dependencies + +- inquirer: v3.1.0 → [v3.1.1](https://github.com/SBoudrias/Inquirer.js/releases/tag/v3.1.1) +- npm-install-webpack2-plugin: v4.1.1 → v5.0.0 - drop Webpack 1 and add Webpack 3 to peerDeps +- promise: v7.3.0 → v8.0.0 +- webpack: v2.6.1 → [v3.0.0](https://github.com/webpack/webpack/releases/tag/v3.0.0) +- webpack-dev-server: v2.4.5 → [v2.5.0](https://github.com/webpack/webpack-dev-server/releases/tag/v2.5.0) + +# 0.17.3 / 2017-07-07 + +## Fixed + +Backported fixes from 0.18: + +- Fixed use of `@import` in CSS by adding `ident` back to `postcss-loader` config [[#311](https://github.com/insin/nwb/issues/311)] +- Fixed display of valid properties when an invalid property is used when configuring a custom `webpack.styles` rule. + +# 0.17.2 / 2017-07-04 + +## Fixed + +Backported fixes from 0.18: + +- Fixed display of user config errors when running the development server. +- Fixed clearing the console by default when running the development server. +- Quick build command config was being created before the default `NODE_ENV = production` was applied, so output filenames didn't include a chunkhash by default. +- Fixed config validation error when running the development server and using `webpack.styles` config for custom preprocessor plugin rules. + +# 0.17.1 / 2017-06-19 + +## Fixed + +- Fixed using a custom port for the dev server - Webpack Dev Server's client didn't like the format we were specifying the URL for the Hot Module Reloading connection in [[#328](https://github.com/insin/nwb/issues/328)] +- Use the correct protocol in the `'The app is running at...'` successful compilation message when using HTTPS. + +# 0.17.0 / 2017-06-17 + +## Breaking Changes + +- Now using [Webpack Dev Server](https://github.com/webpack/webpack-dev-server) (instead of running a basic Express development server). + + Webpack Dev Server has [security features](https://github.com/insin/inputmask-core) which you may need to configure your way around if you're using `--host` or if your development setup involves hitting the dev server from a different host. + + Please [create an issue](https://github.com/insin/nwb/issues/new) if you're affected by this change and there's something nwb can do to mitigate dev server problems without compromising security. + +**React components/libraries** + +- A [`--[keep-]proptypes` flag](https://github.com/insin/nwb/blob/master/docs/guides/ReactComponents.md#--keep-proptypes) replaces `--no[-wrap]-proptypes` to disable wrapping of `propTypes` in React component project builds so they'll be stripped from a production build. + +## Fixed + +- The process will now exit with a non-zero code when a Webpack build completes with errors [[#290](https://github.com/insin/nwb/issues/290)] +- Fixed transpiling of ES2017 features when use of a stage-X preset is disabled with [`babel.stage = false` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#stage-number--false). +- Fixed `hmre = false` [Express middleware option](https://github.com/insin/nwb/blob/master/docs/Middleware.md#options) for disabling use of [React Transform](https://github.com/gaearon/babel-plugin-react-transform#readme) to attempt to handle Hot Module Reloading for React components and `render()` error display [[#263](https://github.com/insin/nwb/issues/263)] + +**Preact** + +- Fixed importing React components when serving a Preact app - this was missed when fixing `preact-compat` configuration issues from v0.16.0. + +## Added + +**Arguments** + +- Added a [`--no-clear[-console]` flag](https://github.com/insin/nwb/blob/master/docs/Commands.md#nwb-serve) to disable clearing of the console when running the dev server. +- Added a [`--no-html` flag](https://github.com/insin/nwb/blob/master/docs/Commands.md#nwb-build) to disable creation of an `index.html` file if you don't need one (e.g. you're serving your built apps via another means) [[#278](https://github.com/insin/nwb/issues/278)] [[bwendt-mylo][bwendt-mylo]] + +**Commands** + +- Added an `nwb web (run|build)` command for [quick development](https://github.com/insin/nwb/blob/master/docs/guides/QuickDevelopment.md#quick-development-with-nwb) with vanilla JavaScript (i.e. you're in charge of rendering). + +**Configuration** + +- Added [`devServer` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#devserver-object) to configure [Webpack Dev Server options](https://webpack.js.org/configuration/dev-server/#devserver), which include: + - `devServer.historyApiFallback.disableDotRule` can be enabled if you need to use dots in your path when using the HTML5 History API + - `devServer.https` can be used to enable HTTPS + - `devServer.proxy` can be used to proxy certain URLs to a separate API backend development server +- Added a [`type` option](https://github.com/insin/nwb/blob/master/docs/Middleware.md#options) to nwb's Express middleware to set the project type (one of `react`, `preact`, `inferno` or `web`) manually, enabling use of the middleware without a config file. + +**React** + +- Added [`babel.removePropTypes` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#removeproptypes-object--false) to disable or configure [removal of `propTypes`](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types) in React app production builds. +- Added [`babel.reactConstantElements` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#reactconstantelements-false) to disable the use of the [React constant element hoisting transform](https://babeljs.io/docs/plugins/transform-react-constant-elements/) in React app production builds. + +## Changed + +**npm modules** + +- Default Babel config for `react-component` and `web-module` projects now uses [`babel-preset-stage-1`](http://babeljs.io/docs/plugins/preset-stage-1/), so you can use [export extensions](http://babeljs.io/docs/plugins/transform-export-extensions/) by default if you need to re-export a library's modules in `src/index.js` [[#284](https://github.com/insin/nwb/issues/284)] +- Default Travis CI config for `react-component` and `web-module` projects now only uses Node 6 by default for quicker builds. + +**Preact** + +- [`preact/devtools`](https://github.com/developit/preact#developer-tools) is now imported in development mode to enable use of React Developer Tools when using `nwb preact run`. This has also been added to the `preact-app` template. + + For existing Preact apps, add the following to its entry point to enable this: + + ``` + if (process.env.NODE_ENV === 'development') { + require('preact/devtools') + } + ``` + +**React components/libraries** + +- [`prop-types`](https://github.com/facebook/prop-types#prop-types) imports are now also removed from React component UMD production builds. + +## Documentation + +- Document the [`--copy-files` flag](https://github.com/insin/nwb/blob/master/docs/guides/ReactComponents.md#--copy-files) properly [[#317](https://github.com/insin/nwb/issues/317)] + +## Dependencies + +- babel-core: v6.24.1 → [v6.25.0](https://github.com/babel/babel/releases/tag/v6.25.0) +- babel-plugin-transform-react-remove-prop-types: v0.4.5 → [v0.4.6](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/releases/tag/v0.4.6) - fix use in Node 4 +- babel-preset-es2017: v6.24.1 +- detect-port: v1.1.3 → [v1.2.1](https://github.com/node-modules/detect-port/releases) +- extract-text-webpack-plugin: v2.1.0 → [v2.1.2](https://github.com/webpack-contrib/extract-text-webpack-plugin/blob/master/CHANGELOG.md#212-2017-06-08) +- file-loader: v0.11.1 → [v0.11.2](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#0112-2017-06-05) - `publicPath` option changes +- inquirer: v3.0.6 → [v3.1.0](https://github.com/SBoudrias/Inquirer.js/releases/tag/v3.1.0) +- ora: v1.2.0 → v1.3.0 +- postcss-loader: v2.0.5 → [v2.0.6](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#206-2017-06-14) +- promise: v7.1.1 → v7.3.0 +- style-loader: v0.18.1 → [v0.18.2](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0182-2017-06-05) +- url-loader: v0.5.8 → [v0.5.9](https://github.com/webpack-contrib/url-loader/releases/tag/v0.5.9) +- [webpack-dev-server](https://github.com/webpack/webpack-dev-server/): v2.4.5 + +# 0.16.3 / 2017-05-31 + +**Dependencies:** + +- case-sensitive-paths-webpack-plugin: v2.0.0 → [v2.1.1](https://github.com/Urthen/case-sensitive-paths-webpack-plugin/blob/master/CHANGELOG.md#211) - don't intercept Webpack "File not found" error, resolve issue with not recognising when a new file is added + +# 0.16.2 / 2017-05-31 + +**Fixed:** + +- Fixed validation of `webpack.styles` config to allow it to be set to `false` [[#312](https://github.com/insin/nwb/pull/312)] [[seanofw][seanofw]] + +**Dependencies:** + +- css-loader: v0.28.3 → [v0.28.4](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#0284-2017-05-30) - preserve leading underscore in class names + +# 0.16.1 / 2017-05-31 + +**Fixed:** + +- Fixed bad render shim paths which were breaking the `nwb react`, `nwb preact` and `nwb inferno` quick development commands. +- Fixed `nwb preact` commands and `nwb react`'s `--preact[-compat]` when used with Preact 8 by removing a workaround for an old preact-compat distribution issue. + +**Added:** + +- Added support for [create-react-class](https://facebook.github.io/react/docs/react-without-es6.html) when using `preact-compat`. + +**Dependencies:** + +- css-loader: v0.28.3 → [v0.28.4](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#0284-2017-05-30) - preserve leading underscore in class names + +# 0.16.0 / 2017-05-29 + +**Breaking Changes:** + +- Global `react`, `preact`, and `inferno` commands are no longer installed when nwb is installed globally [[#308](https://github.com/insin/nwb/issues/308)] + + These are now subcommands of the global `nwb` command, to avoid conflicting with global commands installed by official tools for these libraries, e.g. [`preact-cli`](https://github.com/developit/preact-cli) is now available, which provides a global `preact` command. +- Node.js 4.6.0 is now the minimum required version, based on the `engines` config of nwb's dependencies, +- A separate Webpack rule for stylesheets imported from `node_modules/` is no longer created by default. + + > For backwards compatibility you can set [`webpack.style` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#styles-object--false--old) to `'old'` to use the old default behaviour - this capability will be removed in a future release. +- The Babel plugin for Inferno now requires Inferno >= 1.5 and is not backwards-compatible with 1.4. +- Default Webpack config now sets `module.strictExportPresence = true` so a missing export is now a compile error. +- Default `ExtractTextPlugin` now sets `allChunks = true` to extract stylesheets from all chunks and avoid including the `style-loader` runtime in builds by default. + +**Added:** + +- You can now control [how Webpack rules are created for stylesheets](https://github.com/insin/nwb/blob/master/docs/Stylesheets.md#stylesheets) via [`webpack.styles` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#styles-object--false--old). + + This allows you to set up multiple rules for your own stylesheets (e.g. using CSS Modules only for stylesheets in a particular directory) and to provide rules for dependencies which need a specific Webpack rule for their stylesheets. + + You can also disable creation of stylesheet rules by setting `webpack.styles` to `false`. +- Re-enabled the `react-constant-elements` transform for React production builds, due to significant bug fixes. +- Added a `--no-hmre` flag for use when serving a React app, to disable use of [React Transform](https://github.com/gaearon/babel-plugin-react-transform#readme) to attempt to automatically handle Hot Module Replacement for React components and display an overlay with `render()` errors [[#263](https://github.com/insin/nwb/issues/263)] +- Added support for [intl](https://github.com/andyearnshaw/Intl.js/) and [react-intl](https://github.com/yahoo/react-intl) in [`webpack.compat` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#compat-object) [[#260](https://github.com/insin/nwb/pull/260)] [[grahamlyus][grahamlyus]] +- You can now provide a [`webpack.config()` function](https://github.com/insin/nwb/blob/master/docs/Configuration.md#config-function) which will be given the generated Webpack config to do whatever it wants with [[#256](https://github.com/insin/nwb/issues/256)] +- You can now provide [`use` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#customising-loaders) with a list of loaders in `webpack.rules` to replace a rule's default loader with chained loaders [[#256](https://github.com/insin/nwb/issues/256)] +- You can now [disable a default Webpack config rule](https://github.com/insin/nwb/blob/master/docs/Configuration.md#disabling-default-rules) by setting it to `false` [[#256](https://github.com/insin/nwb/issues/256)] + +**Changed:** + +- Default options are no longer used if you provide a custom `loader` for a rule in `webpack.rules` [[#256](https://github.com/insin/nwb/issues/256)] +- React project templates now use classes and `React.Component` instead of `React.createClass()`, which is deprecated as of React v15.5 [[#216](https://github.com/insin/nwb/issues/216)] + +**Fixed:** + +- Fixed chunk hash not changing when imports in a split chunk are changed, by dropping use of the `webpack-md5-hash` plugin [[#301](https://github.com/insin/nwb/issues/301)] [[grahamlyus][grahamlyus]] +- Added missing config for `CopyWebpackPlugin` when serving a `react-component` project's demo app, so any static content in `demo/public/` will be also served by the dev server [[#307](https://github.com/insin/nwb/issues/307)] +- Removed `node_modules/` caching from default Travis CI config in project skeletons, as it's been reported to cause build failures [[#271](https://github.com/insin/nwb/issues/271)] +- An output directory specified with a trailing slash is now cleaned properly when creating a build. +- A `loader` configured for a Webpack rule is no longer moved into the `options` object when an options object hasn't been explicitly configured [[#256](https://github.com/insin/nwb/issues/256)] +- Fixed cleaning nested dirs, including a demo app's `demo/dist/` dir. +- Fixed cleaning output directories specified with a trailing slash. + +**Dependencies:** + +- autoprefixer: v6.7.0 → [v7.1.1](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#711) +- babel-cli: v6.22.2 → [v6.24.1][babel6241] +- babel-core: v6.22.1 → [v6.24.1][babel6241] +- babel-loader: v6.2.10 → [v7.0.0](https://github.com/babel/babel-loader/releases/tag/v7.0.0) +- babel-plugin-inferno: v1.7.0 → [v3.2.0](https://github.com/infernojs/babel-plugin-inferno/releases) - adds support for Inferno 1.5, not backwards-compatible with 1.4 +- babel-plugin-istanbul: v3.1.2 → [v4.1.4](https://github.com/istanbuljs/babel-plugin-istanbul/blob/master/CHANGELOG.md#414-2017-05-27) - drop support for Node.js 0.10 and v0.12 +- babel-plugin-transform-react-jsx: v6.22.0 → [v6.24.1][babel6241] +- babel-plugin-transform-react-remove-prop-types: v0.2.11 → [v0.4.5](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/releases) - dropped support for `React.createClass()` in favour of the new `create-react-class` package +- babel-plugin-transform-runtime: v6.22.0 → [v6.23.0][babel6230] +- babel-polyfill: v6.22.0 → [v6.23.0][babel6230] +- babel-preset-es2015: v6.22.0 → [v6.24.1][babel6241] +- babel-preset-es2016: v6.22.0 → [v6.24.1][babel6241] +- babel-preset-react: v6.22.0 → [v6.24.1][babel6241] +- babel-preset-stage-0: v6.22.0 → [v6.24.1][babel6241] +- babel-preset-stage-1: v6.22.0 → [v6.24.1][babel6241] +- babel-preset-stage-2: v6.22.0 → [v6.24.1][babel6241] +- babel-preset-stage-3: v6.22.0 → [v6.24.1][babel6241] +- babel-runtime: v6.22.0 → [v6.23.0][babel6230] +- case-sensitive-paths-webpack-plugin: v1.1.4 → [v2.0.0](https://github.com/Urthen/case-sensitive-paths-webpack-plugin/blob/master/CHANGELOG.md#2017-3-31) - use the file system exposed by the compiler +- css-loader: v0.26.1 → [v0.28.3](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#0283-2017-05-25) - added an [`alias` option](https://github.com/webpack-contrib/css-loader#alias) +- detect-port: v1.1.0 → [v1.1.3](https://github.com/node-modules/detect-port/blob/master/HISTORY.md#113--2017-05-24) +- express: v4.14.0 → [v4.15.3](https://github.com/expressjs/express/blob/master/History.md#4153--2017-05-16) +- file-loader: v0.9.0 → [v0.11.1](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#0111-2017-04-01) - added `useRelativePath` option +- filesize: v3.4.3 → [v3.5.10](https://github.com/avoidwork/filesize.js/compare/3.4.3...3.5.10) +- inquirer: v3.0.1 → [v3.0.6](https://github.com/SBoudrias/Inquirer.js/releases/) +- karma: v1.4.0 → [v1.7.0](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md#170-2017-05-06) +- karma-chrome-launcher: v2.0.0 → [v2.1.1](https://github.com/karma-runner/karma-chrome-launcher/blob/master/CHANGELOG.md#211-2017-05-05) - add support for headless Chrome/ChromeCanary +- karma-mocha-reporter: v2.2.2 → [v2.2.3](https://github.com/litixsoft/karma-mocha-reporter/blob/master/CHANGELOG.md#223-2017-03-20) +- karma-phantomjs-launcher: v1.0.2 → [v1.0.4](https://github.com/karma-runner/karma-phantomjs-launcher/blob/master/CHANGELOG.md#104-2017-03-10) - fixed more path issues +- karma-webpack: v2.0.1 → [v2.0.3](https://github.com/webpack-contrib/karma-webpack/blob/master/CHANGELOG.md#203-2017-03-15) - don't swallow configuration errors +- mocha: v3.2.0 → [v3.4.2](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#342--2017-05-24) +- ora: v1.1.0 → v1.2.0 - added `warn()` and `info()` utilities +- postcss-loader: v1.2.2 → [v2.0.5](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#205-2017-05-10) - validate options +- resolve: v1.2.0 → [v1.3.3](https://github.com/browserify/resolve/compare/v1.2.0...v1.3.3) +- style-loader: v0.13.1 → [v0.18.1](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md#0181-2017-05-23) +- url-loader: v0.5.7 → [v0.5.8](https://github.com/webpack-contrib/url-loader/releases/tag/v0.5.8) - fix loader util deprecation warning +- webpack: v2.2.1 → [v2.6.1](https://github.com/webpack/webpack/releases) - `import()` can now configure a chunk name, `require.ensure()` can now take an error callback, added `module.strictExportPresence` +- webpack-dev-middleware: v1.9.0 → [v1.10.2](https://github.com/webpack/webpack-dev-middleware/releases) - CORS security fix +- webpack-hot-middleware: v2.15.0 → [v2.18.0](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.15.0...v2.18.0) - client overlay style can now be customised with CSS using `#webpack-hot-middleware-clientOverlay` +- webpack-merge: v2.4.0 → [v4.1.0](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#410--2017-03-16) +- whatwg-fetch: v2.0.2 → [v2.0.3](https://github.com/github/fetch/releases/tag/v2.0.3) + +[babel6230]: https://github.com/babel/babel/blob/master/CHANGELOG.md#6230-2017-02-13 +[babel6241]: https://github.com/babel/babel/blob/master/CHANGELOG.md#6240-2017-03-13 + +**Internal:** + +- Use `fs` and `fs-extra` instead of `glob` and `rimraf`, which are now only `devDependencies`. + +# 0.15.8 / 2017-05-11 + +**Dependencies:** + +- extract-text-webpack-plugin: [v2.1.0](https://github.com/webpack-contrib/extract-text-webpack-plugin/blob/master/CHANGELOG.md#210-2017-03-05) - fix bad scoped version in nwb v0.15.7 +- html-webpack-plugin: v2.26.0 → [v2.28.0](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2280) - revert relative loader resolving change from v2.25.0 back to a full path +- webpack: v2.2.0 → [v2.2.1](https://github.com/webpack/webpack/releases/tag/v2.2.1) - `ident` is now automatic, fixes issue passing options to postcss-loader + +# 0.15.7 / 2017-05-11 + +**Added:** + +- Added [`npm.cjs` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#cjs-boolean) to disable creation of a CommonJS build in `lib/` if you don't need it [[#285](https://github.com/insin/nwb/issues/285)] [[treshugart][treshugart]] + +**Changed:** + +- Disable creation of a minified UMD build when [`webpack.uglify` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#uglify-object--false) is `false` [[#288](https://github.com/insin/nwb/issues/288)] [[treshugart][treshugart]] +- Support use of Karma `customLaunchers` which start with "Chrome" [[#296](https://github.com/insin/nwb/pull/296)] [[michaelsbradleyjr][michaelsbradleyjr]] + +**Fixed:** + +- Fixed typo in `clean` command in `react-component` skeleton [[#283](https://github.com/insin/nwb/pull/283)] [[totaldis][totaldis]] + +**Documentation:** + +- [Document use of Karma's `usePolling` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#karma-configuration) to reduce CPU usage on macOS [[#297](https://github.com/insin/nwb/issues/297)] [[michaelsbradleyjr][michaelsbradleyjr]] + +# 0.15.6 / 2017-02-11 + +**Changed:** + +- Explicitly call `process.exit(0)` from the `nwb` command when there are no errors running a command [[#262](https://github.com/insin/nwb/pull/262)] + +# 0.15.5 / 2017-02-06 + +**Fixed:** + +- Fixed blank version being set for the React `peerDependency` in new `react-component` projects. +- Use the transpiled ES5 version of `preact-compat` for compatibility builds using `react build` with the `--preact` flag, to prevent UglifyJS errors [[#244](https://github.com/insin/nwb/issues/244)] + +# 0.15.4 / 2017-01-26 + +**Changed:** + +- Support the Array version of deprecated `webpack.postcss` config. +- Tell the user they're including redundant config if they've manually configured `inferno-compat` or `preact-compat` aliases for React modules [[#247](https://github.com/insin/nwb/issues/247)] + +# 0.15.3 / 2017-01-25 + +**Fixed:** + +- Added a missing `.default` to the Preact project skeleton where CommonJS `require()` was being used to import an ES module [[#245](https://github.com/insin/nwb/issues/245)] + + `.default` must now be used to access the default export from an ES module when importing with CommonJS `require()` as Webpack 2 prevents module format mixing, which was previously used to provide CommonJS interop. + +# 0.15.2 / 2017-01-25 + +**Fixed:** + +- Use the transpiled ES5 version of `preact-compat`, as UglifyJS can't handle the ES `module` build [[#244](https://github.com/insin/nwb/issues/244)] + +# 0.15.1 / 2017-01-25 + +**Removed:** + +- Remove hints about possibly not needing `babel.cherryPick` due to Webpack 2 tree shaking, as this doesn't currently appear to be true. + +# 0.15.0 / 2017-01-25 + +**Breaking Changes:** + +- **Upgraded from Webpack 1 to Webpack 2** [[#110](https://github.com/insin/nwb/issues/110)] + + **Minimum Node.js version increased from 4.2 to 4.3** - this is Webpack 2's minimum supported Node.js version. + + **Strict Webpack configuration** - Webpack 2 is strict about what appears in its configuration object. If you're using [`webpack.extra` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#extra-object), it **must** conform to [Webpack 2's configuration format](https://webpack.js.org/configuration/) or your build will fail with a validation error. + + **Dropped CommonJS compatibility when importing ES modules** - Webpack 2 no longer allows you to mix CommonJS modules with ECMAScript modules - if a module uses `import` or `export` syntax, `exports` will be `undefined` and `module.exports` will be read-only and `undefined`. + + As a result, we can no longer provide CommonJS interop by default for ES Modules - you will need to check your code for usage of CommonJS `require()` to import ES modules and tack a `.default` on the end if you need to use the module's `export default`. + + > If you used nwb's Preact project skeleton, the `init()` function in `index.js` needs to have a `.default` tacked on when the `App` component is being imported. + + **Custom top-level properties no longer allowed in Webpack configuration** - Webpack 2 no longer allows custom top-level properties in its configuration. Loader configuration which can't be serialised, such as plugin objects, can now be provided directly as loader options instead using [`webpack.rules` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#rules-object) instead. + + This includes `postcss-loader`, which is now configured via `webpack.rules` instead of having its own special `webpack.postcss` config. + +**`nwb.config.js` Config Format Changes:** + +> For deprecations, nwb will continue to support the old format for the next couple of releases, displaying warning messages about the changes required and adapting deprecated config for use in the current version where possible. +> +> If you have an `nwb.config.js` file, run [`nwb check-config`](https://github.com/insin/nwb/blob/master/docs/Commands.md#check-config-command) after updating nwb to find out if there's anything you need to change. + +- Deprecated `karma.testDirs`, renaming this config to `karma.excludeFromCoverage`, as it can be configured to exclude any paths from code coverage, not just directories [[#236](https://github.com/insin/nwb/issues/236)] + + ```js + // < v0.15 // v0.15 + module.exports = { module.exports = { + karma: { karma: { + testDirs: [ => excludeFromCoverage: [ + 'test/', 'test/', + 'path/to/ignorethis.js' 'path/to/ignorethis.js' + ] ] + } } + } } + ``` + +- Deprecated `webpack.loaders`, renaming this config to `webpack.rules` to match Webpack 2's new config format: + + ```js + // < v0.15 // v0.15 + module.exports = { module.exports = { + webpack: { webpack: { + loaders: { => rules: { + /* ... */ /* ... */ + } } + } } + } } + ``` + +- Deprecated use of a `query` property to configure Webpack rule options as a separate object - an `options` property should now be used as per Webpack 2's new config format: + + ```js + // < v0.15 // v0.15 + module.exports = { module.exports = { + webpack: { webpack: { + loaders: { rules: { + css: { css: { + query: { => options: { + modules: /* ... */ modules: /* ... */ + } } + } } + } } + } } + } } + ``` + + You can also still configure loader options as a flat object to make this particular change irrelevant: + + ```js + module.exports = { + webpack: { + rules: { + css: { + modules: /* ... */ + } + } + } + } + ``` + +- Deprecated configuring PostCSS plugins with special `webpack.postcss` config - postcss-loader can now be configured like any other loader using [`webpack.rules` config](https://github.com/insin/nwb/blob/master/docs/Configuration.md#configuring-postcss): + + ```js + // < v0.15 // v0.15 + module.exports = { module.exports = { + webpack: { webpack: { + postcss: [ => rules: { + require('precss')(), postcss: { + require('autoprefixer')() plugins: [ + ] require('precss')(), + } require('autoprefixer')() + } ] + } + } + } + } + ``` + +**Removed:** + +- Removed support for configuration which was deprecated in nwb v0.12. +- Removed support for `json-schema` in `webpack.compat` config, as this library has now been fixed [[#227](https://github.com/insin/nwb/issues/227)] + +**Dependencies:** + +- autoprefixer: v6.6.1 → [v6.7.0](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#670) +- babel-cli: v6.18.0 → [v6.22.2](https://github.com/babel/babel/blob/master/CHANGELOG.md#6222-2017-01-19) +- babel-core: v6.21.0 → [v6.22.1](https://github.com/babel/babel/blob/master/CHANGELOG.md#6221-2017-01-19) +- babel-plugin-inferno: v1.5.0 → v1.7.0 - make plugin ES5-environment compatible; add option to import `createVNode` +- babel-plugin-transform-react-jsx: v6.8.0 → [v6.22.0][babel6220] +- babel-plugin-transform-react-jsx-self: v6.11.0 → [v6.22.0][babel6220] +- babel-plugin-transform-react-jsx-source: v6.9.0 → [v6.22.0][babel6220] +- babel-plugin-transform-runtime: v6.15.0 → [v6.22.0][babel6220] +- babel-polyfill: v6.20.0 → [v6.22.0][babel6220] +- babel-preset-es2015: v6.18.0 → [v6.22.0][babel6220] +- babel-preset-es2016: v6.16.0 → [v6.22.0][babel6220] +- babel-preset-react : v6.16.0 → [v6.22.0][babel6220] +- babel-preset-stage-0: v6.16.0 → [v6.22.0][babel6220] +- babel-preset-stage-1: v6.16.0 → [v6.22.0][babel6220] +- babel-preset-stage-2: v6.18.0 → [v6.22.0][babel6220] +- babel-preset-stage-3: v6.17.0 → [v6.22.0][babel6220] +- babel-runtime: v6.20.0 → [v6.22.0][babel6220] +- detect-port: v1.0.7 → [v1.1.0](https://github.com/node-modules/detect-port/compare/1.0.7...1.1.0) +- filesize: v3.3.0 → [v3.4.3](https://github.com/avoidwork/filesize.js/compare/3.3.0...3.4.3) +- html-webpack-plugin: v2.24.1 → [v2.26.0](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2260) - Webpack 2 RC support +- inquirer: v2.0.0 → [v3.0.1](https://github.com/SBoudrias/Inquirer.js/releases/) - drop Node.js 0.12 support +- karma: v1.3.0 → [v1.4.0](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md#140-2017-01-14) +- karma-mocha-reporter: v2.2.1 → [v2.2.2](https://github.com/litixsoft/karma-mocha-reporter/blob/master/CHANGELOG.md#222-2017-01-19) +- karma-webpack: v1.8.0 → v2.0.1 - Webpack 2 RC support +- object-assign: v4.1.0 → [v4.1.1](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#122) +- ora: v0.4.1 → v1.1.0 - text can now be changed while stopping and persisting +- postcss-loader: v1.2.1 → [v1.2.2](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#122) +- webpack: v1.14.0 → [v2.2.0](https://medium.com/webpack/webpack-2-2-the-final-release-76c3d43bf144) - \o/ +- webpack-merge: v2.3.1 → [v2.4.0](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#240--2017-01-12) +- whatwg-fetch: v2.0.1 → [v2.0.2](https://github.com/github/fetch/releases/tag/v2.0.2) + +[babel6220]: https://github.com/babel/babel/blob/master/CHANGELOG.md#6220-2017-01-19 + +**Temporarily Scoped Dependencies:** + +These are being scoped to both make use of unreleased features and to test them out: + +- @insin/extract-text-webpack-plugin - scoped until [this PR](https://github.com/webpack/extract-text-webpack-plugin/pull/343) is merged and released +- @insin/npm-install-webpack-plugin - scoped until new features are merged and released + +**Internal:** + +- Dropped unused `fs-extra` dependency. +- Use [`babel-preset-env`](https://github.com/babel/babel-preset-env/) when transpiling to `lib/`, targeting Node.js 4 [[#233](https://github.com/insin/nwb/issues/233)] +- Use ES2015 `String` methods available in Node.js 4 instead of `String.prototype.indexOf` comparisons [[#222](https://github.com/insin/nwb/issues/222)] + +# 0.14.3 / 2017-01-21 + +**Fixed:** + +- Fix `inferno build` command [[#241](https://github.com/insin/nwb/issues/241)] [[balazs4][balazs4]] + +# 0.14.2 / 2017-01-20 + +**Fixed:** + +- Fix using Express middleware with a config file which exports a function [[#238](https://github.com/insin/nwb/issues/238)] + +# 0.14.1 / 2017-01-13 + +**Fixed:** + +- Fix running tests with base config only (`web-app` and `web-module` projects). + +**Dependencies:** + +- Downgrade `html-webpack-plugin` to v2.24.1 while issues later versions cause with `npm-install-webpack-plugin` are unresolved. + +# 0.14.0 / 2017-01-13 + +**Fixed:** + +- To prevent version compatibility issues using project commands from a globally-installed `nwb`, it will now exit with a warning if the project specifies a different version of nwb in `package.json` [[#167](https://github.com/insin/nwb/issues/167)] + - The ability to run project commands like `build`, `serve` etc. from a global `nwb` install is provided so you don't have to reinstall the entirety of nwb when creating new projects, but it's *recommended* that you switch to a locally-installed version later, as relying on globally-installed tool versions is brittle. +- Fix `clean` commands in paths with spaces [[#181](https://github.com/insin/nwb/issues/181)] + +**Added:** + +- Added an `inferno` command for quick Inferno prototyping and building. Use `inferno run <entry.js>` to serve a module and `inferno build <entry.js> [dist/]` to build it. +- Added a `preact` command for quick Preact prototyping and building. Use `preact run <entry.js>` to serve a module and `preact build <entry.js> [dist/]` to build it. +- The `inferno` and `preact` commands use a render shim module by default which hooks into `Inferno.render()` and `Preact.render()` to intercept the incoming VNode and re-render it from the top when accepting Hot Module Replacement, so if you're calling `render()` yourself you don't have to specify a DOM node, or a `root` when re-rendering in Preact. + - If you want to take full control of rendering, use the `--force` flag and nwb will skip the render shim and use your entry module directly. + - The `react` command's render shim doesn't hook into `ReactDOM.render()` and only handles rendering exported components or elements for convenient prototyping, as [react-transform-hmr](https://github.com/gaearon/react-transform-hmr) handles the details of accepting Hot Module Replacement and patching/re-rendering at the component/module level. +- Added new features which are available in the `inferno` and `preact` commands to the existing `react` command: + - Added a `--plugins` option to specify nwb plugins which should be installed and used without having to set up a `package.json`. + - Added a `--force` option to force use of the provided entry module directly instead of the render shim module which is used by default to support quick prototyping. + - Added a `--no-polyfill` option to disable inclusion of nwb's default polyfills for `Promise`, `fetch()` and `Object.assign()` if you're not using them or don't need them polyfilled. + - Inferno compat and Preact compat dependencies are now automatically installed if missing. + - `react build` can now build a module which exports a React component or element, for quick sharing of prototypes. +- Inferno and Preact apps are now configured to use their respective React compatibility modules by default if `react` or `react-dom` are imported, allowing use of existing React code out of the box. + +**Changed:** + +- The Webpack manifest module is now generated when building an app (as well as being inlined into the generated `index.html`) - you will need to include this first if manually handling HTML generation after building. +- Express middleware now supports Inferno, Preact and plain JavaScript apps, not just React. +- When building a React app using the `--inferno` or `--preact` flags, the required compatibility dependencies are now installed automatically if they can't be resolved from your project directory. +- When creating new projects, the latest version of dependencies will be installed, rather than using a a version range hardcoded in nwb. +- Skip initialising a Git repo if a `.git/` directory already exists, e.g. you may want to use `nwb init` in an existing repo. +- The default build for a React component demo app now supports use of a `demo/public/` directory for static content. +- An `args` property is now included in the object passed to user configs which export a function - this contains parsed arguments, e.g. `args.preact` will be `true` if you passed `--preact` when calling `nwb`. + +**Removed:** + +- Removed support for using `--set-env-VAR_NAME` arguments to set environment variables. +- `jsnext:main` is no longer included `package.json` for new `react-component` and `web-module` projects - only the "more standard" `module` property is used to point to an ES2015 modules build [[#215](https://github.com/insin/nwb/issues/215)] + +**Dependencies:** + +- autoprefixer: v6.5.3 → [v6.6.1](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#661) +- babel-core: v6.20.1 → v6.21.0 +- babel-loader: v6.2.9 → [v6.2.10](https://github.com/babel/babel-loader/blob/master/CHANGELOG.md#v6210) - Webpack 2 RC support +- babel-plugin-inferno: v1.4.0 → v1.5.0 - use import instead of global Inferno reference +- babel-plugin-istanbul: v3.0.0 → [v3.1.2](https://github.com/istanbuljs/babel-plugin-istanbul/blob/master/CHANGELOG.md#312-2017-01-04) +- babel-plugin-lodash: v3.2.10 → [v3.2.11](https://github.com/lodash/babel-plugin-lodash/compare/3.2.10...3.2.11) +- detect-port: v1.0.6 → [v1.0.7](https://github.com/node-modules/detect-port/releases/tag/1.0.7) +- html-webpack-plugin: v2.24.1 → [v2.26.0](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2260) - Webpack 2 RC support +- karma-webpack: v1.8.0 → v1.8.1 - Webpack 2 RC support +- ora: v0.3.0 → v0.4.1 +- phantomjs-prebuilt: v2.1.13 → [v2.1.14](https://github.com/Medium/phantomjs/releases/tag/2.1.14) +- postcss-loader: v1.2.0 → [v1.2.1](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#121) +- resolve: v1.1.7 → [v1.2.0](https://github.com/browserify/resolve/compare/1.1.7...v1.2.0) +- webpack-dev-middleware: v1.8.4 → [v1.9.0](https://github.com/webpack/webpack-dev-middleware/releases/tag/v1.9.0) - Webpack 2 RC support +- webpack-hot-middleware: v2.13.2 → [v2.15.0](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.13.2...v2.15.0) - add cache for warnings +- webpack-merge: v1.0.2 → [v2.3.1](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#231--2017-01-06) - providing an empty array/object no longer overrides when merging + +# 0.13.8 / 2016-12-31 + +**Changed:** + +- Inferno apps now use Inferno 1.x by default. + +**Dependencies:** + +- babel-plugin-inferno: v1.3.0-beta17 → v1.4.0 + +# 0.13.7 / 2016-12-25 + +**Fixed:** + +- Updated Inferno Babel plugin to fix whitespace trimming issue. + +**Changed:** + +- Updated default Inferno version for new apps to 1.0.0-beta42. + +**Dependencies:** + +- babel-plugin-inferno: v1.2.0-beta13 → v1.3.0-beta17 - fixes whitespace trimming around newlines + +# 0.13.6 / 2016-12-13 + +**Fixed:** + +* Don't configure the [babel runtime transform](https://babeljs.io/docs/plugins/transform-runtime/)'s `moduleName` path when transpiling code for npm [[#205](https://github.com/insin/nwb/issues/205)] + + If you depend on `babel-runtime` in a React component or Web module (by using `async`/`await` or [enabling any of the runtime transform's other features](https://github.com/insin/nwb/blob/master/docs/Configuration.md#runtime-string--boolean) it needs to be resolvable from the end-user's dependencies, so should be added to your project's `peerDependencies`. + +# 0.13.5 / 2016-12-13 + +**Fixed:** + +* Fix bad char in initial Git commit [[#182](https://github.com/insin/nwb/issues/182) by [ntwcklng][ntwcklng]] + +# 0.13.4 / 2016-12-11 + +**Fixed:** + +* Fix default test in the `preact-app` skeleton [[#206](https://github.com/insin/nwb/pull/206) by [ntwcklng][ntwcklng]] + +# 0.13.3 / 2016-12-10 + +**Fixed:** + +* Fix npm scripts in the `inferno-app` skeleton. + +# 0.13.2 / 2016-12-10 + +**Fixed:** + +* Initialise a Git repo for a new project *after* installing dependencies, so package.json includes dependencies saved by npm in the initial commit. + +# 0.13.1 / 2016-12-10 + +**Added:** + +* Added a `--copy-files` flag for React component builds to copy files which will not be transpiled over to the build directories [[#58](https://github.com/insin/nwb/issues/58)] + +# 0.13.0 / 2016-12-09 + +**Added:** + +- Added new project types: `inferno-app` and `preact-app` - use these with `nwb new` or `nwb init` to develop [Inferno](https://infernojs.com/) and [Preact](https://preactjs.com/) apps [[#194](https://github.com/insin/nwb/issues/194)] +- Added an [`--inferno` flag](https://github.com/insin/nwb/blob/next/docs/Commands.md#build-1) to React app builds to create an [`inferno-compat`](https://github.com/trueadm/inferno/tree/master/packages/inferno-compat) build [[#194](https://github.com/insin/nwb/issues/194)] +- [`react-jsx-source`](https://babeljs.io/docs/plugins/transform-react-jsx-source/) and [`react-jsx-self`](https://babeljs.io/docs/plugins/transform-react-jsx-self/) Babel transforms are now enabled for React apps in development mode for improved debugging. +- A Git repo with an initial commit is now created by default when creating a new project. Pass a `--no-git` flag to disable this. +- Added project-specific variants of `nwb test`: `nwb test-react`, `nwb-test-inferno` and `nwb-test-preact`. +- Added an `audio` loader and an `svg` loader. + +**Removed:** + +- Removed hardcoded React preset from default Babel config when running tests - instead, `nwb test` will run the new `nwb test-react` command if you have a `react-app` or `react-component` project type in `nwb.config.js`. +- Dependencies are no longer bundled. As a result, Babel 6 dependencies will no longer be deduplicated for npm2 users, so an nwb install will be slower and larger - consider upgrading to npm3 or [yarn](https://yarnpkg.com/) if you can. +- Removed support for deprecated `webpack.plugins` config in `nwb.config.js` - this config must now be moved up into `webpack` instead. + +**Changed:** + +- Handling of`.svg` files has been moved from the `graphics` loader to the new `svg` loader so inlining can be configured separately. This matters if you're using a [sprite system](http://una.im/svg-icons/), as base64 inlining SVGs breaks [fragment identifiers](https://css-tricks.com/svg-fragment-identifiers-work/). +- Changed `babel-plugin-transform-runtime` configuration to make use of new `moduleName` config; Webpack module resolution no longer uses a blanket fallback to nwb's `node_modules/` for serving and builds. +- [`webpack.uglify` config](https://github.com/insin/nwb/blob/next/docs/Configuration.md#uglify-object--false) can now be set to `false` to disable use of `UglifyJSPlugin` in production builds for debugging [[#160](https://github.com/insin/nwb/issues/160)] + +**Dependencies:** + +- autoprefixer: v6.4.0 → [v6.5.3](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#653) +- babel-cli: v6.11.4 → v6.18.0 +- babel-core: v6.13.2 → v6.20.0 +- babel-loader: v6.2.4 → [v6.2.9](https://github.com/babel/babel-loader/blob/master/CHANGELOG.md) - better syntax error messages +- babel-plugin-istanbul: v2.0.0 → [v3.0.0](https://github.com/istanbuljs/babel-plugin-istanbul/blob/master/CHANGELOG.md#300-2016-11-14) +- babel-plugin-lodash: v3.2.8 → [v3.2.10](https://github.com/lodash/babel-plugin-lodash/compare/3.2.8...3.2.10) +- babel-plugin-transform-react-remove-prop-types: v0.2.9 → [v0.2.11](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/compare/v0.2.9...v0.2.11) +- babel-plugin-transform-runtime: v6.12.0 → [v6.15.0](https://github.com/babel/babel/blob/master/CHANGELOG.md#v6150-2016-08-31) - add `moduleName` config to specify runtime path +- babel-polyfill: v6.13.0 → v6.20.0 +- babel-preset-es2015: v6.14.0 → v6.18.0 +- babel-preset-es2016: v6.11.3 → v6.16.0 +- babel-preset-react: v6.11.1 → v6.16.0 +- babel-preset-stage-0: v6.5.0 → v6.16.0 +- babel-preset-stage-1: v6.13.0 → v6.16.0 +- babel-preset-stage-2: v6.13.0 → v6.18.0 +- babel-preset-stage-3: v6.11.0 → v6.17.0 +- babel-runtime: v6.11.6 → v6.20.0 +- case-sensitive-paths-webpack-plugin: v1.1.3 → v1.1.4 - handle cwd being incorrect case +- copy-webpack-plugin: v3.0.1 → [v4.0.1](https://github.com/kevlened/copy-webpack-plugin/releases) +- css-loader: v0.23.1 → [v0.26.1](https://github.com/webpack/css-loader/compare/v0.23.0...v0.26.1) - cssnano's use of autoprefixer is now disabled by default +- detect-port: v1.0.0 → v1.0.6 +- figures: v1.7.0 → v2.0.0 +- html-webpack-plugin: v2.22.0 → [v2.24.1](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2241) +- inquirer: v1.1.2 → [v2.0.0](https://github.com/SBoudrias/Inquirer.js/releases/tag/v2.0.0) +- glob: v7.0.5 → [v7.1.1](https://github.com/isaacs/node-glob/compare/v7.0.5...v7.1.1) +- karma: v1.2.0 → [v1.3.0](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md#130-2016-09-09) +- karma-chrome-launcher: v1.0.1 → [v2.0.0](https://github.com/karma-runner/karma-chrome-launcher/blob/master/CHANGELOG.md#200-2016-08-18) - chromium support +- karma-mocha: v1.1.1 → [v1.3.0](https://github.com/karma-runner/karma-mocha/compare/v1.1.1...v1.23.0) +- karma-mocha-reporter: v2.1.0 → [v2.2.1](https://github.com/litixsoft/karma-mocha-reporter/blob/master/CHANGELOG.md#221-2016-11-18) +- karma-phantomjs-launcher: v1.0.1 → [v1.0.2](https://github.com/karma-runner/karma-phantomjs-launcher/blob/master/CHANGELOG.md#102-2016-08-31) - fix phantomjs path calculation +- mocha: v3.0.2 → [v3.2.0](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#320--2016-11-24) +- phantomjs-prebuilt: v2.1.12 → [v2.1.13](https://github.com/Medium/phantomjs/releases/tag/2.1.13) +- postcss-loader: v0.10.0 → [v1.2.0](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#12) +- qs: v6.2.1 → [v6.3.0](https://github.com/ljharb/qs/blob/master/CHANGELOG.md#630) +- webpack: v1.13.1 → [v1.14.0](https://github.com/webpack/webpack/compare/v1.13.1...v1.14.0) - updated node-libs-browser and uglifyjs versions - `screw_ie8` is now enabled by default; fix for Babel sourcemap issue +- webpack-merge: v0.14.1 → [v1.0.2](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#102--2016-11-29) +- webpack-dev-middleware: v1.6.1 → [v1.8.4](https://github.com/webpack/webpack-dev-middleware/blob/master/CHANGELOG.md#184-2016-10-08) +- webpack-hot-middleware: v2.12.2 → [v2.13.2](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.12.2...v2.13.2) +- whatwg-fetch: v1.0.0 → [v2.0.1](https://github.com/github/fetch/releases) - changes behaviour of `Headers` to be spec-compliant + +# 0.12.2 / 2016-09-29 + +**Removed:** + +- Dropped the production `react-constant-elements` transform for now due to bugs. + +# 0.12.1 / 2016-09-15 + +**Experimental:** + +- `react run` can now run modules which export a React component or element. + +**Added:** + +- Added a `reload` option to [Express middleware](https://github.com/insin/nwb/blob/master/docs/Middleware.md#middlewareexpress-options-object) to enable reloading the page if Hot Module Reloading is unsuccessful [[#168](https://github.com/insin/nwb/issues/168)] + +# 0.12.0 / 2016-08-16 + +**Breaking Changes:** + +- **Dropped Node.js 0.12 support** + + Based on the `engines` config of nwb's dependencies, Node.js 4.2.0 is now the minimum required version. +- **Upgraded from Babel 5 to Babel 6** [[#12](https://github.com/insin/nwb/issues/12)] [[#31](https://github.com/insin/nwb/issues/31)] [[@geowarin](https://github.com/geowarin/)] + + Babel 6 introduced [a number of breaking changes](https://github.com/babel/babel/blob/master/CHANGELOG.md#600) which you may need to account for in your codebase if you're using nwb or were otherwise using Babel 5. + + [`babel` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#babel-configuration) in `nwb.config.js` is **no longer directly equivalent to what you would put in a [`.babelrc` file](https://babeljs.io/docs/usage/babelrc/)**. +- **Added support for long-term caching** [[#73](https://github.com/insin/nwb/issues/73)] + + A deterministic hash is now included in the filenames of generated `.js` and `.css` files. + + The Webpack manifest (required for module loading) is now extracted and automatically injected prior to the `</body>` tag, so **your HTML template *must* have a `</body>` tag**. + + **If you do any post-build processing on generated files it might need to be updated**, as production app builds will now generate files as `[name].[hash].[ext]` instead of `[name].[ext]`. +- **Dropped support for the `.jsx` extension** + + [It's dead, Jim](https://github.com/facebookincubator/create-react-app/issues/87#issuecomment-234627904). + + > You can use [`webpack.loaders` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#loaders-object) to set `/\.jsx?$/` as `babel-loader`'s `test` config and [`webpack.extra config`](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#extra-object) to add `.jsx` back to the `resolve.extensions` list if you're using `.jsx` files and can't reasonably migrate away. +- **Dropped `build-module` and `build-umd/clean-umd`commands** + + These were a confusing middle layer which split the implementation of building a React component or browser-focused npm module in two. They both required a config file to provide a project `type` for nwb to figure out what to do. + + They've been **replaced with `build-react-component` and `build-web-module` commands**, which are now used in `package.json` `scripts` in the corresponding project skeletons. + + As a result **having a config file is now optional for all project types**. If you don't need configuration, you can delete the `nwb.config.js` file created as a convenience by project skeletons. + + A config file is now only required if you want to use the generic `build`, `clean` and `serve` commands. +- **Changed ES6 module build directory from `es6/` to `es/`** + + Upgrade steps: + + - Replace `"es6/index.js"` with `"es/index.js"` in `package.json` `"jsnext:main"` config + - Also add `"module": "es/index.js"`, as this is part of [a proposal for native module support](https://github.com/dherman/defense-of-dot-js/blob/master/proposal.md) which is being supported by multiple bundlers. + - Replace `"es6"` with `"es"` in `package.json` `files` config + +- **Dropped `webpack.vendorBundle` config in favour of a `--no-vendor` flag** + + Making this feature toggle a command line argument makes it easier to try, and to combine with other feature toggles like `--preact`. + + Tweak your `package.json` `"build"` script instead if you were using `webpack.vendorBundle: false` config: + + ```json + { + "scripts": { + "build": "nwb build-react-app --no-vendor" + } + } + ``` + +**`nwb.config.js` Config Format Changes:** + +- **`build` config is deprecated in favour of new [`npm` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#npm-object)**, which is a slightly different format. + + nwb will adapt any `build` config it finds for the current build and log out the equivalent `npm` config. + + ``` + // < v0.12 // v0.12 + module.exports = { module.exports = { + build: { => npm: { + jsNext: true, esModules: true, + umd: true, => umd: { + global: 'MyComponent', global: 'MyComponent', + externals: {'react': 'React'} externals: {'react': 'React'} + } } + } } + } + ``` + ``` + // < v0.12 // v0.12 - simple UMD config without externals + module.exports = { module.exports = { + build: { => npm: { + jsNext: true, esModules: true, + umd: true, => umd: 'myLib' + global: 'MyLib' } + } } + } + ``` + +- **The Babel [runtime transform](https://babeljs.io/docs/plugins/transform-runtime/) is now configured using new [`babel.runtime` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#runtime-string--boolean)** instead of Babel 5's `optional` config. + + **The runtime transform is now partially-enabled by default** to support use of `async`/`await` and generators, so update your configuration accordingly. nwb will adapt `['runtime']` config for the current build by converting it to `true`. + + ``` + // < v0.12 // v0.12 - enabled by default for regenerator + module.exports = { + babel: { + optional: ['runtime'] => // You can remove your config if you were + } // using it for async/await or generators + } + ``` + ``` + // < v0.12 // v0.12 - also import helpers from + module.exports = { module.exports = { + babel: { babel: { + optional: ['runtime'] => runtime: 'helpers' + } } + } } + ``` + +- **[`babel.loose` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#loose-boolean) is now Boolean** instead of Babel 5's string config. + + **[Loose mode](http://www.2ality.com/2015/12/babel6-loose-mode.html) is now enabled by default**, so `loose` config is only used if you need to disable loose mode. + + ``` + // < v0.12 // v0.12 - enabled by default + module.exports = { + babel: { + loose: 'all' => (none) + } + } + ``` + ``` + // < v0.12 - loose mode not used // v0.12 - disabling loose mode + module.exports = { + babel: { + (none) => loose: false + } + } + ``` + +- **`karma.tests` config is deprecated in favour of new [`karma.testContext`](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#testcontext-string) and [`karma.testFiles` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#testfiles-string--arraystring)**, depending on which was being specified. If `karma.tests` is present, nwb will attempt to detect the appropriate new config to use it for, or will otherwise fall back to the new default config. + + ``` + // < v0.12 // v0.12 - using a Webpack context module + module.exports = { module.exports = { + karma: { karma: { + tests: 'tests.webpack.js' => testContext: 'tests.webpack.js' + } } + } } + ``` + ``` + // < v0.12 // v0.12 - custom test file glob + module.exports = { module.exports = { + karma: { karma: { + tests: 'test/**.test.js' => testFiles: 'test/**.test.js' + } } + } } + ``` + +**Developer Experience Improvements:** + +- **Added a `check-config` command which checks your nwb configuration file** for errors and deprecated usage, and provides some usage hints (e.g. where more convenient config is available). + + Run this after upgrading your nwb version and it will tell you what needs to be changed. +- **New user-friendly output for Webpack builds based on [create-react-app](https://github.com/facebookincubator/create-react-app)'s**. + + This provides friendlier error and warning reporting, reports the gzipped size of generated files and uses a persistent console for development server logging. + + **Windows Note:** running a development server will clear the current screen in your console - in Windows the escape codes used to do this have the unfortunate effect of clearing *all* the scrollback history in your current console. + + To avoid this **use the `start` command to spawn a new command window when running the development server in Windows**, e.g.: + + ``` + start npm start + start react run app.js + ``` +- **Apps can now use `fetch`, `async`/`await` and generators out of the box without any configuration.** + + `Promise`, `fetch`, `Object.assign` polyfills and the regenerator runtime are now provided by default. +- You can now **transform destructured imports to cherry-picked imports for specified modules** using new [`babel.cherryPick` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#cherrypick-string--arraystring) [[#141](https://github.com/insin/nwb/issues/141)] +- Case-sensitivity of `require`/`import` paths is now enforced by [`CaseSensitivePathsPlugin`](https://github.com/Urthen/case-sensitive-paths-webpack-plugin), avoiding an easy-to-overlook cause of CI build failure if you don't develop on Linux. +- If the intended dev server port is not available, you will now be prompted to continue with a different, free port. + +**React App Optimisations:** + +- **Production React builds now remove `propTypes` from ES6 class and stateless functional components** (but not from your dependencies) using [react-remove-prop-types](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types) [[#97](https://github.com/insin/nwb/issues/97)] + +- **Added a [`--preact` flag](https://github.com/insin/nwb/blob/0.12/docs/Commands.md#build-1)** to React app builds to create a [`preact-compat`](https://github.com/developit/preact-compat) build. + + This is an easy way to try [Preact](https://preactjs.com/) with your React apps, resulting in a much smaller bundle if your app is compatible [[#124](https://github.com/insin/nwb/issues/124)] + +**Babel:** + +- **nwb implements its own support for a Babel 6 equivalent of Babel 5's `stage` configuration** to [choose which experimental features are enabled](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#stage-number--false), including defaulting to [Stage 2](https://babeljs.io/docs/plugins/preset-stage-2/). + + For stage 2 and below, **decorators can be use by default**, as nwb will include the [Babel Legacy Decorator transform plugin](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy). See [the plugin's Best Effort documentation](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy#best-effort) for differences you will need to take into account if you were using Babel 5 decorators. +- **nwb preserves CommonJS interop for apps and component ES5 builds** using the [`add-module-exports`](https://github.com/59naga/babel-plugin-add-module-exports) plugin. + + This means a `.default`doesn't need to be tagged on when you're using `require()` with Webpack's code-splitting, or when people import your npm modules using `require()` directly. + + Babel 6 removed interop with CommonJS exports, as it allowed you to write broken ES6 code. Kent C. Dodds has [a post about this which is well worth reading](https://medium.com/@kentcdodds/misunderstanding-es6-modules-upgrading-babel-tears-and-a-solution-ad2d5ab93ce0) to understand what *not* to do. +- **[Loose mode](http://www.2ality.com/2015/12/babel6-loose-mode.html) is now enabled by default.** +- **Changed [`babel.loose` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#loose-boolean) to Boolean**. + + This is now only needed if you want to disable loose mode (e.g. in non-production environments to check for ES6 compliance errors in normal mode). +- **Added [`babel.runtime` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#runtime-string--boolean)** to configure the Babel runtime transform, replacing Babel 5's `optional` config. + + This is turned on by default, configured to import the regenerator runtime when `async`/`await` or generators are used. +- **Removed the inline element transform optimisation for React app production builds**, as the Babel 6 version of it currently depends on polyfilling `Symbol`. + +**Karma:** + +- **Changed default testing configuration** to support co-location of tests and a wider range of test file names and locations. This should be backwards-compatible with the previous defaults. + - Test files included by default are now `-test.js`, `.test.js` or `.spec.js` files anywhere underneath a `src/`, `test/` or `tests/` directory. + - Code coverage also ignores all code underneath `test/`, `tests/` or any `__tests__/` directory inside `src/` by default, as well as test files. +- **Added [`karma.browsers` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#browsers-string--arrayplugin)** to customise which browsers tests are run in. + + The plugin to support use of `'Chrome'` in this config is also available by default. +- **Added [`karma.testDirs` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#testdirs-string--arraystring)** to control which directories are excluded from code coverage reporting. +- **[`babel-plugin-istanbul`](https://github.com/istanbuljs/babel-plugin-istanbul) is now used to instrument code for test coverage** instead of `isparta-loader`. + +**Webpack:** + +*Default Loader Config* + +- **Disabled `css-loader`'s use of Autoprefixer** - nwb's PostCSS configuration is now the only source of prefix addition and removal [[#132](https://github.com/insin/nwb/issues/132)] +- All static file loaders now use `url-loader` (which falls back to `file-loader`) to allow you to configure inlining for any group of static files if needed. +- **Changed default `limit` config for all static file loaders to `1`**, effectively disabling inlining by default - if you want resources smaller than a given size to be inlined, configure `limit` using [`webpack.loaders` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#loaders-object). +- Moved handling of `.svg` files from the `fonts` loader to the `graphics` loader. +- Moved handling of `.eot` files to the `fonts` loader and removed the `eot` loader. +- Added a `video` loader for `.mp4'`, `.ogg` and `.webm`. +- Added `.webp` to the `graphics` loader. + +*Default Plugin Config* + +- **Updated default `UglifyJsPlugin` options** to strip comments from output and use the `screw_ie8` setting in every minification step. + +*Configuration* + +- **Added [`webpack.aliases` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#aliases-object)** to set up module resolving aliases, as a convenient alternative to using `webpack.extra.resolve.alias` [[#125](https://github.com/insin/nwb/issues/125)] +- **Added [`webpack.autoprefixer` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#autoprefixer-string--object)** to configure Autoprefixer in nwb's default PostCSS configuration [[#132](https://github.com/insin/nwb/issues/132)] +- **Added [`webpack.publicPath` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#publicpath-string)** to set up or clear the path/URL used for static resources, as a convenient alternative to using `webpack.extra.output.publicPath`. +- **Added [`webpack.uglify` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#uglify-object)** to allow customisation of Webpack `UglifyJsPlugin` options. +- **[`webpack.compat` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#compat-object) now supports `'json-schema': true`** to prevent a transitive [`json-schema`](https://github.com/kriszyp/json-schema) dependency breaking Webpack builds. This usually manifests itself as an `Uncaught Error: define cannot be used indirect` error. +- **Generated `module.noParse` config is now an `Array`**, so any user-provided config for it in `webpack.extra` (which should also be specified as an `Array`) can now be merged into it. + +**npm Build:** + +- When creating a project with an ES6 modules build enabled, a `"module"` property will be added to the project's `package.json` as well as `"jsnext:main"` [[#137](https://github.com/insin/nwb/issues/137)] + + This is the default property Webpack 2 uses to look for an ES6 modules build. +- `build` config is deprecated in favour of new [`npm` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#npm-object). +- **React component builds now wrap `propTypes` for ES6 class and stateless functional components with an environment check** - `if (process.env.NODE_ENV !== 'production')` - so they'll automatically be stripped from the production build in apps which use them. [[#145](https://github.com/insin/nwb/issues/145)] + + `propTypes` will be stripped from the minified UMD build. + + This can be disabled by passing a `--no-proptypes` flag. +- Building a React demo app during a React component build can now be skipped by passing a `--no-demo` flag [[#155](https://github.com/insin/nwb/issues/155)] + +**Other Configuration:** + +- **Fallback index serving for HTML5 History apps is now enabled by default** in the development server. This can be disabled by passing a `--no-fallback` flag. +- **Added [`polyfill` config](https://github.com/insin/nwb/blob/0.12/docs/Configuration.md#polyfill-boolean)** to disable default polyfilling of `Promise` and `fetch` for apps if you don't need it and want to shave a few KB off your build. +- **The dev server port can now be specified via a `PORT` environment variable**. The CLI `--port` takes precedence if both are provided. + +**CLI:** + +- Added a `nwb check-config` command. +- CLI now uses spinners for build commands, with gzipped filesize logging. +- **Reworked build commands for React components and npm modules** to remove a needless middle layer and add specific build commands for these project types. +- **Removed the `-g, --global` argument for enabling a UMD build** when creating a React component or web module project, in favour of passing a name to the `--umd` argument instead. +- **Removed the `--info` flag for showing webpack output**, as this is now handled in a more developer-friendly manner. + +**Starter Projects:** + +- The react-app project skeleton now includes examples of importing CSS and images. +- Required `<meta>` tags in HTML templates are now all first thing in `<head>`. +- Added `shrink-to-fit=no` to the `viewport` `<meta>` tag in HTML templates for Safari. + +**Dependencies:** + +- autoprefixer: v6.3.6 → [v6.4.0](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#640) +- babel\* v5 → babel\* v6 +- [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul/): v2.0.0 +- [babel-plugin-lodash](https://github.com/lodash/babel-plugin-lodash): v3.2.8 +- [babel-plugin-transform-react-remove-prop-types](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types): v0.2.9 +- [case-sensitive-paths-webpack-plugin](https://github.com/Urthen/case-sensitive-paths-webpack-plugin): v1.1.3 +- connect-history-api-fallback: v1.2.0 → [v1.3.0](https://github.com/bripkens/connect-history-api-fallback/blob/master/CHANGELOG.md#v130) - allow disabling of the dot rule +- copy-template-dir: v1.2.1 → v1.3.0 - support vars in filenames +- expect: v1.20.1 → [v1.20.2](https://github.com/mjackson/expect/compare/v1.20.1...v1.20.2) +- express: v4.13.4 → [v4.14.0](https://github.com/expressjs/express/blob/master/History.md#4140--2016-06-16) +- [figures](https://github.com/sindresorhus/figures): v1.7.0 +- file-loader: v0.8.5 → [v0.9.0](https://github.com/webpack/file-loader/compare/v0.8.5...v0.9.0) +- glob: v7.0.3 → [v7.0.5](https://github.com/isaacs/node-glob/compare/v7.0.3...v7.0.5) +- html-webpack-plugin: v2.19.0 → [v2.22.0](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2220) +- inquirer: v1.0.3 → [v1.1.2](https://github.com/SBoudrias/Inquirer.js/compare/v1.0.3...v1.1.2) +- karma: v0.13.22 → [v1.2.0](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md#120-2016-08-11) +- karma-chrome-launcher v1.0.1 +- karma-coverage: v1.0.0 → [v1.1.1](https://github.com/karma-runner/karma-coverage/blob/master/CHANGELOG.md#111-2016-07-23) +- karma-mocha-reporter: v2.0.3 → [v2.1.0](https://github.com/litixsoft/karma-mocha-reporter/compare/v2.0.3...v2.1.0) +- karma-phantomjs-launcher: v1.0.0 → [v1.0.1](https://github.com/karma-runner/karma-phantomjs-launcher/blob/master/CHANGELOG.md#101-2016-06-23) +- karma-webpack: v1.7.0 → [v1.8.0](https://github.com/webpack/karma-webpack/blob/master/CHANGELOG.md#180-2016-08-07) - remove dist from scm +- mocha: v2.5.3 → [v3.0.2](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#302--2016-08-08) +- npm-install-webpack-plugin: v4.0.1 → [v4.0.4](https://github.com/ericclemmons/npm-install-webpack-plugin/blob/master/CHANGELOG.md#404-2016-06-30) +- phantomjs-prebuilt: v2.1.7 → v2.1.12 - npm packaging fun +- postcss-loader: : v0.9.1 → [v0.10.0](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#0100) +- qs: v6.2.0 → [v6.2.1](https://github.com/ljharb/qs/blob/master/CHANGELOG.md#621) +- rimraf: v2.5.2 → [v2.5.3](https://github.com/isaacs/rimraf/compare/v2.5.2...v2.5.3) +- [webpack-fail-plugin](https://github.com/TiddoLangerak/webpack-fail-plugin): v1.0.5 +- webpack-hot-middleware: v2.10.0 → [v2.12.2](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.10.0...v2.12.2) +- [webpack-md5-hash](https://github.com/erm0l0v/webpack-md5-hash): v0.0.5 +- webpack-merge: v0.14.0 → [v0.14.1](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#0141--2016-07-25) + +# 0.11.1 / 2016-07-16 + +**Fixed:** + +- PostCSS config was not being created for the vendor/`node_modules/` loader for CSS preprocessor plugins [[#129](https://github.com/insin/nwb/issues/129)] + +# 0.11.0 / 2016-06-08 + +**Breaking Changes:** + +- Replaced the deprecated `autoprefixer-loader` with `postcss-loader` in default style pipelines - it's configured to do the same autoprefixing by default [[#57](https://github.com/insin/nwb/issues/57)] + - If you were configuring vendor prefixing using `webpack.loaders.autoprefixer`, you will now need to manage an `autprefixer` dependency yourself and use [`webpack.postcss`](https://github.com/insin/nwb/blob/0.11/docs/Configuration.md#postcss-object) to perform this configuration. + +**`nwb.config.js` Config Format Changes:** + +* `webpack.plugins` is deprecated - config under `webpack.plugins` should be moved up into `webpack` instead. Having certain config under a `plugins` prop was an implementation detail which wasn't relevant to end-users [[#113](https://github.com/insin/nwb/issues/113)] + + ```js + // < v0.11 + module.exports = { + webpack: { + plugins: { + define: {...}, + html: {...} + } + } + } + ``` + ```js + // v0.11 + module.exports = { + webpack: { + define: {...}, + html: {...} + } + } + ``` +* Support for flatter [Webpack loader configuration](https://github.com/insin/nwb/blob/0.11/docs/Configuration.md#loaders-object) was added. Having a `query` object is now optional - loader query configuration can now be placed directly under the loader's id [[#113](https://github.com/insin/nwb/issues/113)] + + ```js + // < v0.11 + module.exports = { + webpack: { + loaders: { + css: { + query: { + modules: true + } + } + } + } + } + ``` + ```js + // v0.11 + module.exports = { + webpack: { + loaders: { + css: { + modules: true + } + } + } + } + ``` + +**Added:** + +- Installing globally now adds a `react` command for quick React development starting from a single file. + - `react run entry.js` runs a development server. + - `react build entry.js` creates a static build. + - For these commands, Babel is preconfigured to allow you to use all of its Stage 0 features out of the box, including `async`/`await`. + - These are implemented by (the previously undocumented) `serve-react` and (new) `build-react` nwb commands. +- The entry point for apps and npm module UMD builds can now be specified as an argument to [`build` and `serve` commands](https://github.com/insin/nwb/blob/0.11/docs/Commands.md#project-type-specific-commands). The default is still `src/index.js`. [[#115](https://github.com/insin/nwb/issues/115)] +- The directory web apps are built into can now be specified as an argument to [`build`, `clean` and `serve` commands](https://github.com/insin/nwb/blob/0.11/docs/Commands.md#project-type-specific-commands). The default is still `dist/`. +- Added [`webpack.compat` config](https://github.com/insin/nwb/blob/0.11/docs/Configuration.md#compat-object) to enable compatibility tweaks for modules which are known to be problematic with Webpack - initially this includes support for Enzyme, Moment.js and Sinon.js 1.x [[#108](https://github.com/insin/nwb/issues/108)] +- Added [`webpack.postcss` config](https://github.com/insin/nwb/blob/0.11/docs/Configuration.md#postcss-array--object) to customise the PostCSS plugins applied to each style pipeline [[#57](https://github.com/insin/nwb/issues/57)] +- Added [`webpack.vendorBundle` config](https://github.com/insin/nwb/blob/0.11/docs/Configuration.md#vendorbundle-boolean) to disable automatically extracting anything imported from `node_modules/` out into a separate `vendor` chunk [[#106](https://github.com/insin/nwb/issues/106)] +- Added [documentation for creating and using a test context module](https://github.com/insin/nwb/blob/0.11/docs/Testing.md#using-a-test-context-module) if there's code you need to run prior to tests running, such as configuring your assertion library with additional assertions. +- Added a `--config` option to allow you to specify your own config file instead of `nwb.config.js`. + +**Changed:** + +- Apps are no longer required to provide their own HTML template. The default template path of `src/index.html` will continue to be used if a file exists there. If an alternative template is not provided via [`webpack.html` config](https://github.com/insin/nwb/blob/0.11/docs/Configuration.md#html-object), nwb will now fall back to using a basic template. +- Restored default use of the Babel polyfill in Karma config so tests (and their dependencies) can assume a modern environment. +- Default `babel-loader` config now uses [`cacheDirectory: true` for a speedup](https://github.com/babel/babel-loader#babel-loader-is-slow). +- Improved debug output (activated with a `DEBUG=nwb` environment variable) to print config objects in full - if you're configuring plugin objects (e.g. PostCSS plugins), it's recommended to create instances of them if you want to use debug output. +- `webpack.optimize.DedupePlugin` is now only used for production builds, as recommended in the Webpack docs. + +**Dependencies:** + +- html-webpack-plugin: v2.17.0 → [v2.19.0](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2190) +- inquirer: v1.0.2 → [v1.0.3](https://github.com/SBoudrias/Inquirer.js/compare/v1.0.2...v1.0.3) +- mocha: v2.4.5 → [v2.5.3](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#253--2016-05-25) +- npm-install-webpack-plugin: v3.1.2 → [v4.0.1](https://github.com/ericclemmons/npm-install-webpack-plugin/blob/master/CHANGELOG.md#401-2016-06-06) - saving is on by default and [a new `dev` option controls](https://github.com/ericclemmons/npm-install-webpack-plugin#usage) where installed dependencies get saved to +- [postcss-loader](https://github.com/postcss/postcss-loader): v0.9.1 +- redbox-noreact: v1.0.0 → [v1.1.0](https://github.com/insin/redbox-noreact/blob/master/CHANGES.md#110--2016-05-29) +- webpack: v1.13.0 → [v1.13.1](https://github.com/webpack/webpack/compare/v1.13.0...v1.13.1) +- webpack-merge: v0.12.0 → [v0.14.0](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#0140--2016-06-05) + +# 0.10.0 / 2016-05-16 + +**Breaking Changes:** + +- React v15 is now installed into React app/component skeletons by default. + +**Changed:** + +- Default Karma config now includes `showDiff: true` config for the default Mocha reporter. +- The dev server now logs an initial `webpack building...` message so you know you're waiting for the initial build. +- npm scripts in the skeletons generated for `react-app` and `web-app` projects now use project type-specific commands, so the `nwb.config.js` included with them can be deleted if you don't need any config tweaks. +- nwb now passes the `--save` option to npm when installing React dependencies, to honour any npm [save-exact](https://docs.npmjs.com/misc/config#save-exact) (recommended!) or [save-prefix](https://docs.npmjs.com/misc/config#save-exact) config you have set. + +**Added:** + +- Extra Karma config can now be configured via a `karma.extra` Object. +- Added a `--react` option to allow you to set the version of React which will be installed when creating apps or components. This defaults to whatever the stable version of React was when the version of `nwb` you're using was released. + +**Dependencies:** + +- chalk: v1.1.1 → [v1.1.3](https://github.com/chalk/chalk/compare/v1.1.1...v1.1.3) - update deps +- cross-spawn: v2.1.5 → [v2.2.3](https://github.com/IndigoUnited/node-cross-spawn/compare/2.1.5...2.2.3) - update deps +- [detect-port](https://github.com/xudafeng/detect-port/): v1.0.0 +- expect: v1.16.0 → [v1.20.1](https://github.com/mjackson/expect/blob/master/CHANGES.md#v1201) +- html-webpack-plugin: v2.14.0 → [v2.17.0](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2170) +- inquirer: v0.12.0 → [v1.0.2](https://github.com/SBoudrias/Inquirer.js/compare/v0.12.0...v1.0.2) - switch to Promise-based API +- karma-coverage: v0.5.5 → [v1.0.0](https://github.com/karma-runner/karma-coverage/compare/v0.5.5...v1.0.0) +- karma-mocha: v0.2.2 → [v1.0.1](https://github.com/karma-runner/karma-mocha/compare/v0.2.2...v1.0.1) +- karma-mocha-reporter: v2.0.0 → [v2.0.3](https://github.com/litixsoft/karma-mocha-reporter/compare/v2.0.0...v2.0.3) +- npm-install-webpack-plugin: v3.0.0 → [v3.1.2](https://github.com/ericclemmons/npm-install-webpack-plugin/blob/master/CHANGELOG.md#v312-2016-05-12) [[#77](https://github.com/insin/nwb/issues/77)] +- phantomjs-prebuilt: v2.1.6 → [v2.1.7](https://github.com/Medium/phantomjs/releases/tag/v2.1.7) +- qs: v6.1.0 → [v6.2.0](https://github.com/ljharb/qs/blob/master/CHANGELOG.md#620) +- webpack: v1.12.14 → [v1.13.0](https://github.com/webpack/webpack/compare/v1.12.14...v1.13.0) +- webpack-merge: v0.8.4 → [v0.12.0](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#0120--2016-04-19) + +# 0.9.2 / 2016-03-27 + +**Dependencies:** + +- webpack-dev-middleware: v1.6.0 → [v1.6.1](https://github.com/webpack/webpack-dev-middleware/compare/v1.6.0...v1.6.1) - fixes request path issue introduced in 1.6.0 + +# 0.9.1 / 2016-03-26 + +**Fixed:** + +- `style-loader` was not being specified to apply styles from additional chunks when extracting CSS. + +# 0.9.0 / 2016-03-26 + +**Breaking Changes:** + +- Changes to how React and plain JS web apps are built: + - Builds are now generated in `dist/` instead of `public/build/` + - `index.html` for builds is now generated based on a template in `src/index.html`, instead of using a static `public/index.html` [[#34](https://github.com/insin/nwb/issues/34)] + + **Upgrading existing projects:** + + - move your `public/index.html` to `src/index.html` and delete the `<link>` and `<script>` tags for `vendor` and `app` resources. These will now be injected at build time. + - replace `/public/build` in your `.gitignore` with `/dist/` + + - `public/` is now only for public files - any contents in this directory will now be copied to `dist/` at the start of a build. The development server will also serve static content from `public/`. + +**Removed:** + +- Backwards compatibility for `nwb.config.js` format changes made in 0.8 has been removed. + +**Added:** + +- Added a `--host` option when running the dev server [[#50](https://github.com/insin/nwb/issues/50)] +- `ExtractTextPlugin` (used to extract CSS when building) can now be configured using `webpack.plugins.extractText` config - this allows you to configure the `allChunks` setting if you want all CSS to be extracted when using code splitting. +- `HtmlWebpackPlugin` (used to generate an `index.html` when building) can now be configured using `webpack.plugins.html` config. + +**Changed:** + +- `breakConfig: true` has been added to default `babel-loader` config to avoid `.babelrc` files being resolved by Babel - all Babel configuration is expected to be in `nwb.config.js` [[#63](https://github.com/insin/nwb/issues/63)] +- Static resources handled by Webpack's `file-loader` now include a hash in their filenames for cachebusting when they change [[#38](https://github.com/insin/nwb/issues/38)] + +**Dependencies:** + +- babel: v5.8.34 → v5.8.38 - left-pad transitive dependency drama +- babel-core: v5.8.34 → v5.8.38 - left-pad transitive dependency drama +- connect-history-api-fallback: v1.1.0 → v1.2.0 - support custom `Accept` headers +- copy-template-dir: v1.2.0 → v1.2.1 - support large template folders +- expect: v1.14.0 → [v1.16.0](https://github.com/mjackson/expect/compare/v1.14.0...v1.16.0) - mostly packaging changes? +- glob: v7.0.0 → [v7.0.3](https://github.com/isaacs/node-glob/compare/v7.0.0...v7.0.3) - misc fixes +- html-webpack-plugin: v2.9.0 → [v2.14.0](https://github.com/ampedandwired/html-webpack-plugin/blob/master/CHANGELOG.md#v2140) +- karma: v0.13.21 → [v0.13.22](https://github.com/karma-runner/karma/releases/tag/v0.13.22) - removed a large test file from npm package +- karma-coverage: v0.5.3 → [v0.5.5](https://github.com/karma-runner/karma-coverage/blob/master/CHANGELOG.md#055-2016-03-07) - bug fixes +- karma-mocha-reporter: v1.2.3 → [v2.0.0](https://github.com/litixsoft/karma-mocha-reporter/compare/v1.2.3...v2.0.0) - add karma to peerDeps; wait for all browsers to run +- npm-install-webpack-plugin: v2.0.2 → [v3.0.0](https://github.com/ericclemmons/npm-install-webpack-plugin/blob/master/CHANGELOG.md#300-2016-03-07) - `resolve.alias` and `resolve.root` support [[#83](https://github.com/insin/nwb/issues/83)] +- phantomjs-prebuilt: v2.1.4 → v2.1.6 - minor fixes to custom CA handling +- react-transform-hmr: v1.0.2 → [v1.0.4](https://github.com/gaearon/react-transform-hmr/releases/tag/v1.0.4) - update react-proxy to fix a few correctness issues +- style-loader: v0.13.0 → [v0.13.1](https://github.com/webpack/style-loader/compare/v0.13.0...v0.13.1) - add query to style/useable +- webpack-dev-middleware: v1.5.1 → [v1.6.0](https://github.com/webpack/webpack-dev-middleware/compare/v1.5.1...v1.6.0) +- webpack-hot-middleware: v2.7.1 → [v2.10.0](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.7.1...v2.10.0) - improved error overlay styling +- webpack-merge: v0.7.3 → [v0.8.4](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#084--2016-03-17) - change merging behavior so only loaders get prepended + +# 0.8.1 / 2016-03-03 + +**Dependencies:** + +- karma-mocha-reporter: v1.2.2 → [v1.2.3](https://github.com/litixsoft/karma-mocha-reporter/compare/v1.2.2...v1.2.3) - don't fail test suites containing skipped tests + +# 0.8.0 / 2016-02-26 + +**Breaking Changes:** + +- [`npm-install-webpack-plugin`](https://github.com/ericclemmons/npm-install-webpack-plugin) is now used instead of `npm-install-loader` to implement `nwb serve --auto-install`. + + If you were configuring automatic npm installation using a `loaders.install.query.cli` config object, this should be moved to `webpack.plugins.install` instead. + +**`nwb.config.js` Config Format Changes:** + +* React component and vanilla JS module npm build configuration must now be specificed as a `build` object: + + ```js + // < v0.9 + module.exports = { + type: 'react-component', + externals: {react: 'React'}, + global: 'MyComponent', + jsNext: true, + umd: true + } + ``` + ```js + // v0.9 + module.exports = { + type: 'react-component', + build: { + externals: {react: 'React'}, + global: 'MyComponent', + jsNext: true, + umd: true + } + } + ``` +* Webpack configuration must now be specified as a `webpack` object: + + ```js + // < v0.9 + module.exports = { + type: 'react-app', + loaders: { + css: { + query: { + modules: true + } + } + } + } + ``` + ```js + // v0.9 + module.exports = { + type: 'react-app', + webpack: { + loaders: { + css: { + query: { + modules: true + } + } + } + } + } + ``` +* Webpack `define` config must now be specified in a `plugins` object: + + ```js + // < v0.9 + module.exports = { + type: 'react-app', + define: { + __VERSION__: JSON.stringify(require('./package.json').version) + } + } + ``` + ```js + // v0.9 + module.exports = { + type: 'react-app', + webpack: { + plugins: { + define: { + __VERSION__: JSON.stringify(require('./package.json').version) + } + } + } + } + ``` +* All "extra" Webpack config must be specified in a an `extra` object, including extra loaders. The new object must correspond with Webpack's config file layout. + + ```js + // < v0.9 + module.exports = { + type: 'react-app', + loaders: { + extra: [/* ... */] + } + } + ``` + ```js + // v0.9 + module.exports = { + type: 'react-app', + webpack: { + extra: { + module: { + loaders: [/* ... */] + } + } + } + } + ``` + +**Changes:** + +- `nwb.config.js` is now only required when running generic build commands: `build`, `clean`, `serve`, `test` + - `type` config is only required when running a generic build command, but if provided it must be valid. +- Karma tests now always run just once in a CI environment regardless of the `--server` flag - this allows you to use `--server` in your default `npm test` command if you want to, without needing a separate run script for CI. +- Development instructions in project skeletons were moved from `README.md` to a `CONTRIBUTING.md` file, and are now documented using `npm` and `npm run` commands instead of global `nwb` commands. +- All commands are now run in the current working directory - you no longer need to `require.resolve()` full paths to extra Babel plugins configured in `nwb.config.js`, just use their names as normal and Babel will now be able to import them. +- Upgraded to PhantomJS v2 for Karma tests. + - Babel polyfills are no longer included in Webpack config for Karma, as PhantomJS v2 uses a more recent version of WebKit. + +**Added:** + +- Extra webpack config can now be configured via a `webpack.extra` Object. + - To support adding other webpack built-in plugins via `extra`, if a function is exported from `nwb.config.js`, it will now be called with an object containing the following properties: + - `command` - the nwb command being executed + - `webpack` - the webpack module (for configuring extra plugins using nwb's version of webpack) +- Project type-specific versions of the `build`, `clean` and `serve` commands are now officially documented for direct use. +- A `test:watch` npm script was added to project template `package.json`. + +**Dependencies:** + +- autoprefixer-loader: v3.1.0 → v3.2.0 +- cross-spawn: v2.1.4 → [v2.1.5](https://github.com/IndigoUnited/node-cross-spawn/compare/2.1.4...2.1.5) - update `which` dependency (minor) +- expect: v1.13.4 → [v1.14.0](https://github.com/mjackson/expect/blob/master/CHANGES.md#v1140) - new features +- express: v4.13.3 → v4.13.4 - deps +- extract-text-webpack-plugin: v0.9.1 → [v1.0.1](https://github.com/webpack/extract-text-webpack-plugin/compare/v0.9.1...v1.0.1) - use webpack-sources +- glob: v6.0.3 → v7.0.0 - throw if cwd is not a directory +- html-webpack-plugin: v1.7.0 → v2.9.0 +- inquirer: v0.11.2 → [v0.12.0](https://github.com/SBoudrias/Inquirer.js/compare/v0.11.2...v0.12.0) +- karma: v0.13.18 → v0.13.21 - socket.io 1.4.5 seems to have fixed the post-test hanging issue, [bug fixes and new features](https://github.com/karma-runner/karma/releases/tag/v0.13.20) +- karma-mocha: v0.2.1 → [v0.2.2](https://github.com/karma-runner/karma-mocha/compare/v0.2.1...v0.2.2) +- karma-mocha-reporter: v1.1.5 → [v1.2.2](https://github.com/litixsoft/karma-mocha-reporter/compare/v1.1.5...v1.2.2) - add diff output for failed tests +- karma-phantomjs-launcher: v0.2.3 → [v1.0.0](https://github.com/karma-runner/karma-phantomjs-launcher/blob/master/CHANGELOG.md#100-2016-01-28) - use phantomjs-prebuild +- mocha: v2.3.4 → [v2.4.5](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#245--2016-01-28) +- phantomjs v1.9.19 → phantomjs-prebuilt v2.1.4 - update installer to PhantomJS 2.x, renamed package +- qs: v5.2.0 → [v6.1.0](https://github.com/ljharb/qs/blob/master/CHANGELOG.md#610) - revert ES6 requirement, new `allowDots` option and some fixes +- react-transform-catch-errors: v1.0.1 → v1.0.2 - remove some files from the npm package +- react-transform-hmr: v1.0.1 → v1.0.2 - remove some files from the npm package +- resolve: v1.1.6 → [v1.1.7](https://github.com/browserify/resolve/compare/1.1.6...1.1.7) - fix `node_modules` paths on Windows +- rimraf: v2.5.0 → [v2.5.2](https://github.com/isaacs/rimraf/compare/v2.5.0...v2.5.2) +- webpack: v1.12.11 → [v1.12.14](https://github.com/webpack/webpack/compare/v1.12.11...v1.12.14) - fix Windows filename backslash incompatibility +- webpack-dev-middleware: v1.4.0 → [v1.5.1](https://github.com/webpack/webpack-dev-middleware/compare/v1.4.0...v1.5.1) - platform-agnostic path joining, use `res.send` when available +- webpack-hot-middleware: v2.6.0 → [v2.7.1](https://github.com/glenjamin/webpack-hot-middleware/compare/v2.6.0...v2.7.1) - improve hint when hot reloads aren't accepted, update `strip-ansi` dependency (major), update stats handling + +# 0.7.2 / 2016-01-15 + +**Fixed:** + +- `react-app` and `web-app` Webpack build config didn't have `output.publicPath` set, so images required from JavaScript weren't being found [[#55](https://github.com/insin/nwb/issues/55)] +- Test runs no longer hang for up to a minute after completion [[#49](https://github.com/insin/nwb/issues/49)] + +**Dependencies:** + +- inquirer: v0.11.1 → [v0.11.2](https://github.com/SBoudrias/Inquirer.js/releases/tag/v0.11.2) - display fixes +- karma: v0.13.19 → v0.13.18 - downgraded due to the test hanging issue being introduced +- karma-sourcemap-loader: v0.3.6 → v0.3.7 - avoid EMFILE errors; fix charset bug; fix RangeError exception +- socket.io: v1.3.7 - temporarily pinned in nwb's dependencies until the Karma test hang issue is resolved +- webpack: v1.12.10 → [v1.12.11](https://github.com/webpack/webpack/compare/v1.12.10...v1.12.11) +- webpack-merge: v0.7.2 → v0.7.3 - bugfix + +# 0.7.1 / 2016-01-10 + +**Fixed:** + +- Express middleware had a broken import. + +**Added:** + +- Added an `autoInstall` option to Express middleware. + +**Dependencies:** + +- glob: v6.0.3 → v6.0.4 - remove `util._extend` to avoid deprecation warnings +- karma: v0.13.18 → [v0.13.19](https://github.com/karma-runner/karma/releases/tag/v0.13.19) - handle new socket.io internal format +- webpack: v1.12.9 → [v1.12.10](https://github.com/webpack/webpack/compare/v1.12.9...v1.12.10) +- webpack-merge: v0.7.1 → v0.7.2 - fix inclusion of removed `changelog` dependency + +# 0.7.0 / 2016-01-05 + +**Fixed:** + +- Fall back to nwb's dependencies in Webpack config instead of using an alias so `babel-runtime` can be picked up when `optional: ['runtime']` is used [hopefully fixing the weird `/node_modules/node_modules/` issue seen in [[#37](https://github.com/insin/nwb/issues/37)] + +**Added:** + +- Added an `--auto-install` flag to `nwb serve` which automatically installs npm dependencies and saves them to your package.json while developing. + +**Removed:** + +- `jsNext` config no longer defaults to `true` if not present. + +**Changed:** + +- Use `.x` for dependencies when generating skeleton project `package.json` instead of range sigils. + +**Dependencies:** + +- babel-runtime: v5.8.34 → v5.8.29 - downgraded due to a regression in typeof-react-element.js when used in conjunction with `optional: ['runtime']` +- karma: v0.13.16 → [v0.13.18](https://github.com/karma-runner/karma/releases/tag/v0.13.18) +- karma-phantomjs-launcher: v0.2.2 → v0.2.3 - correct cli argument order +- webpack-merge: v0.7.0 → v0.7.1 - performance improvements + +# 0.6.4 / 2016-01-02 + +**Fixed:** + +- `nwb build-umd` no longer errors if there is no `externals` config. + +**Changed:** + +- `nwb clean` now deletes the `coverage/` directory. + +**Dependencies:** + +- inquirer: v0.11.0 → [v0.11.1](https://github.com/SBoudrias/Inquirer.js/releases/tag/v0.11.1) - fix list overflow bug + +# 0.6.3 / 2015-12-31 + +**Fixed:** + +- Exit the process correctly with a non-zero exit code when an async command fails, such as `nwb test` [[#36](https://github.com/insin/nwb/pull/36)] [[jihchi][jihchi]] + +**Dependencies:** + +- karma-mocha-reporter: v1.1.4 → v1.1.5 - show error message when karma runner ends with error +- webpack-merge: v0.5.1 → v0.7.0 - bug fix for merging arrays within nested structures + +# 0.6.2 / 2015-12-30 + +**Dependencies:** + +- argv-set-env: v1.0.0 → [v1.0.1](https://github.com/kentcdodds/argv-set-env/releases/tag/v1.0.1) - docs +- glob: v6.0.1 → v6.0.3 - v6.0.2 was reverted +- karma: v0.13.15 → [v0.13.16](https://github.com/karma-runner/karma/releases/tag/v0.13.16) +- karma-mocha-reporter: v1.1.3 → v1.1.4 - handle duplicate descriptions +- karma-phantomjs-launcher: v0.2.1 → v0.2.2 +- react-transform-catch-errors: v1.0.0 → [v1.0.1](https://github.com/gaearon/react-transform-catch-errors/releases/tag/v1.0.1) - display the offending call stack more prominently +- rimraf: v2.4.5 → v2.5.0 - add glob option +- webpack-merge: v0.3.2 → v0.5.1 - fix recursive merging + +# 0.6.1 / 2015-12-30 + +**Fixed:** + +- The `es6/` directory wasn't included in the default `.gitignore` for npm module project skeletons. + +# 0.6.0 / 2015-12-23 + +**Added:** + +- Added an `nwb init` command - same as `nwb new` but creates a project in the current directory and uses the directory name by default [[#25](https://github.com/insin/nwb/issues/25)] +- Added a new `web-app` project type - this is for anyone who wants to use nwb's build/serve/test setup but isn't using React [[#24](https://github.com/insin/nwb/issues/24)] +- Added a `--reload` option to auto-reload the page when webpack hot module replacement gets stuck. This is primarily intended for use with the new `web-app` project type. +- Command-line arguments can now be used to configure settings for `nwb new`. + +**Fixed:** + +- Production optimisations weren't being applied to React app builds. +- Demo apps weren't generating sourcemaps when bundling. +- Use a non-zero exit code when displaying usage or otherwise exiting due to missing arguments [[#23](https://github.com/insin/nwb/issues/23)] + +**Changed:** + +- Reorganised and coloured `nwb help` output. +- Commands which create files now log details of what they've created [[#26](https://github.com/insin/nwb/issues/26)] +- The ES6 modules build for npm modules is now optional, controlled by a `jsNext` setting in `nwb.config.js`, defaulting to `true` [[#27](https://github.com/insin/nwb/issues/27)] + - nwb 0.6 will default `jsNext` to `true` and log a warning when it's missing from a config file - this behaviour will be removed in nwb v0.7. + +**Dependencies:** + +- copy-template-dir: v1.1.0 → v1.2.0 - provide created file paths in callback +- css-loader: v0.23.0 → v0.23.1 +- expect: v1.13.3 → v1.13.4 - comparing arrays of nested objects fix +- rimraf: v2.4.4 → v2.4.5 + +# 0.5.0 / 2015-12-15 + +**Added:** + +- Top-level Webpack config can now be provided for loaders which support it, as a `config` object in their `nwb.config.js` `loaders` configuration. This is intended for loaders which can't use serialisable `query` config due to plugins, such as some CSS preprocessors [[#18](https://github.com/insin/nwb/issues/18)] + +**Fixed:** + +- `files` config from template `package.json` was being used when packing nwb for publishing. Renamed them to `_package.json` to avoid this [[#22](https://github.com/insin/nwb/issues/22)] + +**Changed:** + +- Downgraded qs dependency so nwb can be used with Node.js 0.12.x [[#19](https://github.com/insin/nwb/issues/19)] + +**Dependencies:** + +- copy-template-dir: v1.0.5 → v1.1.0 - rename all files beginning with `_` +- expect: v1.13.0 → v1.13.3 - `Map`, `Set` and circular comparison fixes +- qs: v6.0.0 → v5.2.0 - downgrade to lose Node.js >= 4.0.0 requirement + +# 0.4.1 / 2015-12-13 + +**Fixed:** + +- Bad npm package for 0.4.0 - npm was reading the new `files` config from `package.json` in templates for React component/web module skeletons and applying it when packing nwb itself for publishing [[#21](https://github.com/insin/nwb/issues/21)] + +# 0.4.0 / 2015-12-11 + +**Added:** + +- Added `--fallback` option to `nwb serve`, for serving the index page from any path when developing React apps which use the HTML5 History API [[#16](https://github.com/insin/nwb/issues/16)] +- Added `"engines": {"node": ">=4.0.0"}` to `package.json` - nwb accidentally depends on this because it uses [qs](https://github.com/hapijs/qs) v6 [[#19](https://github.com/insin/nwb/issues/19)] +- Added `files` config to React component/web module skeleton `package.json`. + - The `files` config for the React component skeleton assumes that components published to npm with `require()` calls for CSS which ships with it will use a `css/` dir. +- Added a default ES6 build with untranspiled ES6 module usage [[#15](https://github.com/insin/nwb/issues/15)] + - This is pointed to by `"jsnext:main"` in project skeleton `package.json` for use by tree-shaking ES6 bundlers. + +**Fixed:** + +- Added missing `main` config to React component/web module skeleton `package.json`, pointing at the ES5 build in `lib/`. +- Express middleware wasn't included in npm package. + +**Changed:** + +- 1.0.0 is now the default version for project skeletons. + +# 0.3.1 / 2015-12-09 + +**Fixed:** + +- Generic `nwb build` was broken for React components/web modules in 0.3.0. + +# 0.3.0 / 2015-12-07 + +**Added:** + +- Support for CSS preprocessor plugin packages [[#6](https://github.com/insin/nwb/issues/6)] + - Loading of configuration objects exported by `'nwb-*'` dependencies found in `package.json`. + - Creation of style loading pipelines for plugins which provide `cssPreprocessors` configuration. + - [nwb-less](https://github.com/insin/nwb-less) + - [nwb-sass](https://github.com/insin/nwb-sass) + +**Fixed:** + +- Babel config is now passed to Babel when transpiling modules [[#13](https://github.com/insin/nwb/issues/13)] + +# 0.2.0 / 2015-12-05 + +**Added:** + +- Express [middleware](https://github.com/insin/nwb/blob/master/docs/Middleware.md#middleware) for running a React app on your own development server using nwb's Webpack config generation [[#8](https://github.com/insin/nwb/issues/8)] + +**Changed:** + +- Webpack loader config objects are now merged with [webpack-merge](https://github.com/survivejs/webpack-merge); query objects will now be deep merged, with lists occurring at the same position in build and user config being concatenated instead of overwritten. + +**Fixed:** + +- babel-runtime can now be resolved from nwb's dependencies when using `optional: ['runtime']` Babel config [[#10](https://github.com/insin/nwb/issues/10)] +- Paths to resources required from CSS in React app builds [[#9](https://github.com/insin/nwb/issues/9)] + +# 0.1.0 / 2015-12-02 + +First 0.x release. + +[balazs4]: https://github.com/balazs4 +[bwendt-mylo]: https://github.com/bwendt-mylo +[DethAriel]: https://github.com/DethAriel +[grahamlyus]: https://github.com/grahamlyus +[hanford]: https://github.com/hanford +[jihchi]: https://github.com/jihchi +[michaelsbradleyjr]: https://github.com/michaelsbradleyjr +[ngyikp]: https://github.com/ngyikp +[ntwcklng]: https://github.com/ntwcklng +[seanofw]: https://github.com/seanofw +[stephenwf]: https://github.com/stephenwf +[totaldis]: https://github.com/totaldis +[treshugart]: https://github.com/treshugart From 2f71b69dcbf67e29cfd4397c1c394de55f4f1578 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Wed, 20 May 2020 09:44:07 +1000 Subject: [PATCH 62/66] Update dependencies --- CHANGES.md | 3 ++- package.json | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 9f649527..7f48f7e8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -43,11 +43,12 @@ ## Dependencies +- autoprefixer: v9.7.6 → [v9.8.0](https://github.com/postcss/autoprefixer/blob/master/CHANGELOG.md#980) - chalk: v3.0.0 → [v4.0.0](https://github.com/chalk/chalk/releases/tag/v4.0.0) - copy-webpack-plugin: v5.1.1 → [v6.0.1](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md#601-2020-05-16) - file-loader: v4.3.0 → [v6.0.0](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md#600-2020-03-17) - fs-extra: v8.1.0 → [v9.0.0](https://github.com/jprichardson/node-fs-extra/blob/master/CHANGELOG.md#900--2020-03-19) -- karma: v4.4.1 → [v5.0.7](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md#507-2020-05-16) +- karma: v4.4.1 → [v5.0.9](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md#509-2020-05-19) - karma-mocha: v1.3.0 → [v2.0.1](https://github.com/karma-runner/karma-mocha/blob/master/CHANGELOG.md#201-2020-04-29) - terser-webpack-plugin v2.3.6 → [v3.0.1](https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/CHANGELOG.md#301-2020-05-06) - url-loader: v2.3.0→ [v4.1.0](https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md) diff --git a/package.json b/package.json index acc5324f..647e7659 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "babel-preset-proposals": "0.3.0", "react-refresh": "0.8.2", - "karma": "5.0.7", + "karma": "5.0.9", "karma-chrome-launcher": "3.1.0", "karma-coverage": "2.0.2", "karma-mocha": "2.0.1", @@ -83,7 +83,7 @@ "expect": "1.20.2", "webpack": "4.43.0", - "autoprefixer": "9.7.6", + "autoprefixer": "9.8.0", "babel-loader": "8.1.0", "case-sensitive-paths-webpack-plugin": "2.3.0", "copy-webpack-plugin": "6.0.1", @@ -109,7 +109,7 @@ "cross-env": "7.0.2", "eslint-config-jonnybuchanan": "6.0.0", "eventsource": "1.0.7", - "flow-bin": "0.124.0", + "flow-bin": "0.125.1", "glob": "7.1.6", "nyc": "15.0.1", "rimraf": "3.0.2", From 7b50e35cb40a3afb39471cb8f924e0f593e7c704 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Wed, 20 May 2020 09:48:07 +1000 Subject: [PATCH 63/66] Release v0.25.0 --- CHANGES.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7f48f7e8..cf2bc318 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,4 @@ -# `next` branch +# 0.25.0 / 2020-05-20 ## Breaking Changes diff --git a/package.json b/package.json index 647e7659..9bb79bf9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nwb", "description": "A toolkit for React, Preact & Inferno apps, React libraries and other npm modules for the web, with no configuration (until you need it)", - "version": "0.24.7", + "version": "0.25.0", "license": "MIT", "author": "Jonny Buchanan <jonathan.buchanan@gmail.com>", "bin": { From afe6dd12c2f6c2b8eabcc442a89c7179257eb0b2 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Wed, 20 May 2020 09:55:55 +1000 Subject: [PATCH 64/66] Release v0.25.1 --- CHANGES.md | 6 ++++++ package.json | 6 ++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index cf2bc318..b6cb58a1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +# 0.25.1 / 2020-05-20 + +## Changed + +- Don't include `docs/` in the npm package. + # 0.25.0 / 2020-05-20 ## Breaking Changes diff --git a/package.json b/package.json index 9bb79bf9..046d55ec 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nwb", "description": "A toolkit for React, Preact & Inferno apps, React libraries and other npm modules for the web, with no configuration (until you need it)", - "version": "0.25.0", + "version": "0.25.1", "license": "MIT", "author": "Jonny Buchanan <jonathan.buchanan@gmail.com>", "bin": { @@ -19,11 +19,9 @@ "test:watch": "cross-env NODE_ENV=test NWB_TEST=true mocha --require @babel/register --watch tests/*-test.js" }, "files": [ - "docs", "lib", "templates", - "express.js", - "polyfills.js" + "express.js" ], "engines": { "node": ">=10.13.0" From 24f77a3151d97bc0f6f0970228596cd1928c86e0 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Wed, 20 May 2020 10:10:33 +1000 Subject: [PATCH 65/66] Bump Node.js version in templates --- CHANGES.md | 4 ++++ templates/inferno-app/CONTRIBUTING.md | 2 +- templates/inferno-app/_.travis.yml | 2 +- templates/preact-app/CONTRIBUTING.md | 2 +- templates/preact-app/_.travis.yml | 2 +- templates/react-app/CONTRIBUTING.md | 2 +- templates/react-app/_.travis.yml | 2 +- templates/react-component/CONTRIBUTING.md | 2 +- templates/react-component/_.travis.yml | 2 +- templates/web-app/CONTRIBUTING.md | 2 +- templates/web-app/_.travis.yml | 2 +- templates/web-module/CONTRIBUTING.md | 2 +- templates/web-module/_.travis.yml | 2 +- 13 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b6cb58a1..b62b3e19 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +## Fixed + +- Bumped Node.js version in templates. + # 0.25.1 / 2020-05-20 ## Changed diff --git a/templates/inferno-app/CONTRIBUTING.md b/templates/inferno-app/CONTRIBUTING.md index c259e6ce..8692e11e 100644 --- a/templates/inferno-app/CONTRIBUTING.md +++ b/templates/inferno-app/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Prerequisites -[Node.js](http://nodejs.org/) >= 8 must be installed. +[Node.js](http://nodejs.org/) >= 10 must be installed. ## Installation diff --git a/templates/inferno-app/_.travis.yml b/templates/inferno-app/_.travis.yml index 06e30d93..d78794cc 100644 --- a/templates/inferno-app/_.travis.yml +++ b/templates/inferno-app/_.travis.yml @@ -2,7 +2,7 @@ sudo: false language: node_js node_js: - - 8 + - 10 before_install: - npm install codecov.io coveralls diff --git a/templates/preact-app/CONTRIBUTING.md b/templates/preact-app/CONTRIBUTING.md index c259e6ce..8692e11e 100644 --- a/templates/preact-app/CONTRIBUTING.md +++ b/templates/preact-app/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Prerequisites -[Node.js](http://nodejs.org/) >= 8 must be installed. +[Node.js](http://nodejs.org/) >= 10 must be installed. ## Installation diff --git a/templates/preact-app/_.travis.yml b/templates/preact-app/_.travis.yml index 06e30d93..d78794cc 100644 --- a/templates/preact-app/_.travis.yml +++ b/templates/preact-app/_.travis.yml @@ -2,7 +2,7 @@ sudo: false language: node_js node_js: - - 8 + - 10 before_install: - npm install codecov.io coveralls diff --git a/templates/react-app/CONTRIBUTING.md b/templates/react-app/CONTRIBUTING.md index c259e6ce..8692e11e 100644 --- a/templates/react-app/CONTRIBUTING.md +++ b/templates/react-app/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Prerequisites -[Node.js](http://nodejs.org/) >= 8 must be installed. +[Node.js](http://nodejs.org/) >= 10 must be installed. ## Installation diff --git a/templates/react-app/_.travis.yml b/templates/react-app/_.travis.yml index 06e30d93..d78794cc 100644 --- a/templates/react-app/_.travis.yml +++ b/templates/react-app/_.travis.yml @@ -2,7 +2,7 @@ sudo: false language: node_js node_js: - - 8 + - 10 before_install: - npm install codecov.io coveralls diff --git a/templates/react-component/CONTRIBUTING.md b/templates/react-component/CONTRIBUTING.md index 4868f267..2ba7b9f4 100644 --- a/templates/react-component/CONTRIBUTING.md +++ b/templates/react-component/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Prerequisites -[Node.js](http://nodejs.org/) >= 8 must be installed. +[Node.js](http://nodejs.org/) >= 10 must be installed. ## Installation diff --git a/templates/react-component/_.travis.yml b/templates/react-component/_.travis.yml index 06e30d93..d78794cc 100644 --- a/templates/react-component/_.travis.yml +++ b/templates/react-component/_.travis.yml @@ -2,7 +2,7 @@ sudo: false language: node_js node_js: - - 8 + - 10 before_install: - npm install codecov.io coveralls diff --git a/templates/web-app/CONTRIBUTING.md b/templates/web-app/CONTRIBUTING.md index 9dc3f4d7..ef05a30c 100644 --- a/templates/web-app/CONTRIBUTING.md +++ b/templates/web-app/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Prerequisites -[Node.js](http://nodejs.org/) >= 8 must be installed. +[Node.js](http://nodejs.org/) >= 10 must be installed. ## Installation diff --git a/templates/web-app/_.travis.yml b/templates/web-app/_.travis.yml index 06e30d93..d78794cc 100644 --- a/templates/web-app/_.travis.yml +++ b/templates/web-app/_.travis.yml @@ -2,7 +2,7 @@ sudo: false language: node_js node_js: - - 8 + - 10 before_install: - npm install codecov.io coveralls diff --git a/templates/web-module/CONTRIBUTING.md b/templates/web-module/CONTRIBUTING.md index 64011920..570873bc 100644 --- a/templates/web-module/CONTRIBUTING.md +++ b/templates/web-module/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Prerequisites -[Node.js](http://nodejs.org/) >= 8 must be installed. +[Node.js](http://nodejs.org/) >= 10 must be installed. ## Installation diff --git a/templates/web-module/_.travis.yml b/templates/web-module/_.travis.yml index 06e30d93..d78794cc 100644 --- a/templates/web-module/_.travis.yml +++ b/templates/web-module/_.travis.yml @@ -2,7 +2,7 @@ sudo: false language: node_js node_js: - - 8 + - 10 before_install: - npm install codecov.io coveralls From 89633429aebaa297b7a770229f1530a40c610892 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Wed, 20 May 2020 10:10:42 +1000 Subject: [PATCH 66/66] Release v0.25.2 --- CHANGES.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index b62b3e19..37feb72c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,5 @@ +# 0.25.2 / 2020-05-20 + ## Fixed - Bumped Node.js version in templates. diff --git a/package.json b/package.json index 046d55ec..c9abd67b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nwb", "description": "A toolkit for React, Preact & Inferno apps, React libraries and other npm modules for the web, with no configuration (until you need it)", - "version": "0.25.1", + "version": "0.25.2", "license": "MIT", "author": "Jonny Buchanan <jonathan.buchanan@gmail.com>", "bin": {