metro-transform-worker 0.75.0 → 0.76.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metro-transform-worker",
3
- "version": "0.75.0",
3
+ "version": "0.76.0",
4
4
  "description": "🚇 Transform worker for Metro.",
5
5
  "main": "src/index.js",
6
6
  "repository": {
@@ -18,21 +18,21 @@
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.75.0",
22
- "metro-babel-transformer": "0.75.0",
23
- "metro-cache": "0.75.0",
24
- "metro-cache-key": "0.75.0",
25
- "metro-hermes-compiler": "0.75.0",
26
- "metro-source-map": "0.75.0",
27
- "metro-transform-plugins": "0.75.0",
21
+ "metro": "0.76.0",
22
+ "metro-babel-transformer": "0.76.0",
23
+ "metro-cache": "0.76.0",
24
+ "metro-cache-key": "0.76.0",
25
+ "metro-hermes-compiler": "0.76.0",
26
+ "metro-source-map": "0.76.0",
27
+ "metro-transform-plugins": "0.76.0",
28
28
  "nullthrows": "^1.1.1"
29
29
  },
30
30
  "devDependencies": {
31
- "metro-memory-fs": "0.75.0",
32
- "metro-minify-terser": "0.75.0",
33
- "metro-react-native-babel-transformer": "0.75.0"
31
+ "metro-memory-fs": "0.76.0",
32
+ "metro-minify-terser": "0.76.0",
33
+ "metro-react-native-babel-transformer": "0.76.0"
34
34
  },
35
35
  "engines": {
36
- "node": ">=14.17.0"
36
+ "node": ">=16"
37
37
  }
38
38
  }
package/src/index.js CHANGED
@@ -102,7 +102,6 @@ const compileToBytecode = (rawCode, type, options) => {
102
102
  const disabledDependencyTransformer = {
103
103
  transformSyncRequire: () => void 0,
104
104
  transformImportCall: () => void 0,
105
- transformJSResource: () => void 0,
106
105
  transformPrefetch: () => void 0,
107
106
  transformIllegalDynamicRequire: () => void 0,
108
107
  };
@@ -114,15 +113,13 @@ class InvalidRequireCallError extends Error {
114
113
  }
115
114
  }
116
115
  async function transformJS(file, { config, options, projectRoot }) {
117
- var _file$ast;
118
116
  // Transformers can output null ASTs (if they ignore the file). In that case
119
117
  // we need to parse the module source code to get their AST.
120
118
  let ast =
121
- (_file$ast = file.ast) !== null && _file$ast !== void 0
122
- ? _file$ast
123
- : babylon.parse(file.code, {
124
- sourceType: "unambiguous",
125
- });
119
+ file.ast ??
120
+ babylon.parse(file.code, {
121
+ sourceType: "unambiguous",
122
+ });
126
123
  const { importDefault, importAll } = generateImportNames(ast);
127
124
 
128
125
  // Add "use strict" if the file was parsed as a module, and the directive did
@@ -353,7 +350,6 @@ async function transformAsset(file, context) {
353
350
  * the generic JavaScript transformation.
354
351
  */
355
352
  async function transformJSWithBabel(file, context) {
356
- var _transformResult$func;
357
353
  const { babelTransformerPath } = context.config;
358
354
  // $FlowFixMe[unsupported-syntax] dynamic require
359
355
  const transformer = require(babelTransformerPath);
@@ -363,11 +359,7 @@ async function transformJSWithBabel(file, context) {
363
359
  const jsFile = {
364
360
  ...file,
365
361
  ast: transformResult.ast,
366
- functionMap:
367
- (_transformResult$func = transformResult.functionMap) !== null &&
368
- _transformResult$func !== void 0
369
- ? _transformResult$func
370
- : null,
362
+ functionMap: transformResult.functionMap ?? null,
371
363
  };
372
364
  return await transformJS(jsFile, context);
373
365
  }
package/src/index.js.flow CHANGED
@@ -174,11 +174,6 @@ export type BytecodeOutput = $ReadOnly<{
174
174
  type: BytecodeFileType,
175
175
  }>;
176
176
 
177
- type DependencySplitCondition = $PropertyType<
178
- $PropertyType<TransformResultDependency, 'data'>,
179
- 'splitCondition',
180
- >;
181
-
182
177
  type TransformResponse = $ReadOnly<{
183
178
  dependencies: $ReadOnlyArray<TransformResultDependency>,
184
179
  output: $ReadOnlyArray<JsOutput | BytecodeOutput>,
@@ -264,10 +259,9 @@ const compileToBytecode = (
264
259
  return HermesCompiler.compile(code, options);
265
260
  };
266
261
 
267
- const disabledDependencyTransformer: DependencyTransformer<mixed> = {
262
+ const disabledDependencyTransformer: DependencyTransformer = {
268
263
  transformSyncRequire: () => void 0,
269
264
  transformImportCall: () => void 0,
270
- transformJSResource: () => void 0,
271
265
  transformPrefetch: () => void 0,
272
266
  transformIllegalDynamicRequire: () => void 0,
273
267
  };
@@ -402,7 +396,7 @@ async function transformJS(
402
396
  unstable_allowRequireContext: config.unstable_allowRequireContext,
403
397
  };
404
398
  // $FlowFixMe[unsupported-syntax] dynamic require
405
- const collectDependencies: CollectDependenciesFn<DependencySplitCondition> = require(config.unstable_collectDependenciesPath);
399
+ const collectDependencies: CollectDependenciesFn = require(config.unstable_collectDependenciesPath);
406
400
  ({ast, dependencies, dependencyMapName} = collectDependencies(ast, opts));
407
401
  } catch (error) {
408
402
  if (error instanceof InternalInvalidRequireCallError) {