Skip to content

Commit

Permalink
Move polyfills.js into react-dev-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
ForbesLindesay committed Jun 1, 2017
1 parent e91648a commit d99c14f
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 10 deletions.
8 changes: 8 additions & 0 deletions packages/react-dev-utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,11 @@ module.exports = {
// ...
}
```

#### polyfills

The polyfills files can be included in order to add polyfills for:

- `Promise` (including automated rejection tracking)
- `fetch`
- `Object.assign`
6 changes: 5 additions & 1 deletion packages/react-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"ModuleScopePlugin.js",
"openBrowser.js",
"openChrome.applescript",
"polyfills.js",
"printHostingInstructions.js",
"WatchMissingNodeModulesPlugin.js",
"WebpackDevServerUtils.js",
Expand All @@ -44,11 +45,14 @@
"gzip-size": "3.0.0",
"html-entities": "1.2.1",
"inquirer": "3.0.6",
"object-assign": "4.1.1",
"opn": "5.0.0",
"promise": "7.1.1",
"recursive-readdir": "2.2.1",
"shell-quote": "1.6.1",
"sockjs-client": "1.1.4",
"strip-ansi": "3.0.1",
"text-table": "0.2.0"
"text-table": "0.2.0",
"whatwg-fetch": "2.0.3"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @remove-on-eject-begin
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
Expand All @@ -7,7 +6,7 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
// @remove-on-eject-end

'use strict';

if (typeof Promise === 'undefined') {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-scripts/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = {
// require.resolve('webpack/hot/dev-server'),
require.resolve('react-dev-utils/webpackHotDevClient'),
// We ship a few polyfills by default:
require.resolve('./polyfills'),
require.resolve('react-dev-utils/polyfills'),
// Errors should be considered fatal in development
require.resolve('react-error-overlay'),
// Finally, this is your app's code:
Expand Down
2 changes: 1 addition & 1 deletion packages/react-scripts/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ module.exports = {
// You can exclude the *.map files from the build during deployment.
devtool: 'source-map',
// In production, we only want to load the polyfills and the app code.
entry: [require.resolve('./polyfills'), paths.appIndexJs],
entry: [require.resolve('react-dev-utils/polyfills'), paths.appIndexJs],
output: {
// The build folder.
path: paths.appBuild,
Expand Down
5 changes: 1 addition & 4 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,16 @@
"fs-extra": "3.0.1",
"html-webpack-plugin": "2.28.0",
"jest": "20.0.3",
"object-assign": "4.1.1",
"postcss-flexbugs-fixes": "3.0.0",
"postcss-loader": "2.0.5",
"promise": "7.1.1",
"react-dev-utils": "^3.0.0",
"react-error-overlay": "^1.0.7",
"style-loader": "0.17.0",
"sw-precache-webpack-plugin": "0.9.1",
"url-loader": "0.5.8",
"webpack": "2.6.1",
"webpack-dev-server": "2.4.5",
"webpack-manifest-plugin": "1.1.0",
"whatwg-fetch": "2.0.3"
"webpack-manifest-plugin": "1.1.0"
},
"devDependencies": {
"react": "^15.5.4",
Expand Down
6 changes: 5 additions & 1 deletion packages/react-scripts/scripts/utils/createJestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ module.exports = (resolve, rootDir, isEjecting) => {
// in Jest configs. We need help from somebody with Windows to determine this.
const config = {
collectCoverageFrom: ['src/**/*.{js,jsx}'],
setupFiles: [resolve('config/polyfills.js')],
setupFiles: [
isEjecting
? '<rootDir>/node_modules/react-dev-utils/polyfills.js'
: require.resolve('react-dev-utils/polyfills.js'),
],
setupTestFrameworkScriptFile: setupTestsFile,
testMatch: [
'<rootDir>/src/**/__tests__/**/*.js?(x)',
Expand Down

0 comments on commit d99c14f

Please sign in to comment.