Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new script to generate bundle-stats.json. #3928

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
99b51b6
Use uglifyjs-webpack-plugin v1 (#3618)
viankakrisna Jan 11, 2018
c36414e
Specify ecma version (#3743)
Timer Jan 11, 2018
113b722
Move browsers to cross-tool config (#3644)
ai Jan 9, 2018
9cbe4bf
add experimental babel-plugin-macros support (#3675)
Jan 9, 2018
a50a5a9
Redisable require.ensure() (#3121)
everdimension Jan 10, 2018
b6286b3
Remove the navigateFallback behavior from the generated service worke…
jeffposnick Jan 10, 2018
0dbf119
Change the default `start_url` to `.` (#3346)
foochu Jan 10, 2018
f4844c9
Update jest to 22 and support watchPathIgnorePatterns configuration (…
aisensiy Jan 11, 2018
4272518
Bump Jest to 22.0.6 (#3751)
gaearon Jan 11, 2018
8eec24d
Switch to Babel 7 (#3522)
clemmy Jan 11, 2018
96a2d91
wip
gaearon Jan 12, 2018
70421f8
Fix the build
gaearon Jan 12, 2018
3112fd2
Update appveyor.cleanup-cache.txt
gaearon Jan 12, 2018
0ead30a
Fix windows build
gaearon Jan 12, 2018
995de8a
Bump eslint-plugin-jsx-a11y version (#2690)
gaearon Jan 12, 2018
2573f1a
Enable `getter-return` rule as a warning (#3723)
chrislaughlin Jan 13, 2018
d869461
Loosen Babel preset to use browserslist (#3770)
Timer Jan 13, 2018
0d7d192
Add preflight check to guard against wrong versions of webpack/eslint…
gaearon Jan 13, 2018
074c694
Compile dependencies with babel-preset-env (#3776)
gaearon Jan 13, 2018
dc61df6
Compile code in parallel (#3778)
Timer Jan 13, 2018
4ab4ae4
Add restricted globals package (#2286)
sidoshi Jan 14, 2018
e7a7a6f
Allow parsing of ecma 8
Timer Jan 14, 2018
75f8e7d
Bump dependencies (#3785)
gaearon Jan 14, 2018
cf78ade
Create bundle stats with new build script
joshwcomeau Jan 23, 2018
3099ec7
Add docs, fix some quirks
joshwcomeau Jan 28, 2018
c2d8e1f
Undo whitespace changes
joshwcomeau Jan 28, 2018
e091d64
Fix caret
joshwcomeau Jan 28, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions appveyor.cleanup-cache.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ Edit this file to trigger a cache rebuild.
http://help.appveyor.com/discussions/questions/1310-delete-cache

----
Just testing if this works.
lalala.
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@
"packages/*"
],
"scripts": {
"build": "cd packages/react-scripts && node scripts/build.js",
"build": "cd packages/react-scripts && node bin/react-scripts.js build",
"build:with-stats":
"cd packages/react-scripts && node scripts/build.js --stats",
"changelog": "lerna-changelog",
"create-react-app": "node tasks/cra.js",
"e2e": "tasks/e2e-simple.sh",
"e2e:docker": "tasks/local-test.sh",
"postinstall": "cd packages/react-error-overlay/ && yarn build:prod",
"publish": "tasks/publish.sh",
"start": "cd packages/react-scripts && node scripts/start.js",
"start": "cd packages/react-scripts && node bin/react-scripts.js start",
"screencast": "svg-term --cast hItN7sl5yfCPTHxvFg5glhhfp --out screencast.svg --window",
"test": "cd packages/react-scripts && node scripts/test.js --env=jsdom",
"test": "cd packages/react-scripts && node bin/react-scripts.js test --env=jsdom",
"format": "prettier --trailing-comma es5 --single-quote --write 'packages/*/*.js' 'packages/*/!(node_modules)/**/*.js'",
"precommit": "lint-staged"
},
"devDependencies": {
"eslint": "^4.4.1",
"eslint": "4.15.0",
"husky": "^0.13.2",
"lerna": "2.6.0",
"lerna-changelog": "^0.6.0",
Expand Down
57 changes: 57 additions & 0 deletions packages/babel-preset-react-app/dependencies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';

module.exports = function(api, opts) {
if (!opts) {
opts = {};
}

// This is similar to how `env` works in Babel:
// https://babeljs.io/docs/usage/babelrc/#env-option
// We are not using `env` because it’s ignored in versions > [email protected]:
// https://github.com/babel/babel/issues/4539
// https://github.com/facebookincubator/create-react-app/issues/720
// It’s also nice that we can enforce `NODE_ENV` being specified.
var env = process.env.BABEL_ENV || process.env.NODE_ENV;
var isEnvDevelopment = env === 'development';
var isEnvProduction = env === 'production';
var isEnvTest = env === 'test';
if (!isEnvDevelopment && !isEnvProduction && !isEnvTest) {
throw new Error(
'Using `babel-preset-react-app` requires that you specify `NODE_ENV` or ' +
'`BABEL_ENV` environment variables. Valid values are "development", ' +
'"test", and "production". Instead, received: ' +
JSON.stringify(env) +
'.'
);
}

return {
presets: [
isEnvTest && [
// ES features necessary for user's Node version
require('@babel/preset-env').default,
{
targets: {
node: 'current',
},
// Do not transform modules to CJS
modules: false,
},
],
(isEnvProduction || isEnvDevelopment) && [
// Latest stable ECMAScript features
require('@babel/preset-env').default,
{
// Do not transform modules to CJS
modules: false,
},
],
].filter(Boolean),
};
};
193 changes: 86 additions & 107 deletions packages/babel-preset-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,131 +6,110 @@
*/
'use strict';

const plugins = [
// class { handleClick = () => { } }
require.resolve('babel-plugin-transform-class-properties'),
// The following two plugins use Object.assign directly, instead of Babel's
// extends helper. Note that this assumes `Object.assign` is available.
// { ...todo, completed: true }
[
require.resolve('babel-plugin-transform-object-rest-spread'),
{
useBuiltIns: true,
},
],
// Transforms JSX
[
require.resolve('babel-plugin-transform-react-jsx'),
{
useBuiltIns: true,
},
],
// Polyfills the runtime needed for async/await and generators
[
require.resolve('babel-plugin-transform-runtime'),
{
helpers: false,
polyfill: false,
regenerator: true,
},
],
];

// This is similar to how `env` works in Babel:
// https://babeljs.io/docs/usage/babelrc/#env-option
// We are not using `env` because it’s ignored in versions > [email protected]:
// https://github.com/babel/babel/issues/4539
// https://github.com/facebookincubator/create-react-app/issues/720
// It’s also nice that we can enforce `NODE_ENV` being specified.
var env = process.env.BABEL_ENV || process.env.NODE_ENV;
if (env !== 'development' && env !== 'test' && env !== 'production') {
throw new Error(
'Using `babel-preset-react-app` requires that you specify `NODE_ENV` or ' +
'`BABEL_ENV` environment variables. Valid values are "development", ' +
'"test", and "production". Instead, received: ' +
JSON.stringify(env) +
'.'
);
}
module.exports = function(api, opts) {
if (!opts) {
opts = {};
}

if (env === 'development' || env === 'test') {
// The following two plugins are currently necessary to make React warnings
// include more valuable information. They are included here because they are
// currently not enabled in babel-preset-react. See the below threads for more info:
// https://github.com/babel/babel/issues/4702
// https://github.com/babel/babel/pull/3540#issuecomment-228673661
// https://github.com/facebookincubator/create-react-app/issues/989
plugins.push.apply(plugins, [
// Adds component stack to warning messages
require.resolve('babel-plugin-transform-react-jsx-source'),
// Adds __self attribute to JSX which React will use for some warnings
require.resolve('babel-plugin-transform-react-jsx-self'),
]);
}
// This is similar to how `env` works in Babel:
// https://babeljs.io/docs/usage/babelrc/#env-option
// We are not using `env` because it’s ignored in versions > [email protected]:
// https://github.com/babel/babel/issues/4539
// https://github.com/facebookincubator/create-react-app/issues/720
// It’s also nice that we can enforce `NODE_ENV` being specified.
var env = process.env.BABEL_ENV || process.env.NODE_ENV;
var isEnvDevelopment = env === 'development';
var isEnvProduction = env === 'production';
var isEnvTest = env === 'test';
if (!isEnvDevelopment && !isEnvProduction && !isEnvTest) {
throw new Error(
'Using `babel-preset-react-app` requires that you specify `NODE_ENV` or ' +
'`BABEL_ENV` environment variables. Valid values are "development", ' +
'"test", and "production". Instead, received: ' +
JSON.stringify(env) +
'.'
);
}

if (env === 'test') {
module.exports = {
return {
presets: [
// ES features necessary for user's Node version
[
require('babel-preset-env').default,
isEnvTest && [
// ES features necessary for user's Node version
require('@babel/preset-env').default,
{
targets: {
node: 'current',
},
},
],
// JSX, Flow
require.resolve('babel-preset-react'),
],
plugins: plugins.concat([
// Compiles import() to a deferred require()
require.resolve('babel-plugin-dynamic-import-node'),
]),
};
} else {
module.exports = {
presets: [
// Latest stable ECMAScript features
[
require.resolve('babel-preset-env'),
(isEnvProduction || isEnvDevelopment) && [
// Latest stable ECMAScript features
require('@babel/preset-env').default,
{
targets: {
// React parses on ie 9, so we should too
ie: 9,
// We currently minify with uglify
// Remove after https://github.com/mishoo/UglifyJS2/issues/448
uglify: true,
},
// Disable polyfill transforms
useBuiltIns: false,
// `entry` transforms `@babel/polyfill` into individual requires for
// the targeted browsers. This is safer than `usage` which performs
// static code analysis to determine what's required.
// This is probably a fine default to help trim down bundles when
// end-users inevitably import '@babel/polyfill'.
useBuiltIns: 'entry',
// Do not transform modules to CJS
modules: false,
},
],
// JSX, Flow
require.resolve('babel-preset-react'),
],
plugins: plugins.concat([
// function* () { yield 42; yield 43; }
[
require.resolve('babel-plugin-transform-regenerator'),
require('@babel/preset-react').default,
{
// Adds component stack to warning messages
// Adds __self attribute to JSX which React will use for some warnings
development: isEnvDevelopment || isEnvTest,
},
],
[require('@babel/preset-flow').default],
].filter(Boolean),
plugins: [
// Experimental macros support. Will be documented after it's had some time
// in the wild.
require('babel-plugin-macros'),
// class { handleClick = () => { } }
require('@babel/plugin-proposal-class-properties').default,
// The following two plugins use Object.assign directly, instead of Babel's
// extends helper. Note that this assumes `Object.assign` is available.
// { ...todo, completed: true }
[
require('@babel/plugin-proposal-object-rest-spread').default,
{
// Async functions are converted to generators by babel-preset-env
useBuiltIns: true,
},
],
// Transforms JSX
[
require('@babel/plugin-transform-react-jsx').default,
{
useBuiltIns: true,
},
],
// Polyfills the runtime needed for async/await and generators
[
require('@babel/plugin-transform-runtime').default,
{
helpers: false,
polyfill: false,
regenerator: true,
},
],
// function* () { yield 42; yield 43; }
!isEnvTest && [
require('@babel/plugin-transform-regenerator').default,
{
// Async functions are converted to generators by @babel/preset-env
async: false,
},
],
// Adds syntax support for import()
require.resolve('babel-plugin-syntax-dynamic-import'),
]),
require('@babel/plugin-syntax-dynamic-import').default,
isEnvTest &&
// Transform dynamic import to require
require('babel-plugin-transform-dynamic-import').default,
].filter(Boolean),
};

if (env === 'production') {
// Optimization: hoist JSX that never changes out of render()
// Disabled because of issues: https://github.com/facebookincubator/create-react-app/issues/553
// TODO: Enable again when these issues are resolved.
// plugins.push.apply(plugins, [
// require.resolve('babel-plugin-transform-react-constant-elements')
// ]);
}
}
};
32 changes: 16 additions & 16 deletions packages/babel-preset-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
"url": "https://github.com/facebookincubator/create-react-app/issues"
},
"files": [
"index.js"
"index.js",
"dependencies.js"
],
"dependencies": {
"babel-plugin-dynamic-import-node": "1.1.0",
"babel-plugin-syntax-dynamic-import": "6.18.0",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-plugin-transform-object-rest-spread": "6.26.0",
"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-regenerator": "6.26.0",
"babel-plugin-transform-runtime": "6.23.0",
"babel-preset-env": "1.6.1",
"babel-preset-react": "6.24.1"
},
"peerDependencies": {
"babel-runtime": "^6.23.0"
"@babel/core": "7.0.0-beta.37",
"@babel/plugin-proposal-class-properties": "7.0.0-beta.37",
"@babel/plugin-syntax-dynamic-import": "^7.0.0-beta.37",
"@babel/plugin-transform-classes": "7.0.0-beta.37",
"@babel/plugin-transform-react-constant-elements": "7.0.0-beta.37",
"@babel/plugin-transform-react-display-name": "7.0.0-beta.37",
"@babel/plugin-transform-react-jsx": "7.0.0-beta.37",
"@babel/plugin-transform-regenerator": "7.0.0-beta.37",
"@babel/plugin-transform-runtime": "7.0.0-beta.37",
"@babel/preset-env": "7.0.0-beta.37",
"@babel/preset-flow": "7.0.0-beta.37",
"@babel/preset-react": "7.0.0-beta.37",
"babel-plugin-macros": "2.0.0",
"babel-plugin-transform-dynamic-import": "2.0.0"
}
}
48 changes: 48 additions & 0 deletions packages/confusing-browser-globals/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# confusing-browser-globals

A curated list of browser globals that commonly cause confusion and are not recommended to use without an explicit `window.` qualifier.

## Motivation

Some global variables in browser are likely to be used by people without the intent of using them as globals, such as `status`, `name`, `event`, etc.

For example:

```js
handleClick() { // missing `event` argument
this.setState({
text: event.target.value // uses the `event` global: oops!
});
}
```

This package exports a list of globals that are often used by mistake. You can feed this list to a static analysis tool like ESLint to prevent their usage without an explicit `window.` qualifier.


## Installation

```
npm install --save confusing-browser-globals
```


## Usage

If you use Create React App, you don't need to configure anything, as this rule is already included in the default `eslint-config-react-app` preset.

If you maintain your own ESLint configuration, you can do this:

```js
var restrictedGlobals = require('confusing-browser-globals');

module.exports = {
rules: {
'no-restricted-globals': ['error'].concat(restrictedGlobals),
}
};
```


## License

MIT
Loading