@reactunity/scripts 0.8.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/bin/react-unity-scripts.js +6 -1
- package/config/env.js +2 -4
- package/config/eslint/base.js +43 -0
- package/config/eslint/config.js +252 -0
- package/config/eslint/jest.js +59 -0
- package/config/eslintConfig.js +2 -17
- package/config/jest/babelTransform.js +37 -0
- package/config/jest/cssTransform.js +22 -0
- package/config/jest/fileTransform.js +40 -0
- package/config/paths.js +9 -0
- package/config/{web-inspector → public}/.gitignore +0 -0
- package/config/{web-inspector → public}/favicon.ico +0 -0
- package/config/public/index.html +78 -0
- package/config/unityMiddleware.js +29 -0
- package/config/webpack/persistentCache/createEnvironmentHash.js +9 -0
- package/config/webpack.config.js +222 -116
- package/config/webpackDevServer.config.js +61 -81
- package/lib/types/base.d.ts +13 -2
- package/package.json +61 -52
- package/scripts/build.js +41 -19
- package/scripts/eject.js +237 -234
- package/scripts/init.js +15 -17
- package/scripts/lint.js +4 -3
- package/scripts/start.js +31 -40
- package/scripts/test.js +129 -0
- package/scripts/utils/createJestConfig.js +152 -0
- package/scripts/utils/verifyTypeScriptSetup.js +306 -309
- package/config/pnpTs.js +0 -43
- package/config/react-error-overlay.js +0 -9
- package/config/refreshOverlayInterop.js +0 -4
- package/config/web-inspector/Build/WebInspector.data +0 -0
- package/config/web-inspector/Build/WebInspector.framework.js +0 -7
- package/config/web-inspector/Build/WebInspector.loader.js +0 -1
- package/config/web-inspector/Build/WebInspector.wasm +0 -0
- package/config/web-inspector/index.html +0 -86
- package/config/webpackHotDevClient.js +0 -268
- package/scripts/utils/verifyPackageTree.js +0 -161
|
@@ -9,20 +9,32 @@
|
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
11
11
|
const fs = require('fs');
|
|
12
|
-
const
|
|
12
|
+
const path = require('path');
|
|
13
13
|
const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');
|
|
14
14
|
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
|
|
15
15
|
const ignoredFiles = require('react-dev-utils/ignoredFiles');
|
|
16
16
|
const redirectServedPath = require('react-dev-utils/redirectServedPathMiddleware');
|
|
17
17
|
const paths = require('./paths');
|
|
18
18
|
const getHttpsConfig = require('./getHttpsConfig');
|
|
19
|
-
const
|
|
19
|
+
const { registerUnityMiddleware } = require('./unityMiddleware');
|
|
20
20
|
|
|
21
|
+
const host = process.env.HOST || '0.0.0.0';
|
|
21
22
|
const sockHost = process.env.WDS_SOCKET_HOST;
|
|
22
|
-
const sockPath = process.env.WDS_SOCKET_PATH; // default: '/
|
|
23
|
+
const sockPath = process.env.WDS_SOCKET_PATH; // default: '/ws'
|
|
23
24
|
const sockPort = process.env.WDS_SOCKET_PORT;
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
function servePreviewerIfExists() {
|
|
27
|
+
try {
|
|
28
|
+
const previewerPath = path.dirname(require.resolve('@reactunity/previewer', { paths: [paths.appPath] }));
|
|
29
|
+
console.log('Using @reactunity/previewer');
|
|
30
|
+
return [{ directory: path.join(previewerPath, 'public') }];
|
|
31
|
+
} catch (err) { }
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = function (proxy, allowedHost) {
|
|
36
|
+
const disableFirewall =
|
|
37
|
+
!proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true';
|
|
26
38
|
return {
|
|
27
39
|
// WebpackDevServer 2.4.3 introduced a security fix that prevents remote
|
|
28
40
|
// websites from potentially accessing local content through DNS rebinding:
|
|
@@ -40,29 +52,17 @@ module.exports = function (proxy, allowedHost, host, port) {
|
|
|
40
52
|
// So we will disable the host check normally, but enable it if you have
|
|
41
53
|
// specified the `proxy` setting. Finally, we let you override it if you
|
|
42
54
|
// really know what you're doing with a special environment variable.
|
|
43
|
-
|
|
55
|
+
// Note: ["localhost", ".localhost"] will support subdomains - but we might
|
|
56
|
+
// want to allow setting the allowedHosts manually for more complex setups
|
|
57
|
+
allowedHosts: disableFirewall ? 'all' : [allowedHost],
|
|
58
|
+
headers: {
|
|
59
|
+
'Access-Control-Allow-Origin': '*',
|
|
60
|
+
'Access-Control-Allow-Methods': '*',
|
|
61
|
+
'Access-Control-Allow-Headers': '*',
|
|
62
|
+
},
|
|
44
63
|
// Enable gzip compression of generated files.
|
|
45
64
|
compress: true,
|
|
46
|
-
// Enable hot reloading server. It will provide WDS_SOCKET_PATH endpoint
|
|
47
|
-
// for the WebpackDevServer client so it can learn when the files were
|
|
48
|
-
// updated. The WebpackDevServer client is included as an entry point
|
|
49
|
-
// in the webpack development configuration. Note that only changes
|
|
50
|
-
// to CSS are currently hot reloaded. JS changes will refresh the browser.
|
|
51
|
-
hot: true,
|
|
52
|
-
// Use 'ws' instead of 'sockjs-node' on server since we're using native
|
|
53
|
-
// websockets in `webpackHotDevClient`.
|
|
54
|
-
webSocketServer: 'ws',
|
|
55
|
-
devMiddleware: {
|
|
56
|
-
index: 'index.html',
|
|
57
|
-
// It is important to tell WebpackDevServer to use the same "publicPath" path as
|
|
58
|
-
// we specified in the webpack config. When homepage is '.', default to serving
|
|
59
|
-
// from the root.
|
|
60
|
-
// remove last slash so user can land on `/test` instead of `/test/`
|
|
61
|
-
publicPath: paths.publicUrlOrPath.slice(0, -1),
|
|
62
|
-
},
|
|
63
65
|
static: [
|
|
64
|
-
// Serve React Unity Web Inspector as the index page
|
|
65
|
-
{ directory: path.join(__dirname, 'web-inspector'), },
|
|
66
66
|
{
|
|
67
67
|
// By default WebpackDevServer serves physical files from current directory
|
|
68
68
|
// in addition to all the virtual build products that it serves from memory.
|
|
@@ -79,29 +79,25 @@ module.exports = function (proxy, allowedHost, host, port) {
|
|
|
79
79
|
// for some reason broken when imported through webpack. If you just want to
|
|
80
80
|
// use an image, put it in `src` and `import` it from JavaScript instead.
|
|
81
81
|
directory: paths.appPublic,
|
|
82
|
-
publicPath: paths.publicUrlOrPath,
|
|
83
|
-
|
|
84
|
-
staticOptions: {},
|
|
85
|
-
// Reportedly, this avoids CPU overload on some systems.
|
|
86
|
-
// https://github.com/facebook/create-react-app/issues/293
|
|
87
|
-
// src/node_modules is not ignored to support absolute imports
|
|
88
|
-
// https://github.com/facebook/create-react-app/issues/1065
|
|
82
|
+
publicPath: [paths.publicUrlOrPath],
|
|
83
|
+
// By default files from `contentBase` will not trigger a page reload.
|
|
89
84
|
watch: {
|
|
85
|
+
// Reportedly, this avoids CPU overload on some systems.
|
|
86
|
+
// https://github.com/facebook/create-react-app/issues/293
|
|
87
|
+
// src/node_modules is not ignored to support absolute imports
|
|
88
|
+
// https://github.com/facebook/create-react-app/issues/1065
|
|
90
89
|
ignored: ignoredFiles(paths.appSrc),
|
|
91
90
|
},
|
|
92
91
|
},
|
|
92
|
+
|
|
93
|
+
// If installed, serve the ReactUnity Web Previewer
|
|
94
|
+
...servePreviewerIfExists(),
|
|
95
|
+
|
|
96
|
+
// Serve the fallback of web previewer as the index page
|
|
97
|
+
{ directory: path.join(__dirname, 'public'), },
|
|
93
98
|
],
|
|
94
|
-
|
|
95
|
-
'Access-Control-Allow-Origin': '*',
|
|
96
|
-
},
|
|
97
|
-
https: getHttpsConfig(),
|
|
98
|
-
host,
|
|
99
|
-
port,
|
|
99
|
+
|
|
100
100
|
client: {
|
|
101
|
-
overlay: false,
|
|
102
|
-
// Silence WebpackDevServer's own logs since they're generally not useful.
|
|
103
|
-
// It will still show compile warnings and errors with this setting.
|
|
104
|
-
logging: 'none',
|
|
105
101
|
webSocketURL: {
|
|
106
102
|
// Enable custom sockjs pathname for websocket connection to hot reloading server.
|
|
107
103
|
// Enable custom sockjs hostname, pathname and port for websocket connection
|
|
@@ -110,7 +106,18 @@ module.exports = function (proxy, allowedHost, host, port) {
|
|
|
110
106
|
pathname: sockPath,
|
|
111
107
|
port: sockPort,
|
|
112
108
|
},
|
|
109
|
+
overlay: false,
|
|
110
|
+
},
|
|
111
|
+
devMiddleware: {
|
|
112
|
+
// It is important to tell WebpackDevServer to use the same "publicPath" path as
|
|
113
|
+
// we specified in the webpack config. When homepage is '.', default to serving
|
|
114
|
+
// from the root.
|
|
115
|
+
// remove last slash so user can land on `/test` instead of `/test/`
|
|
116
|
+
publicPath: paths.publicUrlOrPath.slice(0, -1),
|
|
113
117
|
},
|
|
118
|
+
|
|
119
|
+
https: getHttpsConfig(),
|
|
120
|
+
host,
|
|
114
121
|
historyApiFallback: {
|
|
115
122
|
// Paths with dots should still use the history fallback.
|
|
116
123
|
// See https://github.com/facebook/create-react-app/issues/387.
|
|
@@ -119,57 +126,30 @@ module.exports = function (proxy, allowedHost, host, port) {
|
|
|
119
126
|
},
|
|
120
127
|
// `proxy` is run between `before` and `after` `webpack-dev-server` hooks
|
|
121
128
|
proxy,
|
|
122
|
-
|
|
123
|
-
|
|
129
|
+
setupMiddlewares(middlewares, devServer) {
|
|
130
|
+
if (!devServer) {
|
|
131
|
+
throw new Error('webpack-dev-server is not defined');
|
|
132
|
+
}
|
|
124
133
|
|
|
125
|
-
// Keep `evalSourceMapMiddleware`
|
|
134
|
+
// Keep `evalSourceMapMiddleware`
|
|
126
135
|
// middlewares before `redirectServedPath` otherwise will not have any effect
|
|
127
136
|
// This lets us fetch source contents from webpack for the error overlay
|
|
128
|
-
app.use(evalSourceMapMiddleware(devServer));
|
|
129
|
-
// This lets us open files from the runtime error overlay.
|
|
130
|
-
app.use(errorOverlayMiddleware());
|
|
137
|
+
devServer.app.use(evalSourceMapMiddleware(devServer));
|
|
131
138
|
|
|
132
139
|
if (fs.existsSync(paths.proxySetup)) {
|
|
133
140
|
// This registers user provided middleware for proxy reasons
|
|
134
|
-
require(paths.proxySetup)(app);
|
|
141
|
+
require(paths.proxySetup)(devServer.app);
|
|
135
142
|
}
|
|
136
143
|
|
|
137
|
-
|
|
138
|
-
function contentEncodingShorthand(pattern, encoding) {
|
|
139
|
-
app.get(pattern, function (req, res, next) {
|
|
140
|
-
res.set('Content-Encoding', encoding);
|
|
141
|
-
next();
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function contentTypeShorthand(pattern, type) {
|
|
146
|
-
app.get(pattern, function (req, res, next) {
|
|
147
|
-
res.set('Content-Type', type);
|
|
148
|
-
next();
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
contentEncodingShorthand('*.unityweb', 'gzip');
|
|
153
|
-
contentEncodingShorthand('*.gz', 'gzip');
|
|
154
|
-
contentEncodingShorthand('*.br', 'br');
|
|
155
|
-
contentTypeShorthand('*.js.gz', 'application/javascript');
|
|
156
|
-
contentTypeShorthand('*.js.br', 'application/javascript');
|
|
157
|
-
contentTypeShorthand('*.wasm', 'application/wasm');
|
|
158
|
-
contentTypeShorthand('*.wasm.gz', 'application/wasm');
|
|
159
|
-
contentTypeShorthand('*.wasm.br', 'application/wasm');
|
|
160
|
-
},
|
|
161
|
-
onAfterSetupMiddleware(devServer) {
|
|
162
|
-
const app = devServer.app;
|
|
144
|
+
registerUnityMiddleware(devServer.app);
|
|
163
145
|
|
|
164
146
|
// Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
|
|
165
|
-
|
|
147
|
+
middlewares.push({
|
|
148
|
+
name: 'public-urls',
|
|
149
|
+
middleware: redirectServedPath(paths.publicUrlOrPath),
|
|
150
|
+
});
|
|
166
151
|
|
|
167
|
-
|
|
168
|
-
// previous service worker registered for the same host:port combination.
|
|
169
|
-
// We do this in development to avoid hitting the production cache if
|
|
170
|
-
// it used the same host and port.
|
|
171
|
-
// https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
|
|
172
|
-
app.use(noopServiceWorkerMiddleware(paths.publicUrlOrPath));
|
|
152
|
+
return middlewares;
|
|
173
153
|
},
|
|
174
154
|
};
|
|
175
155
|
};
|
package/lib/types/base.d.ts
CHANGED
|
@@ -10,6 +10,11 @@ declare namespace NodeJS {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
declare module '*.avif' {
|
|
14
|
+
const src: string;
|
|
15
|
+
export default src;
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
declare module '*.bmp' {
|
|
14
19
|
const src: string;
|
|
15
20
|
export default src;
|
|
@@ -41,8 +46,14 @@ declare module '*.webp' {
|
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
declare module '*.svg' {
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
import * as React from 'react';
|
|
50
|
+
|
|
51
|
+
export const ReactComponent: React.FunctionComponent<React.SVGProps<
|
|
52
|
+
SVGSVGElement
|
|
53
|
+
> & { title?: string }>;
|
|
54
|
+
|
|
55
|
+
const src: string;
|
|
56
|
+
export default src;
|
|
46
57
|
}
|
|
47
58
|
|
|
48
59
|
declare module '*.module.css' {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactunity/scripts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Configuration and scripts for React Unity.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"engines": {
|
|
11
|
-
"node": "
|
|
11
|
+
"node": ">=14.0.0"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/ReactUnity/scripts/issues"
|
|
@@ -44,69 +44,78 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@babel/core": "7.
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
50
|
-
"@types/
|
|
51
|
-
"@
|
|
52
|
-
"@typescript-eslint/
|
|
53
|
-
"
|
|
54
|
-
"babel-
|
|
55
|
-
"babel-
|
|
56
|
-
"babel-
|
|
47
|
+
"@babel/core": "^7.17.9",
|
|
48
|
+
"@babel/eslint-parser": "^7.17.0",
|
|
49
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
|
|
50
|
+
"@types/react": "^18.0.8",
|
|
51
|
+
"@types/webpack-env": "^1.16.4",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^5.21.0",
|
|
53
|
+
"@typescript-eslint/parser": "^5.21.0",
|
|
54
|
+
"babel-jest": "^28.0.2",
|
|
55
|
+
"babel-loader": "^8.2.5",
|
|
56
|
+
"babel-plugin-named-asset-import": "^0.3.8",
|
|
57
|
+
"babel-preset-react-app": "^10.0.1",
|
|
57
58
|
"bfj": "^7.0.2",
|
|
58
|
-
"camelcase": "^6.
|
|
59
|
-
"case-sensitive-paths-webpack-plugin": "2.4.0",
|
|
60
|
-
"confusing-browser-globals": "^1.0.
|
|
61
|
-
"css-loader": "6.
|
|
62
|
-
"dotenv": "
|
|
63
|
-
"dotenv-expand": "
|
|
64
|
-
"eslint": "^
|
|
65
|
-
"eslint-
|
|
66
|
-
"eslint-plugin-
|
|
67
|
-
"eslint-plugin-react": "^7.
|
|
68
|
-
"eslint-plugin-react-hooks": "^4.
|
|
69
|
-
"eslint-plugin-testing-library": "^
|
|
70
|
-
"eslint-webpack-plugin": "^3.1.
|
|
71
|
-
"file-loader": "6.2.0",
|
|
72
|
-
"fs-extra": "^10.
|
|
73
|
-
"identity-obj-proxy": "3.0.0",
|
|
59
|
+
"camelcase": "^6.3.0",
|
|
60
|
+
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
61
|
+
"confusing-browser-globals": "^1.0.11",
|
|
62
|
+
"css-loader": "^6.7.1",
|
|
63
|
+
"dotenv": "^16.0.0",
|
|
64
|
+
"dotenv-expand": "^8.0.3",
|
|
65
|
+
"eslint": "^8.14.0",
|
|
66
|
+
"eslint-plugin-import": "^2.26.0",
|
|
67
|
+
"eslint-plugin-jest": "^26.1.5",
|
|
68
|
+
"eslint-plugin-react": "^7.29.4",
|
|
69
|
+
"eslint-plugin-react-hooks": "^4.5.0",
|
|
70
|
+
"eslint-plugin-testing-library": "^5.3.1",
|
|
71
|
+
"eslint-webpack-plugin": "^3.1.1",
|
|
72
|
+
"file-loader": "^6.2.0",
|
|
73
|
+
"fs-extra": "^10.1.0",
|
|
74
|
+
"identity-obj-proxy": "^3.0.0",
|
|
75
|
+
"jest": "^28.0.2",
|
|
76
|
+
"jest-resolve": "^28.0.2",
|
|
77
|
+
"jest-watch-typeahead": "^1.1.0",
|
|
78
|
+
"mini-css-extract-plugin": "^2.6.0",
|
|
74
79
|
"null-loader": "^4.0.1",
|
|
75
|
-
"
|
|
76
|
-
"
|
|
80
|
+
"postcss": "^8.4.12",
|
|
81
|
+
"postcss-loader": "^6.2.1",
|
|
82
|
+
"prompts": "^2.4.2",
|
|
77
83
|
"raw-loader": "^4.0.2",
|
|
78
|
-
"react-app-polyfill": "^
|
|
79
|
-
"react-dev-utils": "
|
|
80
|
-
"react-refresh": "^0.
|
|
81
|
-
"resolve": "1.
|
|
82
|
-
"resolve-url-loader": "^
|
|
83
|
-
"sass
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"webpack": "5.
|
|
90
|
-
"
|
|
84
|
+
"react-app-polyfill": "^3.0.0",
|
|
85
|
+
"react-dev-utils": "^12.0.1",
|
|
86
|
+
"react-refresh": "^0.13.0",
|
|
87
|
+
"resolve": "^1.22.0",
|
|
88
|
+
"resolve-url-loader": "^5.0.0",
|
|
89
|
+
"sass": "^1.51.0",
|
|
90
|
+
"sass-loader": "^12.6.0",
|
|
91
|
+
"semver": "^7.3.7",
|
|
92
|
+
"source-map-loader": "^3.0.1",
|
|
93
|
+
"style-loader": "^3.3.1",
|
|
94
|
+
"tailwindcss": "^3.0.24",
|
|
95
|
+
"terser-webpack-plugin": "^5.3.1",
|
|
96
|
+
"url-loader": "^4.1.1",
|
|
97
|
+
"webpack": "^5.72.0",
|
|
98
|
+
"webpack-dev-server": "^4.8.1",
|
|
99
|
+
"webpack-manifest-plugin": "^5.0.0"
|
|
91
100
|
},
|
|
92
101
|
"devDependencies": {
|
|
93
|
-
"
|
|
94
|
-
"typescript": "^4.4.4"
|
|
102
|
+
"typescript": "^4.6.3"
|
|
95
103
|
},
|
|
96
104
|
"optionalDependencies": {
|
|
97
|
-
"fsevents": "^2.3.2"
|
|
98
|
-
"sass": "^1.43.4"
|
|
105
|
+
"fsevents": "^2.3.2"
|
|
99
106
|
},
|
|
100
107
|
"peerDependencies": {
|
|
101
|
-
"@reactunity/
|
|
102
|
-
"
|
|
108
|
+
"@reactunity/previewer": "*",
|
|
109
|
+
"@reactunity/renderer": "^0.10.0",
|
|
110
|
+
"react": "^18.0.0",
|
|
111
|
+
"typescript": "^4.6.3"
|
|
103
112
|
},
|
|
104
113
|
"peerDependenciesMeta": {
|
|
114
|
+
"@reactunity/previewer": {
|
|
115
|
+
"optional": true
|
|
116
|
+
},
|
|
105
117
|
"typescript": {
|
|
106
118
|
"optional": true
|
|
107
119
|
}
|
|
108
|
-
},
|
|
109
|
-
"resolutions": {
|
|
110
|
-
"react-dev-utils": "https://github.com/ReactUnity/scripts/raw/main/temp/react-dev-utils-11.0.3-hotfix.tgz"
|
|
111
120
|
}
|
|
112
121
|
}
|
package/scripts/build.js
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
11
11
|
// Do this as the first thing so that any code reading it knows the right env.
|
|
12
|
-
process.env.BABEL_ENV =
|
|
13
|
-
process.env.NODE_ENV =
|
|
12
|
+
process.env.BABEL_ENV = 'production';
|
|
13
|
+
process.env.NODE_ENV = 'production';
|
|
14
14
|
|
|
15
15
|
// Makes the script crash on unhandled rejections instead of silently
|
|
16
16
|
// ignoring them. In the future, promise rejections that are not handled will
|
|
@@ -21,15 +21,6 @@ process.on('unhandledRejection', err => {
|
|
|
21
21
|
|
|
22
22
|
// Ensure environment variables are read.
|
|
23
23
|
require('../config/env');
|
|
24
|
-
// @remove-on-eject-begin
|
|
25
|
-
// Do the preflight checks (only happens before eject).
|
|
26
|
-
const verifyPackageTree = require('./utils/verifyPackageTree');
|
|
27
|
-
if (process.env.SKIP_PREFLIGHT_CHECK !== 'true') {
|
|
28
|
-
verifyPackageTree();
|
|
29
|
-
}
|
|
30
|
-
const verifyTypeScriptSetup = require('./utils/verifyTypeScriptSetup');
|
|
31
|
-
verifyTypeScriptSetup();
|
|
32
|
-
// @remove-on-eject-end
|
|
33
24
|
|
|
34
25
|
const path = require('path');
|
|
35
26
|
const chalk = require('react-dev-utils/chalk');
|
|
@@ -38,13 +29,16 @@ const bfj = require('bfj');
|
|
|
38
29
|
const webpack = require('webpack');
|
|
39
30
|
const configFactory = require('../config/webpack.config');
|
|
40
31
|
const paths = require('../config/paths');
|
|
32
|
+
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
|
41
33
|
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
|
34
|
+
const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
|
|
42
35
|
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
|
43
36
|
const printBuildError = require('react-dev-utils/printBuildError');
|
|
44
37
|
|
|
45
38
|
const measureFileSizesBeforeBuild =
|
|
46
39
|
FileSizeReporter.measureFileSizesBeforeBuild;
|
|
47
40
|
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
|
|
41
|
+
const useYarn = fs.existsSync(paths.yarnLockFile);
|
|
48
42
|
|
|
49
43
|
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
50
44
|
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
@@ -52,13 +46,26 @@ const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
|
52
46
|
|
|
53
47
|
const isInteractive = process.stdout.isTTY;
|
|
54
48
|
|
|
49
|
+
// Warn and crash if required files are missing
|
|
50
|
+
if (!checkRequiredFiles([paths.appIndexJs])) {
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
|
|
55
54
|
const argv = process.argv.slice(2);
|
|
56
55
|
const writeStatsJson = argv.indexOf('--stats') !== -1;
|
|
57
56
|
|
|
58
57
|
// Generate configuration
|
|
59
58
|
const config = configFactory('production');
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
// We require that you explicitly set browsers and do not fall back to
|
|
61
|
+
// browserslist defaults.
|
|
62
|
+
const checkBrowsers = () => Promise.resolve();
|
|
63
|
+
checkBrowsers(paths.appPath, isInteractive)
|
|
64
|
+
.then(() => {
|
|
65
|
+
// First, read the current file sizes in build directory.
|
|
66
|
+
// This lets us display how much they changed later.
|
|
67
|
+
return measureFileSizesBeforeBuild(paths.appBuild);
|
|
68
|
+
})
|
|
62
69
|
.then(previousFileSizes => {
|
|
63
70
|
// Remove all content but keep the directory so that
|
|
64
71
|
// if you're in it, you don't end up in Trash
|
|
@@ -97,8 +104,17 @@ measureFileSizesBeforeBuild(paths.appBuild)
|
|
|
97
104
|
);
|
|
98
105
|
console.log();
|
|
99
106
|
|
|
107
|
+
const appPackage = require(paths.appPackageJson);
|
|
108
|
+
const publicUrl = paths.publicUrlOrPath;
|
|
109
|
+
const publicPath = config.output.publicPath;
|
|
100
110
|
const buildFolder = path.relative(process.cwd(), paths.appBuild);
|
|
101
|
-
|
|
111
|
+
printHostingInstructions(
|
|
112
|
+
appPackage,
|
|
113
|
+
publicUrl,
|
|
114
|
+
publicPath,
|
|
115
|
+
buildFolder,
|
|
116
|
+
useYarn
|
|
117
|
+
);
|
|
102
118
|
},
|
|
103
119
|
err => {
|
|
104
120
|
const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
|
|
@@ -168,13 +184,19 @@ function build(previousFileSizes) {
|
|
|
168
184
|
process.env.CI.toLowerCase() !== 'false') &&
|
|
169
185
|
messages.warnings.length
|
|
170
186
|
) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
'Most CI servers set it automatically.\n'
|
|
175
|
-
)
|
|
187
|
+
// Ignore sourcemap warnings in CI builds. See #8227 for more info.
|
|
188
|
+
const filteredWarnings = messages.warnings.filter(
|
|
189
|
+
w => !/Failed to parse source map/.test(w)
|
|
176
190
|
);
|
|
177
|
-
|
|
191
|
+
if (filteredWarnings.length) {
|
|
192
|
+
console.log(
|
|
193
|
+
chalk.yellow(
|
|
194
|
+
'\nTreating warnings as errors because process.env.CI = true.\n' +
|
|
195
|
+
'Most CI servers set it automatically.\n'
|
|
196
|
+
)
|
|
197
|
+
);
|
|
198
|
+
return reject(new Error(filteredWarnings.join('\n\n')));
|
|
199
|
+
}
|
|
178
200
|
}
|
|
179
201
|
|
|
180
202
|
const resolveArgs = {
|