metro-transform-worker 0.76.6 → 0.76.8
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 +10 -10
- package/src/index.js +14 -4
- package/src/index.js.flow +11 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro-transform-worker",
|
|
3
|
-
"version": "0.76.
|
|
3
|
+
"version": "0.76.8",
|
|
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.20.0",
|
|
19
19
|
"@babel/types": "^7.20.0",
|
|
20
20
|
"babel-preset-fbjs": "^3.4.0",
|
|
21
|
-
"metro": "0.76.
|
|
22
|
-
"metro-babel-transformer": "0.76.
|
|
23
|
-
"metro-cache": "0.76.
|
|
24
|
-
"metro-cache-key": "0.76.
|
|
25
|
-
"metro-source-map": "0.76.
|
|
26
|
-
"metro-transform-plugins": "0.76.
|
|
21
|
+
"metro": "0.76.8",
|
|
22
|
+
"metro-babel-transformer": "0.76.8",
|
|
23
|
+
"metro-cache": "0.76.8",
|
|
24
|
+
"metro-cache-key": "0.76.8",
|
|
25
|
+
"metro-source-map": "0.76.8",
|
|
26
|
+
"metro-transform-plugins": "0.76.8",
|
|
27
27
|
"nullthrows": "^1.1.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"metro-memory-fs": "0.76.
|
|
31
|
-
"metro-minify-terser": "0.76.
|
|
32
|
-
"metro-react-native-babel-transformer": "0.76.
|
|
30
|
+
"metro-memory-fs": "0.76.8",
|
|
31
|
+
"metro-minify-terser": "0.76.8",
|
|
32
|
+
"metro-react-native-babel-transformer": "0.76.8"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": ">=16"
|
package/src/index.js
CHANGED
|
@@ -20,6 +20,7 @@ const { stableHash } = require("metro-cache");
|
|
|
20
20
|
const getCacheKey = require("metro-cache-key");
|
|
21
21
|
const {
|
|
22
22
|
fromRawMappings,
|
|
23
|
+
functionMapBabelPlugin,
|
|
23
24
|
toBabelSegments,
|
|
24
25
|
toSegmentTuple,
|
|
25
26
|
} = require("metro-source-map");
|
|
@@ -327,12 +328,17 @@ async function transformJSWithBabel(file, context) {
|
|
|
327
328
|
// $FlowFixMe[unsupported-syntax] dynamic require
|
|
328
329
|
const transformer = require(babelTransformerPath);
|
|
329
330
|
const transformResult = await transformer.transform(
|
|
330
|
-
|
|
331
|
+
// functionMapBabelPlugin populates metadata.metro.functionMap
|
|
332
|
+
getBabelTransformArgs(file, context, [functionMapBabelPlugin])
|
|
331
333
|
);
|
|
332
334
|
const jsFile = {
|
|
333
335
|
...file,
|
|
334
336
|
ast: transformResult.ast,
|
|
335
|
-
functionMap:
|
|
337
|
+
functionMap:
|
|
338
|
+
transformResult.metadata?.metro?.functionMap ??
|
|
339
|
+
// Fallback to deprecated explicitly-generated `functionMap`
|
|
340
|
+
transformResult.functionMap ??
|
|
341
|
+
null,
|
|
336
342
|
};
|
|
337
343
|
return await transformJS(jsFile, context);
|
|
338
344
|
}
|
|
@@ -382,7 +388,11 @@ async function transformJSON(file, { options, config, projectRoot }) {
|
|
|
382
388
|
output,
|
|
383
389
|
};
|
|
384
390
|
}
|
|
385
|
-
function getBabelTransformArgs(
|
|
391
|
+
function getBabelTransformArgs(
|
|
392
|
+
file,
|
|
393
|
+
{ options, config, projectRoot },
|
|
394
|
+
plugins = []
|
|
395
|
+
) {
|
|
386
396
|
return {
|
|
387
397
|
filename: file.filename,
|
|
388
398
|
options: {
|
|
@@ -399,7 +409,7 @@ function getBabelTransformArgs(file, { options, config, projectRoot }) {
|
|
|
399
409
|
projectRoot,
|
|
400
410
|
publicPath: config.publicPath,
|
|
401
411
|
},
|
|
402
|
-
plugins
|
|
412
|
+
plugins,
|
|
403
413
|
src: file.code,
|
|
404
414
|
};
|
|
405
415
|
}
|
package/src/index.js.flow
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
import type {PluginEntry} from '@babel/core';
|
|
14
|
+
import type {PluginEntry, Plugins} from '@babel/core';
|
|
15
15
|
import type {
|
|
16
16
|
BabelTransformer,
|
|
17
17
|
BabelTransformerArgs,
|
|
@@ -39,6 +39,7 @@ const {stableHash} = require('metro-cache');
|
|
|
39
39
|
const getCacheKey = require('metro-cache-key');
|
|
40
40
|
const {
|
|
41
41
|
fromRawMappings,
|
|
42
|
+
functionMapBabelPlugin,
|
|
42
43
|
toBabelSegments,
|
|
43
44
|
toSegmentTuple,
|
|
44
45
|
} = require('metro-source-map');
|
|
@@ -498,13 +499,18 @@ async function transformJSWithBabel(
|
|
|
498
499
|
const transformer: BabelTransformer = require(babelTransformerPath);
|
|
499
500
|
|
|
500
501
|
const transformResult = await transformer.transform(
|
|
501
|
-
|
|
502
|
+
// functionMapBabelPlugin populates metadata.metro.functionMap
|
|
503
|
+
getBabelTransformArgs(file, context, [functionMapBabelPlugin]),
|
|
502
504
|
);
|
|
503
505
|
|
|
504
506
|
const jsFile: JSFile = {
|
|
505
507
|
...file,
|
|
506
508
|
ast: transformResult.ast,
|
|
507
|
-
functionMap:
|
|
509
|
+
functionMap:
|
|
510
|
+
transformResult.metadata?.metro?.functionMap ??
|
|
511
|
+
// Fallback to deprecated explicitly-generated `functionMap`
|
|
512
|
+
transformResult.functionMap ??
|
|
513
|
+
null,
|
|
508
514
|
};
|
|
509
515
|
|
|
510
516
|
return await transformJS(jsFile, context);
|
|
@@ -563,6 +569,7 @@ async function transformJSON(
|
|
|
563
569
|
function getBabelTransformArgs(
|
|
564
570
|
file: $ReadOnly<{filename: Path, code: string, ...}>,
|
|
565
571
|
{options, config, projectRoot}: TransformationContext,
|
|
572
|
+
plugins?: Plugins = [],
|
|
566
573
|
): BabelTransformerArgs {
|
|
567
574
|
return {
|
|
568
575
|
filename: file.filename,
|
|
@@ -580,7 +587,7 @@ function getBabelTransformArgs(
|
|
|
580
587
|
projectRoot,
|
|
581
588
|
publicPath: config.publicPath,
|
|
582
589
|
},
|
|
583
|
-
plugins
|
|
590
|
+
plugins,
|
|
584
591
|
src: file.code,
|
|
585
592
|
};
|
|
586
593
|
}
|