metro-transform-worker 0.70.3 → 0.71.2
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/package.json +11 -11
- package/src/index.js +2 -1
- package/src/index.js.flow +14 -10
- package/src/__mocks__/index.js +0 -13
- package/src.real/__mocks__/index.js +0 -14
- package/src.real/__tests__/__snapshots__/index-test.js.snap +0 -329
- package/src.real/__tests__/index-test.js +0 -647
- package/src.real/index.js +0 -754
- package/src.real/utils/assetTransformer.js +0 -49
- package/src.real/utils/getMinifier.js +0 -32
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro-transform-worker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.71.2",
|
|
4
4
|
"description": "🚇 Transform worker for Metro.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"@babel/parser": "^7.14.0",
|
|
19
19
|
"@babel/types": "^7.0.0",
|
|
20
20
|
"babel-preset-fbjs": "^3.4.0",
|
|
21
|
-
"metro": "0.
|
|
22
|
-
"metro-babel-transformer": "0.
|
|
23
|
-
"metro-cache": "0.
|
|
24
|
-
"metro-cache-key": "0.
|
|
25
|
-
"metro-hermes-compiler": "0.
|
|
26
|
-
"metro-source-map": "0.
|
|
27
|
-
"metro-transform-plugins": "0.
|
|
21
|
+
"metro": "0.71.2",
|
|
22
|
+
"metro-babel-transformer": "0.71.2",
|
|
23
|
+
"metro-cache": "0.71.2",
|
|
24
|
+
"metro-cache-key": "0.71.2",
|
|
25
|
+
"metro-hermes-compiler": "0.71.2",
|
|
26
|
+
"metro-source-map": "0.71.2",
|
|
27
|
+
"metro-transform-plugins": "0.71.2",
|
|
28
28
|
"nullthrows": "^1.1.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"metro-memory-fs": "0.
|
|
32
|
-
"metro-minify-uglify": "0.
|
|
33
|
-
"metro-react-native-babel-transformer": "0.
|
|
31
|
+
"metro-memory-fs": "0.71.2",
|
|
32
|
+
"metro-minify-uglify": "0.71.2",
|
|
33
|
+
"metro-react-native-babel-transformer": "0.71.2"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/src/index.js
CHANGED
|
@@ -249,6 +249,7 @@ async function transformJS(file, { config, options, projectRoot }) {
|
|
|
249
249
|
keepRequireNames: options.dev,
|
|
250
250
|
allowOptionalDependencies: config.allowOptionalDependencies,
|
|
251
251
|
dependencyMapName: config.unstable_dependencyMapReservedName,
|
|
252
|
+
unstable_allowRequireContext: config.unstable_allowRequireContext,
|
|
252
253
|
}; // $FlowFixMe[unsupported-syntax] dynamic require
|
|
253
254
|
|
|
254
255
|
const collectDependencies = require(config.unstable_collectDependenciesPath);
|
|
@@ -586,7 +587,7 @@ module.exports = {
|
|
|
586
587
|
require.resolve("metro/src/ModuleGraph/worker/generateImportNames"),
|
|
587
588
|
require.resolve("metro/src/ModuleGraph/worker/JsFileWrapping"),
|
|
588
589
|
...metroTransformPlugins.getTransformPluginCacheKeyFiles(),
|
|
589
|
-
]);
|
|
590
|
+
]); // $FlowFixMe[unsupported-syntax]
|
|
590
591
|
|
|
591
592
|
const babelTransformer = require(babelTransformerPath);
|
|
592
593
|
|
package/src/index.js.flow
CHANGED
|
@@ -78,7 +78,7 @@ export type Minifier = MinifierOptions =>
|
|
|
78
78
|
|
|
79
79
|
export type Type = 'script' | 'module' | 'asset';
|
|
80
80
|
|
|
81
|
-
export type JsTransformerConfig = $ReadOnly<{
|
|
81
|
+
export type JsTransformerConfig = $ReadOnly<{
|
|
82
82
|
assetPlugins: $ReadOnlyArray<string>,
|
|
83
83
|
assetRegistryPath: string,
|
|
84
84
|
asyncRequireModulePath: string,
|
|
@@ -99,11 +99,13 @@ export type JsTransformerConfig = $ReadOnly<{|
|
|
|
99
99
|
unstable_disableModuleWrapping: boolean,
|
|
100
100
|
unstable_disableNormalizePseudoGlobals: boolean,
|
|
101
101
|
unstable_compactOutput: boolean,
|
|
102
|
-
|
|
102
|
+
/** Enable `require.context` statements which can be used to import multiple files in a directory. */
|
|
103
|
+
unstable_allowRequireContext: boolean,
|
|
104
|
+
}>;
|
|
103
105
|
|
|
104
106
|
export type {CustomTransformOptions} from 'metro-babel-transformer';
|
|
105
107
|
|
|
106
|
-
export type JsTransformOptions = $ReadOnly<{
|
|
108
|
+
export type JsTransformOptions = $ReadOnly<{
|
|
107
109
|
customTransformOptions?: CustomTransformOptions,
|
|
108
110
|
dev: boolean,
|
|
109
111
|
experimentalImportSupport?: boolean,
|
|
@@ -117,7 +119,7 @@ export type JsTransformOptions = $ReadOnly<{|
|
|
|
117
119
|
type: Type,
|
|
118
120
|
unstable_disableES6Transforms?: boolean,
|
|
119
121
|
unstable_transformProfile: TransformProfile,
|
|
120
|
-
|
|
122
|
+
}>;
|
|
121
123
|
|
|
122
124
|
export type BytecodeFileType =
|
|
123
125
|
| 'bytecode/module'
|
|
@@ -157,20 +159,20 @@ type TransformationContext = $ReadOnly<{
|
|
|
157
159
|
options: JsTransformOptions,
|
|
158
160
|
}>;
|
|
159
161
|
|
|
160
|
-
export type JsOutput = $ReadOnly<{
|
|
161
|
-
data: $ReadOnly<{
|
|
162
|
+
export type JsOutput = $ReadOnly<{
|
|
163
|
+
data: $ReadOnly<{
|
|
162
164
|
code: string,
|
|
163
165
|
lineCount: number,
|
|
164
166
|
map: Array<MetroSourceMapSegmentTuple>,
|
|
165
167
|
functionMap: ?FBSourceFunctionMap,
|
|
166
|
-
|
|
168
|
+
}>,
|
|
167
169
|
type: JSFileType,
|
|
168
|
-
|
|
170
|
+
}>;
|
|
169
171
|
|
|
170
|
-
export type BytecodeOutput = $ReadOnly<{
|
|
172
|
+
export type BytecodeOutput = $ReadOnly<{
|
|
171
173
|
data: HermesCompilerResult,
|
|
172
174
|
type: BytecodeFileType,
|
|
173
|
-
|
|
175
|
+
}>;
|
|
174
176
|
|
|
175
177
|
type DependencySplitCondition = $PropertyType<
|
|
176
178
|
$PropertyType<TransformResultDependency, 'data'>,
|
|
@@ -396,6 +398,7 @@ async function transformJS(
|
|
|
396
398
|
keepRequireNames: options.dev,
|
|
397
399
|
allowOptionalDependencies: config.allowOptionalDependencies,
|
|
398
400
|
dependencyMapName: config.unstable_dependencyMapReservedName,
|
|
401
|
+
unstable_allowRequireContext: config.unstable_allowRequireContext,
|
|
399
402
|
};
|
|
400
403
|
// $FlowFixMe[unsupported-syntax] dynamic require
|
|
401
404
|
const collectDependencies: CollectDependenciesFn<DependencySplitCondition> = require(config.unstable_collectDependenciesPath);
|
|
@@ -744,6 +747,7 @@ module.exports = {
|
|
|
744
747
|
...metroTransformPlugins.getTransformPluginCacheKeyFiles(),
|
|
745
748
|
]);
|
|
746
749
|
|
|
750
|
+
// $FlowFixMe[unsupported-syntax]
|
|
747
751
|
const babelTransformer = require(babelTransformerPath);
|
|
748
752
|
return [
|
|
749
753
|
filesKey,
|
package/src/__mocks__/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
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
|
-
* @format
|
|
8
|
-
*/
|
|
9
|
-
"use strict";
|
|
10
|
-
|
|
11
|
-
module.exports = function (data, callback) {
|
|
12
|
-
callback(null, {});
|
|
13
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
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
|
-
* @format
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
module.exports = function (data, callback) {
|
|
13
|
-
callback(null, {});
|
|
14
|
-
};
|
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`reports filename when encountering unsupported dynamic dependency 1`] = `"local/file.js:Invalid call at line 3: require(a)"`;
|
|
4
|
-
|
|
5
|
-
exports[`transforms a module with dependencies 1`] = `
|
|
6
|
-
Array [
|
|
7
|
-
Array [
|
|
8
|
-
2,
|
|
9
|
-
0,
|
|
10
|
-
1,
|
|
11
|
-
0,
|
|
12
|
-
],
|
|
13
|
-
Array [
|
|
14
|
-
6,
|
|
15
|
-
0,
|
|
16
|
-
5,
|
|
17
|
-
0,
|
|
18
|
-
],
|
|
19
|
-
Array [
|
|
20
|
-
8,
|
|
21
|
-
0,
|
|
22
|
-
2,
|
|
23
|
-
0,
|
|
24
|
-
"require",
|
|
25
|
-
],
|
|
26
|
-
Array [
|
|
27
|
-
8,
|
|
28
|
-
2,
|
|
29
|
-
2,
|
|
30
|
-
0,
|
|
31
|
-
"require",
|
|
32
|
-
],
|
|
33
|
-
Array [
|
|
34
|
-
8,
|
|
35
|
-
13,
|
|
36
|
-
2,
|
|
37
|
-
7,
|
|
38
|
-
],
|
|
39
|
-
Array [
|
|
40
|
-
8,
|
|
41
|
-
39,
|
|
42
|
-
2,
|
|
43
|
-
0,
|
|
44
|
-
],
|
|
45
|
-
Array [
|
|
46
|
-
10,
|
|
47
|
-
0,
|
|
48
|
-
3,
|
|
49
|
-
0,
|
|
50
|
-
"arbitrary",
|
|
51
|
-
],
|
|
52
|
-
Array [
|
|
53
|
-
10,
|
|
54
|
-
2,
|
|
55
|
-
3,
|
|
56
|
-
0,
|
|
57
|
-
"arbitrary",
|
|
58
|
-
],
|
|
59
|
-
Array [
|
|
60
|
-
10,
|
|
61
|
-
11,
|
|
62
|
-
3,
|
|
63
|
-
9,
|
|
64
|
-
],
|
|
65
|
-
Array [
|
|
66
|
-
10,
|
|
67
|
-
12,
|
|
68
|
-
3,
|
|
69
|
-
10,
|
|
70
|
-
"code",
|
|
71
|
-
],
|
|
72
|
-
Array [
|
|
73
|
-
10,
|
|
74
|
-
16,
|
|
75
|
-
3,
|
|
76
|
-
9,
|
|
77
|
-
],
|
|
78
|
-
Array [
|
|
79
|
-
10,
|
|
80
|
-
17,
|
|
81
|
-
3,
|
|
82
|
-
0,
|
|
83
|
-
],
|
|
84
|
-
Array [
|
|
85
|
-
12,
|
|
86
|
-
0,
|
|
87
|
-
4,
|
|
88
|
-
0,
|
|
89
|
-
],
|
|
90
|
-
Array [
|
|
91
|
-
12,
|
|
92
|
-
6,
|
|
93
|
-
4,
|
|
94
|
-
6,
|
|
95
|
-
"b",
|
|
96
|
-
],
|
|
97
|
-
Array [
|
|
98
|
-
12,
|
|
99
|
-
7,
|
|
100
|
-
4,
|
|
101
|
-
7,
|
|
102
|
-
],
|
|
103
|
-
Array [
|
|
104
|
-
12,
|
|
105
|
-
10,
|
|
106
|
-
4,
|
|
107
|
-
10,
|
|
108
|
-
"require",
|
|
109
|
-
],
|
|
110
|
-
Array [
|
|
111
|
-
12,
|
|
112
|
-
21,
|
|
113
|
-
4,
|
|
114
|
-
17,
|
|
115
|
-
],
|
|
116
|
-
Array [
|
|
117
|
-
12,
|
|
118
|
-
45,
|
|
119
|
-
4,
|
|
120
|
-
0,
|
|
121
|
-
],
|
|
122
|
-
]
|
|
123
|
-
`;
|
|
124
|
-
|
|
125
|
-
exports[`transforms a module with dependencies 2`] = `
|
|
126
|
-
Object {
|
|
127
|
-
"mappings": "AAA",
|
|
128
|
-
"names": Array [
|
|
129
|
-
"<global>",
|
|
130
|
-
],
|
|
131
|
-
}
|
|
132
|
-
`;
|
|
133
|
-
|
|
134
|
-
exports[`transforms a simple module 1`] = `
|
|
135
|
-
Array [
|
|
136
|
-
Array [
|
|
137
|
-
2,
|
|
138
|
-
0,
|
|
139
|
-
1,
|
|
140
|
-
0,
|
|
141
|
-
"arbitrary",
|
|
142
|
-
],
|
|
143
|
-
Array [
|
|
144
|
-
2,
|
|
145
|
-
2,
|
|
146
|
-
1,
|
|
147
|
-
0,
|
|
148
|
-
"arbitrary",
|
|
149
|
-
],
|
|
150
|
-
Array [
|
|
151
|
-
2,
|
|
152
|
-
11,
|
|
153
|
-
1,
|
|
154
|
-
9,
|
|
155
|
-
],
|
|
156
|
-
Array [
|
|
157
|
-
2,
|
|
158
|
-
12,
|
|
159
|
-
1,
|
|
160
|
-
10,
|
|
161
|
-
"code",
|
|
162
|
-
],
|
|
163
|
-
Array [
|
|
164
|
-
2,
|
|
165
|
-
16,
|
|
166
|
-
1,
|
|
167
|
-
9,
|
|
168
|
-
],
|
|
169
|
-
Array [
|
|
170
|
-
2,
|
|
171
|
-
17,
|
|
172
|
-
1,
|
|
173
|
-
0,
|
|
174
|
-
],
|
|
175
|
-
]
|
|
176
|
-
`;
|
|
177
|
-
|
|
178
|
-
exports[`transforms a simple module 2`] = `
|
|
179
|
-
Object {
|
|
180
|
-
"mappings": "AAA",
|
|
181
|
-
"names": Array [
|
|
182
|
-
"<global>",
|
|
183
|
-
],
|
|
184
|
-
}
|
|
185
|
-
`;
|
|
186
|
-
|
|
187
|
-
exports[`transforms a simple script 1`] = `
|
|
188
|
-
Array [
|
|
189
|
-
Array [
|
|
190
|
-
2,
|
|
191
|
-
0,
|
|
192
|
-
1,
|
|
193
|
-
0,
|
|
194
|
-
"someReallyArbitrary",
|
|
195
|
-
],
|
|
196
|
-
Array [
|
|
197
|
-
2,
|
|
198
|
-
2,
|
|
199
|
-
1,
|
|
200
|
-
0,
|
|
201
|
-
"someReallyArbitrary",
|
|
202
|
-
],
|
|
203
|
-
Array [
|
|
204
|
-
2,
|
|
205
|
-
21,
|
|
206
|
-
1,
|
|
207
|
-
19,
|
|
208
|
-
],
|
|
209
|
-
Array [
|
|
210
|
-
2,
|
|
211
|
-
22,
|
|
212
|
-
1,
|
|
213
|
-
20,
|
|
214
|
-
"code",
|
|
215
|
-
],
|
|
216
|
-
Array [
|
|
217
|
-
2,
|
|
218
|
-
26,
|
|
219
|
-
1,
|
|
220
|
-
19,
|
|
221
|
-
],
|
|
222
|
-
Array [
|
|
223
|
-
2,
|
|
224
|
-
27,
|
|
225
|
-
1,
|
|
226
|
-
0,
|
|
227
|
-
],
|
|
228
|
-
]
|
|
229
|
-
`;
|
|
230
|
-
|
|
231
|
-
exports[`transforms a simple script 2`] = `
|
|
232
|
-
Object {
|
|
233
|
-
"mappings": "AAA",
|
|
234
|
-
"names": Array [
|
|
235
|
-
"<global>",
|
|
236
|
-
],
|
|
237
|
-
}
|
|
238
|
-
`;
|
|
239
|
-
|
|
240
|
-
exports[`transforms an es module with asyncToGenerator 1`] = `
|
|
241
|
-
"__d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, _dependencyMap) {
|
|
242
|
-
var _interopRequireDefault = _$$_REQUIRE(_dependencyMap[0], \\"@babel/runtime/helpers/interopRequireDefault\\");
|
|
243
|
-
|
|
244
|
-
Object.defineProperty(exports, \\"__esModule\\", {
|
|
245
|
-
value: true
|
|
246
|
-
});
|
|
247
|
-
exports.test = test;
|
|
248
|
-
|
|
249
|
-
var _asyncToGenerator2 = _interopRequireDefault(_$$_REQUIRE(_dependencyMap[1], \\"@babel/runtime/helpers/asyncToGenerator\\"));
|
|
250
|
-
|
|
251
|
-
function test() {
|
|
252
|
-
return _test.apply(this, arguments);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function _test() {
|
|
256
|
-
_test = (0, _asyncToGenerator2.default)(function* () {});
|
|
257
|
-
return _test.apply(this, arguments);
|
|
258
|
-
}
|
|
259
|
-
});"
|
|
260
|
-
`;
|
|
261
|
-
|
|
262
|
-
exports[`transforms an es module with asyncToGenerator 2`] = `
|
|
263
|
-
Object {
|
|
264
|
-
"mappings": "AAA,OC",
|
|
265
|
-
"names": Array [
|
|
266
|
-
"<global>",
|
|
267
|
-
"test",
|
|
268
|
-
],
|
|
269
|
-
}
|
|
270
|
-
`;
|
|
271
|
-
|
|
272
|
-
exports[`transforms async generators 1`] = `
|
|
273
|
-
"__d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, _dependencyMap) {
|
|
274
|
-
var _interopRequireDefault = _$$_REQUIRE(_dependencyMap[0], \\"@babel/runtime/helpers/interopRequireDefault\\");
|
|
275
|
-
|
|
276
|
-
Object.defineProperty(exports, \\"__esModule\\", {
|
|
277
|
-
value: true
|
|
278
|
-
});
|
|
279
|
-
exports.test = test;
|
|
280
|
-
|
|
281
|
-
var _awaitAsyncGenerator2 = _interopRequireDefault(_$$_REQUIRE(_dependencyMap[1], \\"@babel/runtime/helpers/awaitAsyncGenerator\\"));
|
|
282
|
-
|
|
283
|
-
var _wrapAsyncGenerator2 = _interopRequireDefault(_$$_REQUIRE(_dependencyMap[2], \\"@babel/runtime/helpers/wrapAsyncGenerator\\"));
|
|
284
|
-
|
|
285
|
-
function test() {
|
|
286
|
-
return _test.apply(this, arguments);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
function _test() {
|
|
290
|
-
_test = (0, _wrapAsyncGenerator2.default)(function* () {
|
|
291
|
-
yield \\"ok\\";
|
|
292
|
-
});
|
|
293
|
-
return _test.apply(this, arguments);
|
|
294
|
-
}
|
|
295
|
-
});"
|
|
296
|
-
`;
|
|
297
|
-
|
|
298
|
-
exports[`transforms import/export syntax when experimental flag is on 1`] = `
|
|
299
|
-
Array [
|
|
300
|
-
Array [
|
|
301
|
-
4,
|
|
302
|
-
0,
|
|
303
|
-
1,
|
|
304
|
-
0,
|
|
305
|
-
],
|
|
306
|
-
Array [
|
|
307
|
-
4,
|
|
308
|
-
6,
|
|
309
|
-
1,
|
|
310
|
-
7,
|
|
311
|
-
"c",
|
|
312
|
-
],
|
|
313
|
-
Array [
|
|
314
|
-
4,
|
|
315
|
-
7,
|
|
316
|
-
1,
|
|
317
|
-
0,
|
|
318
|
-
],
|
|
319
|
-
]
|
|
320
|
-
`;
|
|
321
|
-
|
|
322
|
-
exports[`transforms import/export syntax when experimental flag is on 2`] = `
|
|
323
|
-
Object {
|
|
324
|
-
"mappings": "AAA",
|
|
325
|
-
"names": Array [
|
|
326
|
-
"<global>",
|
|
327
|
-
],
|
|
328
|
-
}
|
|
329
|
-
`;
|