From bf053188e46e2e8e02dd29c5e9cb1413aeb4f82a Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Sat, 14 Mar 2020 01:46:54 +1000 Subject: [PATCH] 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 `
` 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 `` - 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,