@reactunity/scripts 0.6.1 → 0.9.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/bin/react-unity-scripts.js +7 -2
- package/config/env.js +1 -3
- 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 +31 -0
- package/config/jest/babelTransform.js +37 -0
- package/config/jest/cssTransform.js +22 -0
- package/config/jest/fileTransform.js +40 -0
- package/config/modules.js +14 -0
- package/config/paths.js +6 -0
- package/config/unityMiddleware.js +29 -0
- package/config/web-inspector/Build/WebInspector.data +0 -0
- package/config/web-inspector/Build/WebInspector.framework.js +1 -1
- package/config/web-inspector/Build/WebInspector.loader.js +1 -1
- package/config/web-inspector/Build/WebInspector.wasm +0 -0
- package/config/web-inspector/index.html +2 -2
- package/config/webpack/persistentCache/createEnvironmentHash.js +9 -0
- package/config/webpack.config.js +183 -169
- package/config/webpackDevServer.config.js +49 -79
- package/lib/types/base.d.ts +21 -7
- package/package.json +63 -54
- package/scripts/build.js +41 -19
- package/scripts/eject.js +237 -234
- package/scripts/init.js +11 -12
- package/scripts/lint.js +40 -0
- package/scripts/start.js +40 -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/webpackHotDevClient.js +0 -268
- package/scripts/utils/verifyPackageTree.js +0 -161
|
@@ -19,12 +19,17 @@ const spawn = require('react-dev-utils/crossSpawn');
|
|
|
19
19
|
const args = process.argv.slice(2);
|
|
20
20
|
|
|
21
21
|
const scriptIndex = args.findIndex(
|
|
22
|
-
x =>
|
|
22
|
+
x =>
|
|
23
|
+
x === 'build' ||
|
|
24
|
+
x === 'eject' ||
|
|
25
|
+
x === 'start' ||
|
|
26
|
+
x === 'test' ||
|
|
27
|
+
x === 'lint'
|
|
23
28
|
);
|
|
24
29
|
const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
|
|
25
30
|
const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
|
|
26
31
|
|
|
27
|
-
if (['build', 'eject', 'start', 'test'].includes(script)) {
|
|
32
|
+
if (['build', 'eject', 'start', 'test', 'lint'].includes(script)) {
|
|
28
33
|
const result = spawn.sync(
|
|
29
34
|
process.execPath,
|
|
30
35
|
nodeArgs
|
package/config/env.js
CHANGED
|
@@ -94,10 +94,8 @@ function getClientEnvironment(publicUrl) {
|
|
|
94
94
|
WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH,
|
|
95
95
|
WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT,
|
|
96
96
|
// Whether or not react-refresh is enabled.
|
|
97
|
-
// react-refresh is not 100% stable at this time,
|
|
98
|
-
// which is why it's disabled by default.
|
|
99
97
|
// It is defined here so it is available in the webpackHotDevClient.
|
|
100
|
-
FAST_REFRESH: process.env.FAST_REFRESH || false,
|
|
98
|
+
FAST_REFRESH: process.env.FAST_REFRESH === 'true' || false,
|
|
101
99
|
}
|
|
102
100
|
);
|
|
103
101
|
// Stringify all values so we can feed into webpack DefinePlugin
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
root: true,
|
|
12
|
+
|
|
13
|
+
parser: '@babel/eslint-parser',
|
|
14
|
+
|
|
15
|
+
plugins: ['react'],
|
|
16
|
+
|
|
17
|
+
env: {
|
|
18
|
+
browser: true,
|
|
19
|
+
commonjs: true,
|
|
20
|
+
es6: true,
|
|
21
|
+
jest: true,
|
|
22
|
+
node: true,
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
parserOptions: {
|
|
26
|
+
sourceType: 'module',
|
|
27
|
+
requireConfigFile: false,
|
|
28
|
+
babelOptions: {
|
|
29
|
+
presets: [require.resolve('babel-preset-react-app/prod')],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
settings: {
|
|
34
|
+
react: {
|
|
35
|
+
version: 'detect',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
rules: {
|
|
40
|
+
'react/jsx-uses-vars': 'warn',
|
|
41
|
+
'react/jsx-uses-react': 'warn',
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
// Inspired by https://github.com/airbnb/javascript but less opinionated.
|
|
11
|
+
|
|
12
|
+
// We use eslint-loader so even warnings are very visible.
|
|
13
|
+
// This is why we prefer to use "WARNING" level for potential errors,
|
|
14
|
+
// and we try not to use "ERROR" level at all.
|
|
15
|
+
|
|
16
|
+
// In the future, we might create a separate list of rules for production.
|
|
17
|
+
// It would probably be more strict.
|
|
18
|
+
|
|
19
|
+
// The ESLint browser environment defines all browser globals as valid,
|
|
20
|
+
// even though most people don't know some of them exist (e.g. `name` or `status`).
|
|
21
|
+
// This is dangerous as it hides accidentally undefined variables.
|
|
22
|
+
// We blacklist the globals that we deem potentially confusing.
|
|
23
|
+
// To use them, explicitly reference them, e.g. `window.name` or `window.status`.
|
|
24
|
+
const restrictedGlobals = require('confusing-browser-globals');
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
extends: [require.resolve('./base')],
|
|
28
|
+
|
|
29
|
+
plugins: ['import', 'react-hooks'],
|
|
30
|
+
|
|
31
|
+
overrides: [
|
|
32
|
+
{
|
|
33
|
+
files: ['**/*.ts?(x)'],
|
|
34
|
+
parser: '@typescript-eslint/parser',
|
|
35
|
+
parserOptions: {
|
|
36
|
+
ecmaVersion: 2018,
|
|
37
|
+
sourceType: 'module',
|
|
38
|
+
ecmaFeatures: {
|
|
39
|
+
jsx: true,
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
// typescript-eslint specific options
|
|
43
|
+
warnOnUnsupportedTypeScriptVersion: true,
|
|
44
|
+
},
|
|
45
|
+
plugins: ['@typescript-eslint'],
|
|
46
|
+
// If adding a typescript-eslint version of an existing ESLint rule,
|
|
47
|
+
// make sure to disable the ESLint rule here.
|
|
48
|
+
rules: {
|
|
49
|
+
// TypeScript's `noFallthroughCasesInSwitch` option is more robust (#6906)
|
|
50
|
+
'default-case': 'off',
|
|
51
|
+
// 'tsc' already handles this (https://github.com/typescript-eslint/typescript-eslint/issues/291)
|
|
52
|
+
'no-dupe-class-members': 'off',
|
|
53
|
+
// 'tsc' already handles this (https://github.com/typescript-eslint/typescript-eslint/issues/477)
|
|
54
|
+
'no-undef': 'off',
|
|
55
|
+
|
|
56
|
+
// Add TypeScript specific rules (and turn off ESLint equivalents)
|
|
57
|
+
'@typescript-eslint/consistent-type-assertions': 'warn',
|
|
58
|
+
'no-array-constructor': 'off',
|
|
59
|
+
'@typescript-eslint/no-array-constructor': 'warn',
|
|
60
|
+
'no-redeclare': 'off',
|
|
61
|
+
'@typescript-eslint/no-redeclare': 'warn',
|
|
62
|
+
'no-use-before-define': 'off',
|
|
63
|
+
'@typescript-eslint/no-use-before-define': [
|
|
64
|
+
'warn',
|
|
65
|
+
{
|
|
66
|
+
functions: false,
|
|
67
|
+
classes: false,
|
|
68
|
+
variables: false,
|
|
69
|
+
typedefs: false,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
'no-unused-expressions': 'off',
|
|
73
|
+
'@typescript-eslint/no-unused-expressions': [
|
|
74
|
+
'error',
|
|
75
|
+
{
|
|
76
|
+
allowShortCircuit: true,
|
|
77
|
+
allowTernary: true,
|
|
78
|
+
allowTaggedTemplates: true,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
'no-unused-vars': 'off',
|
|
82
|
+
'@typescript-eslint/no-unused-vars': [
|
|
83
|
+
'warn',
|
|
84
|
+
{
|
|
85
|
+
args: 'none',
|
|
86
|
+
ignoreRestSiblings: true,
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
'no-useless-constructor': 'off',
|
|
90
|
+
'@typescript-eslint/no-useless-constructor': 'warn',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
|
|
95
|
+
// NOTE: When adding rules here, you need to make sure they are compatible with
|
|
96
|
+
// `typescript-eslint`, as some rules such as `no-array-constructor` aren't compatible.
|
|
97
|
+
rules: {
|
|
98
|
+
// http://eslint.org/docs/rules/
|
|
99
|
+
'array-callback-return': 'warn',
|
|
100
|
+
'default-case': ['warn', { commentPattern: '^no default$' }],
|
|
101
|
+
'dot-location': ['warn', 'property'],
|
|
102
|
+
eqeqeq: ['warn', 'smart'],
|
|
103
|
+
'new-parens': 'warn',
|
|
104
|
+
'no-array-constructor': 'warn',
|
|
105
|
+
'no-caller': 'warn',
|
|
106
|
+
'no-cond-assign': ['warn', 'except-parens'],
|
|
107
|
+
'no-const-assign': 'warn',
|
|
108
|
+
'no-control-regex': 'warn',
|
|
109
|
+
'no-delete-var': 'warn',
|
|
110
|
+
'no-dupe-args': 'warn',
|
|
111
|
+
'no-dupe-class-members': 'warn',
|
|
112
|
+
'no-dupe-keys': 'warn',
|
|
113
|
+
'no-duplicate-case': 'warn',
|
|
114
|
+
'no-empty-character-class': 'warn',
|
|
115
|
+
'no-empty-pattern': 'warn',
|
|
116
|
+
'no-eval': 'warn',
|
|
117
|
+
'no-ex-assign': 'warn',
|
|
118
|
+
'no-extend-native': 'warn',
|
|
119
|
+
'no-extra-bind': 'warn',
|
|
120
|
+
'no-extra-label': 'warn',
|
|
121
|
+
'no-fallthrough': 'warn',
|
|
122
|
+
'no-func-assign': 'warn',
|
|
123
|
+
'no-implied-eval': 'warn',
|
|
124
|
+
'no-invalid-regexp': 'warn',
|
|
125
|
+
'no-iterator': 'warn',
|
|
126
|
+
'no-label-var': 'warn',
|
|
127
|
+
'no-labels': ['warn', { allowLoop: true, allowSwitch: false }],
|
|
128
|
+
'no-lone-blocks': 'warn',
|
|
129
|
+
'no-loop-func': 'warn',
|
|
130
|
+
'no-mixed-operators': [
|
|
131
|
+
'warn',
|
|
132
|
+
{
|
|
133
|
+
groups: [
|
|
134
|
+
['&', '|', '^', '~', '<<', '>>', '>>>'],
|
|
135
|
+
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
|
|
136
|
+
['&&', '||'],
|
|
137
|
+
['in', 'instanceof'],
|
|
138
|
+
],
|
|
139
|
+
allowSamePrecedence: false,
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
'no-multi-str': 'warn',
|
|
143
|
+
'no-native-reassign': 'warn',
|
|
144
|
+
'no-negated-in-lhs': 'warn',
|
|
145
|
+
'no-new-func': 'warn',
|
|
146
|
+
'no-new-object': 'warn',
|
|
147
|
+
'no-new-symbol': 'warn',
|
|
148
|
+
'no-new-wrappers': 'warn',
|
|
149
|
+
'no-obj-calls': 'warn',
|
|
150
|
+
'no-octal': 'warn',
|
|
151
|
+
'no-octal-escape': 'warn',
|
|
152
|
+
'no-redeclare': 'warn',
|
|
153
|
+
'no-regex-spaces': 'warn',
|
|
154
|
+
'no-restricted-syntax': ['warn', 'WithStatement'],
|
|
155
|
+
'no-script-url': 'warn',
|
|
156
|
+
'no-self-assign': 'warn',
|
|
157
|
+
'no-self-compare': 'warn',
|
|
158
|
+
'no-sequences': 'warn',
|
|
159
|
+
'no-shadow-restricted-names': 'warn',
|
|
160
|
+
'no-sparse-arrays': 'warn',
|
|
161
|
+
'no-template-curly-in-string': 'warn',
|
|
162
|
+
'no-this-before-super': 'warn',
|
|
163
|
+
'no-throw-literal': 'warn',
|
|
164
|
+
'no-undef': 'error',
|
|
165
|
+
'no-restricted-globals': ['error'].concat(restrictedGlobals),
|
|
166
|
+
'no-unreachable': 'warn',
|
|
167
|
+
'no-unused-expressions': [
|
|
168
|
+
'error',
|
|
169
|
+
{
|
|
170
|
+
allowShortCircuit: true,
|
|
171
|
+
allowTernary: true,
|
|
172
|
+
allowTaggedTemplates: true,
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
'no-unused-labels': 'warn',
|
|
176
|
+
'no-unused-vars': [
|
|
177
|
+
'warn',
|
|
178
|
+
{
|
|
179
|
+
args: 'none',
|
|
180
|
+
ignoreRestSiblings: true,
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
'no-use-before-define': [
|
|
184
|
+
'warn',
|
|
185
|
+
{
|
|
186
|
+
functions: false,
|
|
187
|
+
classes: false,
|
|
188
|
+
variables: false,
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
'no-useless-computed-key': 'warn',
|
|
192
|
+
'no-useless-concat': 'warn',
|
|
193
|
+
'no-useless-constructor': 'warn',
|
|
194
|
+
'no-useless-escape': 'warn',
|
|
195
|
+
'no-useless-rename': [
|
|
196
|
+
'warn',
|
|
197
|
+
{
|
|
198
|
+
ignoreDestructuring: false,
|
|
199
|
+
ignoreImport: false,
|
|
200
|
+
ignoreExport: false,
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
'no-with': 'warn',
|
|
204
|
+
'no-whitespace-before-property': 'warn',
|
|
205
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
206
|
+
'require-yield': 'warn',
|
|
207
|
+
'rest-spread-spacing': ['warn', 'never'],
|
|
208
|
+
strict: ['warn', 'never'],
|
|
209
|
+
'unicode-bom': ['warn', 'never'],
|
|
210
|
+
'use-isnan': 'warn',
|
|
211
|
+
'valid-typeof': 'warn',
|
|
212
|
+
'no-restricted-properties': [
|
|
213
|
+
'error',
|
|
214
|
+
{
|
|
215
|
+
object: 'require',
|
|
216
|
+
property: 'ensure',
|
|
217
|
+
message:
|
|
218
|
+
'Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting',
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
object: 'System',
|
|
222
|
+
property: 'import',
|
|
223
|
+
message:
|
|
224
|
+
'Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting',
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
'getter-return': 'warn',
|
|
228
|
+
|
|
229
|
+
// https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules
|
|
230
|
+
'import/first': 'error',
|
|
231
|
+
'import/no-amd': 'error',
|
|
232
|
+
'import/no-anonymous-default-export': 'warn',
|
|
233
|
+
'import/no-webpack-loader-syntax': 'error',
|
|
234
|
+
|
|
235
|
+
// https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
|
|
236
|
+
'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }],
|
|
237
|
+
'react/jsx-no-comment-textnodes': 'warn',
|
|
238
|
+
'react/jsx-no-duplicate-props': 'warn',
|
|
239
|
+
'react/jsx-no-target-blank': 'warn',
|
|
240
|
+
'react/jsx-no-undef': 'error',
|
|
241
|
+
'react/jsx-pascal-case': [
|
|
242
|
+
'warn',
|
|
243
|
+
{
|
|
244
|
+
allowAllCaps: true,
|
|
245
|
+
ignore: [],
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
'react/no-danger-with-children': 'warn',
|
|
249
|
+
// https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks
|
|
250
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
251
|
+
},
|
|
252
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
// We use eslint-loader so even warnings are very visible.
|
|
11
|
+
// This is why we prefer to use "WARNING" level for potential errors,
|
|
12
|
+
// and we try not to use "ERROR" level at all.
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
plugins: ['jest', 'testing-library'],
|
|
16
|
+
overrides: [
|
|
17
|
+
{
|
|
18
|
+
files: ['**/__tests__/**/*', '**/*.{spec,test}.*'],
|
|
19
|
+
env: {
|
|
20
|
+
'jest/globals': true,
|
|
21
|
+
},
|
|
22
|
+
// A subset of the recommended rules:
|
|
23
|
+
rules: {
|
|
24
|
+
// https://github.com/jest-community/eslint-plugin-jest
|
|
25
|
+
'jest/no-conditional-expect': 'error',
|
|
26
|
+
'jest/no-identical-title': 'error',
|
|
27
|
+
'jest/no-interpolation-in-snapshots': 'error',
|
|
28
|
+
'jest/no-jasmine-globals': 'error',
|
|
29
|
+
'jest/no-jest-import': 'error',
|
|
30
|
+
'jest/no-mocks-import': 'error',
|
|
31
|
+
'jest/valid-describe-callback': 'error',
|
|
32
|
+
'jest/valid-expect': 'error',
|
|
33
|
+
'jest/valid-expect-in-promise': 'error',
|
|
34
|
+
'jest/valid-title': 'warn',
|
|
35
|
+
|
|
36
|
+
// https://github.com/testing-library/eslint-plugin-testing-library
|
|
37
|
+
'testing-library/await-async-query': 'error',
|
|
38
|
+
'testing-library/await-async-utils': 'error',
|
|
39
|
+
'testing-library/no-await-sync-query': 'error',
|
|
40
|
+
'testing-library/no-container': 'error',
|
|
41
|
+
'testing-library/no-debugging-utils': 'error',
|
|
42
|
+
'testing-library/no-dom-import': ['error', 'react'],
|
|
43
|
+
'testing-library/no-node-access': 'error',
|
|
44
|
+
'testing-library/no-promise-in-fire-event': 'error',
|
|
45
|
+
'testing-library/no-render-in-setup': 'error',
|
|
46
|
+
'testing-library/no-unnecessary-act': 'error',
|
|
47
|
+
'testing-library/no-wait-for-empty-callback': 'error',
|
|
48
|
+
'testing-library/no-wait-for-multiple-assertions': 'error',
|
|
49
|
+
'testing-library/no-wait-for-side-effects': 'error',
|
|
50
|
+
'testing-library/no-wait-for-snapshot': 'error',
|
|
51
|
+
'testing-library/prefer-find-by': 'error',
|
|
52
|
+
'testing-library/prefer-presence-queries': 'error',
|
|
53
|
+
'testing-library/prefer-query-by-disappearance': 'error',
|
|
54
|
+
'testing-library/prefer-screen-queries': 'error',
|
|
55
|
+
'testing-library/render-result-naming-convention': 'error',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @remove-on-eject-begin
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
// @remove-on-eject-end
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const paths = require('./paths');
|
|
13
|
+
const modules = require('./modules');
|
|
14
|
+
|
|
15
|
+
const baseConfig = {
|
|
16
|
+
extends: [require.resolve('./eslint/config')],
|
|
17
|
+
rules: {
|
|
18
|
+
...(!modules.hasJsxRuntime && {
|
|
19
|
+
'react/react-in-jsx-scope': 'error',
|
|
20
|
+
}),
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
module.exports = {
|
|
25
|
+
extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
|
|
26
|
+
cache: true,
|
|
27
|
+
cacheLocation: path.resolve(paths.appNodeModules, '.cache/.eslintcache'),
|
|
28
|
+
cwd: paths.appPath,
|
|
29
|
+
resolvePluginsRelativeTo: __dirname,
|
|
30
|
+
baseConfig,
|
|
31
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// @remove-on-eject-begin
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2014-present, Facebook, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
// @remove-on-eject-end
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const babelJest = require('babel-jest').default;
|
|
12
|
+
|
|
13
|
+
const hasJsxRuntime = (() => {
|
|
14
|
+
if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
require.resolve('react/jsx-runtime');
|
|
20
|
+
return true;
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
})();
|
|
25
|
+
|
|
26
|
+
module.exports = babelJest.createTransformer({
|
|
27
|
+
presets: [
|
|
28
|
+
[
|
|
29
|
+
require.resolve('babel-preset-react-app'),
|
|
30
|
+
{
|
|
31
|
+
runtime: hasJsxRuntime ? 'automatic' : 'classic',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
],
|
|
35
|
+
babelrc: false,
|
|
36
|
+
configFile: false,
|
|
37
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// @remove-on-eject-begin
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2014-present, Facebook, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
// @remove-on-eject-end
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
// This is a custom Jest transformer turning style imports into empty objects.
|
|
12
|
+
// http://facebook.github.io/jest/docs/en/webpack.html
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
process() {
|
|
16
|
+
return 'module.exports = {};';
|
|
17
|
+
},
|
|
18
|
+
getCacheKey() {
|
|
19
|
+
// The output is always the same.
|
|
20
|
+
return 'cssTransform';
|
|
21
|
+
},
|
|
22
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const camelcase = require('camelcase');
|
|
5
|
+
|
|
6
|
+
// This is a custom Jest transformer turning file imports into filenames.
|
|
7
|
+
// http://facebook.github.io/jest/docs/en/webpack.html
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
process(src, filename) {
|
|
11
|
+
const assetFilename = JSON.stringify(path.basename(filename));
|
|
12
|
+
|
|
13
|
+
if (filename.match(/\.svg$/)) {
|
|
14
|
+
// Based on how SVGR generates a component name:
|
|
15
|
+
// https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
|
|
16
|
+
const pascalCaseFilename = camelcase(path.parse(filename).name, {
|
|
17
|
+
pascalCase: true,
|
|
18
|
+
});
|
|
19
|
+
const componentName = `Svg${pascalCaseFilename}`;
|
|
20
|
+
return `const React = require('react');
|
|
21
|
+
module.exports = {
|
|
22
|
+
__esModule: true,
|
|
23
|
+
default: ${assetFilename},
|
|
24
|
+
ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
|
|
25
|
+
return {
|
|
26
|
+
$$typeof: Symbol.for('react.element'),
|
|
27
|
+
type: 'svg',
|
|
28
|
+
ref: ref,
|
|
29
|
+
key: null,
|
|
30
|
+
props: Object.assign({}, props, {
|
|
31
|
+
children: ${assetFilename}
|
|
32
|
+
})
|
|
33
|
+
};
|
|
34
|
+
}),
|
|
35
|
+
};`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return `module.exports = ${assetFilename};`;
|
|
39
|
+
},
|
|
40
|
+
};
|
package/config/modules.js
CHANGED
|
@@ -131,11 +131,25 @@ function getModules() {
|
|
|
131
131
|
|
|
132
132
|
const additionalModulePaths = getAdditionalModulePaths(options);
|
|
133
133
|
|
|
134
|
+
const hasJsxRuntime = (() => {
|
|
135
|
+
if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
require.resolve('react/jsx-runtime');
|
|
141
|
+
return true;
|
|
142
|
+
} catch (e) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
})();
|
|
146
|
+
|
|
134
147
|
return {
|
|
135
148
|
additionalModulePaths: additionalModulePaths,
|
|
136
149
|
webpackAliases: getWebpackAliases(options),
|
|
137
150
|
jestAliases: getJestAliases(options),
|
|
138
151
|
hasTsConfig,
|
|
152
|
+
hasJsxRuntime,
|
|
139
153
|
};
|
|
140
154
|
}
|
|
141
155
|
|
package/config/paths.js
CHANGED
|
@@ -74,6 +74,8 @@ module.exports = {
|
|
|
74
74
|
testsSetup: resolveModule(resolveApp, 'src/setupTests'),
|
|
75
75
|
proxySetup: resolveApp('src/setupProxy.js'),
|
|
76
76
|
appNodeModules: resolveApp('node_modules'),
|
|
77
|
+
appWebpackCache: resolveApp('node_modules/.cache'),
|
|
78
|
+
appTsBuildInfoFile: resolveApp('node_modules/.cache/tsconfig.tsbuildinfo'),
|
|
77
79
|
swSrc: resolveModule(resolveApp, 'src/service-worker'),
|
|
78
80
|
publicUrlOrPath,
|
|
79
81
|
};
|
|
@@ -97,6 +99,8 @@ module.exports = {
|
|
|
97
99
|
testsSetup: resolveModule(resolveApp, 'src/setupTests'),
|
|
98
100
|
proxySetup: resolveApp('src/setupProxy.js'),
|
|
99
101
|
appNodeModules: resolveApp('node_modules'),
|
|
102
|
+
appWebpackCache: resolveApp('node_modules/.cache'),
|
|
103
|
+
appTsBuildInfoFile: resolveApp('node_modules/.cache/tsconfig.tsbuildinfo'),
|
|
100
104
|
swSrc: resolveModule(resolveApp, 'src/service-worker'),
|
|
101
105
|
publicUrlOrPath,
|
|
102
106
|
// These properties only exist before ejecting:
|
|
@@ -133,6 +137,8 @@ if (
|
|
|
133
137
|
testsSetup: resolveModule(resolveOwn, `${templatePath}/src/setupTests`),
|
|
134
138
|
proxySetup: resolveOwn(`${templatePath}/src/setupProxy.js`),
|
|
135
139
|
appNodeModules: resolveOwn('node_modules'),
|
|
140
|
+
appWebpackCache: resolveOwn('node_modules/.cache'),
|
|
141
|
+
appTsBuildInfoFile: resolveOwn('node_modules/.cache/tsconfig.tsbuildinfo'),
|
|
136
142
|
swSrc: resolveModule(resolveOwn, `${templatePath}/src/service-worker`),
|
|
137
143
|
publicUrlOrPath,
|
|
138
144
|
// These properties only exist before ejecting:
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function registerUnityMiddleware(app) {
|
|
2
|
+
// Allow serving Unity builds
|
|
3
|
+
function contentEncodingShorthand(pattern, encoding) {
|
|
4
|
+
app.get(pattern, function (req, res, next) {
|
|
5
|
+
res.set('Content-Encoding', encoding);
|
|
6
|
+
next();
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function contentTypeShorthand(pattern, type) {
|
|
11
|
+
app.get(pattern, function (req, res, next) {
|
|
12
|
+
res.set('Content-Type', type);
|
|
13
|
+
next();
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
contentEncodingShorthand('*.unityweb', 'gzip');
|
|
18
|
+
contentEncodingShorthand('*.gz', 'gzip');
|
|
19
|
+
contentEncodingShorthand('*.br', 'br');
|
|
20
|
+
contentTypeShorthand('*.js.gz', 'application/javascript');
|
|
21
|
+
contentTypeShorthand('*.js.br', 'application/javascript');
|
|
22
|
+
contentTypeShorthand('*.wasm', 'application/wasm');
|
|
23
|
+
contentTypeShorthand('*.wasm.gz', 'application/wasm');
|
|
24
|
+
contentTypeShorthand('*.wasm.br', 'application/wasm');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = {
|
|
28
|
+
registerUnityMiddleware,
|
|
29
|
+
};
|
|
Binary file
|