metro-transform-worker 0.81.0 → 0.81.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 +17 -9
- package/src/index.js +19 -12
- package/src/index.js.flow +27 -13
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro-transform-worker",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.2",
|
|
4
4
|
"description": "🚇 Transform worker for Metro.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./src/index.js",
|
|
8
|
+
"./package.json": "./package.json",
|
|
9
|
+
"./private/*": "./src/*.js",
|
|
10
|
+
"./src": "./src/index.js",
|
|
11
|
+
"./src/*.js": "./src/*.js",
|
|
12
|
+
"./src/*": "./src/*.js"
|
|
13
|
+
},
|
|
6
14
|
"repository": {
|
|
7
15
|
"type": "git",
|
|
8
16
|
"url": "git@github.com:facebook/metro.git"
|
|
@@ -18,18 +26,18 @@
|
|
|
18
26
|
"@babel/parser": "^7.25.3",
|
|
19
27
|
"@babel/types": "^7.25.2",
|
|
20
28
|
"flow-enums-runtime": "^0.0.6",
|
|
21
|
-
"metro": "0.81.
|
|
22
|
-
"metro-babel-transformer": "0.81.
|
|
23
|
-
"metro-cache": "0.81.
|
|
24
|
-
"metro-cache-key": "0.81.
|
|
25
|
-
"metro-minify-terser": "0.81.
|
|
26
|
-
"metro-source-map": "0.81.
|
|
27
|
-
"metro-transform-plugins": "0.81.
|
|
29
|
+
"metro": "0.81.2",
|
|
30
|
+
"metro-babel-transformer": "0.81.2",
|
|
31
|
+
"metro-cache": "0.81.2",
|
|
32
|
+
"metro-cache-key": "0.81.2",
|
|
33
|
+
"metro-minify-terser": "0.81.2",
|
|
34
|
+
"metro-source-map": "0.81.2",
|
|
35
|
+
"metro-transform-plugins": "0.81.2",
|
|
28
36
|
"nullthrows": "^1.1.1"
|
|
29
37
|
},
|
|
30
38
|
"devDependencies": {
|
|
31
39
|
"@react-native/metro-babel-transformer": "0.73.11",
|
|
32
|
-
"metro-memory-fs": "0.81.
|
|
40
|
+
"metro-memory-fs": "0.81.2"
|
|
33
41
|
},
|
|
34
42
|
"engines": {
|
|
35
43
|
"node": ">=18.18"
|
package/src/index.js
CHANGED
|
@@ -108,21 +108,22 @@ async function transformJS(file, { config, options, projectRoot }) {
|
|
|
108
108
|
directives.push(types.directive(types.directiveLiteral("use strict")));
|
|
109
109
|
}
|
|
110
110
|
const plugins = [];
|
|
111
|
-
const babelPluginOpts = {
|
|
112
|
-
...options,
|
|
113
|
-
inlineableCalls: [importDefault, importAll],
|
|
114
|
-
importDefault,
|
|
115
|
-
importAll,
|
|
116
|
-
};
|
|
117
111
|
if (options.experimentalImportSupport === true) {
|
|
118
|
-
plugins.push([
|
|
112
|
+
plugins.push([
|
|
113
|
+
metroTransformPlugins.importExportPlugin,
|
|
114
|
+
{
|
|
115
|
+
importAll,
|
|
116
|
+
importDefault,
|
|
117
|
+
resolve: false,
|
|
118
|
+
},
|
|
119
|
+
]);
|
|
119
120
|
}
|
|
120
121
|
if (options.inlineRequires) {
|
|
121
122
|
plugins.push([
|
|
122
123
|
metroTransformPlugins.inlineRequiresPlugin,
|
|
123
124
|
{
|
|
124
|
-
...babelPluginOpts,
|
|
125
125
|
ignoredRequires: options.nonInlinedRequires,
|
|
126
|
+
inlineableCalls: [importDefault, importAll],
|
|
126
127
|
memoizeCalls:
|
|
127
128
|
options.customTransformOptions?.unstable_memoizeInlineRequires ??
|
|
128
129
|
options.unstable_memoizeInlineRequires,
|
|
@@ -130,7 +131,15 @@ async function transformJS(file, { config, options, projectRoot }) {
|
|
|
130
131
|
},
|
|
131
132
|
]);
|
|
132
133
|
}
|
|
133
|
-
plugins.push([
|
|
134
|
+
plugins.push([
|
|
135
|
+
metroTransformPlugins.inlinePlugin,
|
|
136
|
+
{
|
|
137
|
+
dev: options.dev,
|
|
138
|
+
inlinePlatform: options.inlinePlatform,
|
|
139
|
+
isWrapped: false,
|
|
140
|
+
platform: options.platform,
|
|
141
|
+
},
|
|
142
|
+
]);
|
|
134
143
|
ast = nullthrows(
|
|
135
144
|
transformFromAstSync(ast, "", {
|
|
136
145
|
ast: true,
|
|
@@ -153,9 +162,7 @@ async function transformJS(file, { config, options, projectRoot }) {
|
|
|
153
162
|
configFile: false,
|
|
154
163
|
comments: true,
|
|
155
164
|
filename: file.filename,
|
|
156
|
-
plugins: [
|
|
157
|
-
[metroTransformPlugins.constantFoldingPlugin, babelPluginOpts],
|
|
158
|
-
],
|
|
165
|
+
plugins: [metroTransformPlugins.constantFoldingPlugin],
|
|
159
166
|
sourceMaps: false,
|
|
160
167
|
cloneInputAst: false,
|
|
161
168
|
}).ast
|
package/src/index.js.flow
CHANGED
|
@@ -23,6 +23,11 @@ import type {
|
|
|
23
23
|
FBSourceFunctionMap,
|
|
24
24
|
MetroSourceMapSegmentTuple,
|
|
25
25
|
} from 'metro-source-map';
|
|
26
|
+
import type {
|
|
27
|
+
ImportExportPluginOptions,
|
|
28
|
+
InlinePluginOptions,
|
|
29
|
+
InlineRequiresPluginOptions,
|
|
30
|
+
} from 'metro-transform-plugins';
|
|
26
31
|
import type {TransformResultDependency} from 'metro/src/DeltaBundler';
|
|
27
32
|
import type {AllowOptionalDependencies} from 'metro/src/DeltaBundler/types.flow.js';
|
|
28
33
|
import type {
|
|
@@ -287,32 +292,43 @@ async function transformJS(
|
|
|
287
292
|
// Perform the import-export transform (in case it's still needed), then
|
|
288
293
|
// fold requires and perform constant folding (if in dev).
|
|
289
294
|
const plugins: Array<PluginEntry> = [];
|
|
290
|
-
const babelPluginOpts = {
|
|
291
|
-
...options,
|
|
292
|
-
inlineableCalls: [importDefault, importAll],
|
|
293
|
-
importDefault,
|
|
294
|
-
importAll,
|
|
295
|
-
};
|
|
296
295
|
|
|
297
296
|
if (options.experimentalImportSupport === true) {
|
|
298
|
-
plugins.push([
|
|
297
|
+
plugins.push([
|
|
298
|
+
metroTransformPlugins.importExportPlugin,
|
|
299
|
+
{
|
|
300
|
+
importAll,
|
|
301
|
+
importDefault,
|
|
302
|
+
resolve: false,
|
|
303
|
+
} as ImportExportPluginOptions,
|
|
304
|
+
]);
|
|
299
305
|
}
|
|
300
306
|
|
|
301
307
|
if (options.inlineRequires) {
|
|
302
308
|
plugins.push([
|
|
303
309
|
metroTransformPlugins.inlineRequiresPlugin,
|
|
304
310
|
{
|
|
305
|
-
...babelPluginOpts,
|
|
306
311
|
ignoredRequires: options.nonInlinedRequires,
|
|
312
|
+
inlineableCalls: [importDefault, importAll],
|
|
307
313
|
memoizeCalls:
|
|
314
|
+
// $FlowFixMe[incompatible-cast] is this always (?boolean)?
|
|
308
315
|
options.customTransformOptions?.unstable_memoizeInlineRequires ??
|
|
309
316
|
options.unstable_memoizeInlineRequires,
|
|
310
317
|
nonMemoizedModules: options.unstable_nonMemoizedInlineRequires,
|
|
311
|
-
},
|
|
318
|
+
} as InlineRequiresPluginOptions,
|
|
312
319
|
]);
|
|
313
320
|
}
|
|
314
321
|
|
|
315
|
-
plugins.push([
|
|
322
|
+
plugins.push([
|
|
323
|
+
metroTransformPlugins.inlinePlugin,
|
|
324
|
+
{
|
|
325
|
+
dev: options.dev,
|
|
326
|
+
inlinePlatform: options.inlinePlatform,
|
|
327
|
+
isWrapped: false,
|
|
328
|
+
// $FlowFixMe[incompatible-cast] expects a string if inlinePlatform
|
|
329
|
+
platform: options.platform,
|
|
330
|
+
} as InlinePluginOptions,
|
|
331
|
+
]);
|
|
316
332
|
|
|
317
333
|
ast = nullthrows(
|
|
318
334
|
transformFromAstSync(ast, '', {
|
|
@@ -345,9 +361,7 @@ async function transformJS(
|
|
|
345
361
|
configFile: false,
|
|
346
362
|
comments: true,
|
|
347
363
|
filename: file.filename,
|
|
348
|
-
plugins: [
|
|
349
|
-
[metroTransformPlugins.constantFoldingPlugin, babelPluginOpts],
|
|
350
|
-
],
|
|
364
|
+
plugins: [metroTransformPlugins.constantFoldingPlugin],
|
|
351
365
|
sourceMaps: false,
|
|
352
366
|
cloneInputAst: false,
|
|
353
367
|
}).ast,
|