metro-transform-worker 0.83.2 → 0.83.4

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.83.2",
3
+ "version": "0.83.4",
4
4
  "description": "🚇 Transform worker for Metro.",
5
5
  "main": "src/index.js",
6
6
  "exports": {
@@ -19,17 +19,17 @@
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
21
  "@babel/core": "^7.25.2",
22
- "@babel/generator": "^7.25.0",
23
- "@babel/parser": "^7.25.3",
24
- "@babel/types": "^7.25.2",
22
+ "@babel/generator": "^7.29.1",
23
+ "@babel/parser": "^7.29.0",
24
+ "@babel/types": "^7.29.0",
25
25
  "flow-enums-runtime": "^0.0.6",
26
- "metro": "0.83.2",
27
- "metro-babel-transformer": "0.83.2",
28
- "metro-cache": "0.83.2",
29
- "metro-cache-key": "0.83.2",
30
- "metro-minify-terser": "0.83.2",
31
- "metro-source-map": "0.83.2",
32
- "metro-transform-plugins": "0.83.2",
26
+ "metro": "0.83.4",
27
+ "metro-babel-transformer": "0.83.4",
28
+ "metro-cache": "0.83.4",
29
+ "metro-cache-key": "0.83.4",
30
+ "metro-minify-terser": "0.83.4",
31
+ "metro-source-map": "0.83.4",
32
+ "metro-transform-plugins": "0.83.4",
33
33
  "nullthrows": "^1.1.1"
34
34
  },
35
35
  "devDependencies": {
package/src/index.js CHANGED
@@ -30,30 +30,41 @@ var JsFileWrapping = _interopRequireWildcard(
30
30
  );
31
31
  var _nullthrows = _interopRequireDefault(require("nullthrows"));
32
32
  function _interopRequireDefault(e) {
33
- return e && e.__esModule ? e : { default: e };
34
- }
35
- function _getRequireWildcardCache(e) {
36
- if ("function" != typeof WeakMap) return null;
37
- var r = new WeakMap(),
38
- t = new WeakMap();
39
- return (_getRequireWildcardCache = function (e) {
40
- return e ? t : r;
41
- })(e);
33
+ return e && e.__esModule
34
+ ? e
35
+ : {
36
+ default: e,
37
+ };
42
38
  }
43
- function _interopRequireWildcard(e, r) {
44
- if (!r && e && e.__esModule) return e;
45
- if (null === e || ("object" != typeof e && "function" != typeof e))
46
- return { default: e };
47
- var t = _getRequireWildcardCache(r);
48
- if (t && t.has(e)) return t.get(e);
49
- var n = { __proto__: null },
50
- a = Object.defineProperty && Object.getOwnPropertyDescriptor;
51
- for (var u in e)
52
- if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
53
- var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
54
- i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
39
+ function _interopRequireWildcard(e, t) {
40
+ if ("function" == typeof WeakMap)
41
+ var r = new WeakMap(),
42
+ n = new WeakMap();
43
+ return (_interopRequireWildcard = function (e, t) {
44
+ if (!t && e && e.__esModule) return e;
45
+ var o,
46
+ i,
47
+ f = {
48
+ __proto__: null,
49
+ default: e,
50
+ };
51
+ if (null === e || ("object" != typeof e && "function" != typeof e))
52
+ return f;
53
+ if ((o = t ? n : r)) {
54
+ if (o.has(e)) return o.get(e);
55
+ o.set(e, f);
55
56
  }
56
- return ((n.default = e), t && t.set(e, n), n);
57
+ for (const t in e)
58
+ "default" !== t &&
59
+ {}.hasOwnProperty.call(e, t) &&
60
+ ((i =
61
+ (o = Object.defineProperty) &&
62
+ Object.getOwnPropertyDescriptor(e, t)) &&
63
+ (i.get || i.set)
64
+ ? o(f, t, i)
65
+ : (f[t] = e[t]));
66
+ return f;
67
+ })(e, t);
57
68
  }
58
69
  const InternalInvalidRequireCallError =
59
70
  _collectDependencies.default.InvalidRequireCallError;
@@ -83,21 +94,21 @@ const minifyCode = async (
83
94
  const sourceMap = (0, _metroSourceMap.fromRawMappings)([
84
95
  {
85
96
  code,
86
- source,
87
- map,
88
97
  functionMap: null,
89
- path: filename,
90
98
  isIgnored: false,
99
+ map,
100
+ path: filename,
101
+ source,
91
102
  },
92
103
  ]).toMap(undefined, {});
93
104
  const minify = (0, _getMinifier.default)(config.minifierPath);
94
105
  try {
95
106
  const minified = await minify({
96
107
  code,
97
- map: sourceMap,
108
+ config: config.minifierConfig,
98
109
  filename,
110
+ map: sourceMap,
99
111
  reserved,
100
- config: config.minifierConfig,
101
112
  });
102
113
  return {
103
114
  code: minified.code,
@@ -117,11 +128,11 @@ const minifyCode = async (
117
128
  }
118
129
  };
119
130
  const disabledDependencyTransformer = {
120
- transformSyncRequire: () => void 0,
131
+ transformIllegalDynamicRequire: () => void 0,
121
132
  transformImportCall: () => void 0,
122
133
  transformImportMaybeSyncCall: () => void 0,
123
134
  transformPrefetch: () => void 0,
124
- transformIllegalDynamicRequire: () => void 0,
135
+ transformSyncRequire: () => void 0,
125
136
  };
126
137
  class InvalidRequireCallError extends Error {
127
138
  constructor(innerError, filename) {
@@ -182,13 +193,13 @@ async function transformJS(file, { config, options, projectRoot }) {
182
193
  (0, _core.transformFromAstSync)(ast, "", {
183
194
  ast: true,
184
195
  babelrc: false,
196
+ cloneInputAst: true,
185
197
  code: false,
186
- configFile: false,
187
198
  comments: true,
199
+ configFile: false,
188
200
  filename: file.filename,
189
201
  plugins,
190
202
  sourceMaps: false,
191
- cloneInputAst: true,
192
203
  }).ast,
193
204
  );
194
205
  if (!options.dev) {
@@ -196,13 +207,13 @@ async function transformJS(file, { config, options, projectRoot }) {
196
207
  (0, _core.transformFromAstSync)(ast, "", {
197
208
  ast: true,
198
209
  babelrc: false,
210
+ cloneInputAst: false,
199
211
  code: false,
200
- configFile: false,
201
212
  comments: true,
213
+ configFile: false,
202
214
  filename: file.filename,
203
215
  plugins: [_metroTransformPlugins.default.constantFoldingPlugin],
204
216
  sourceMaps: false,
205
- cloneInputAst: false,
206
217
  }).ast,
207
218
  );
208
219
  }
@@ -216,7 +227,9 @@ async function transformJS(file, { config, options, projectRoot }) {
216
227
  try {
217
228
  const importDeclarationLocs = file.unstable_importDeclarationLocs ?? null;
218
229
  const opts = {
230
+ allowOptionalDependencies: config.allowOptionalDependencies,
219
231
  asyncRequireModulePath: config.asyncRequireModulePath,
232
+ dependencyMapName: config.unstable_dependencyMapReservedName,
220
233
  dependencyTransformer:
221
234
  config.unstable_disableModuleWrapping === true
222
235
  ? disabledDependencyTransformer
@@ -227,8 +240,6 @@ async function transformJS(file, { config, options, projectRoot }) {
227
240
  ),
228
241
  inlineableCalls: [importDefault, importAll],
229
242
  keepRequireNames: options.dev,
230
- allowOptionalDependencies: config.allowOptionalDependencies,
231
- dependencyMapName: config.unstable_dependencyMapReservedName,
232
243
  unstable_allowRequireContext: config.unstable_allowRequireContext,
233
244
  unstable_isESMImportAtSource:
234
245
  importDeclarationLocs != null
@@ -317,9 +328,9 @@ async function transformJS(file, { config, options, projectRoot }) {
317
328
  {
318
329
  data: {
319
330
  code,
331
+ functionMap: file.functionMap,
320
332
  lineCount,
321
333
  map,
322
- functionMap: file.functionMap,
323
334
  },
324
335
  type: file.type,
325
336
  },
@@ -338,9 +349,9 @@ async function transformAsset(file, context) {
338
349
  );
339
350
  const jsFile = {
340
351
  ...file,
341
- type: "js/module/asset",
342
352
  ast: result.ast,
343
353
  functionMap: null,
354
+ type: "js/module/asset",
344
355
  };
345
356
  return transformJS(jsFile, context);
346
357
  }
@@ -406,9 +417,9 @@ async function transformJSON(file, { options, config, projectRoot }) {
406
417
  {
407
418
  data: {
408
419
  code,
420
+ functionMap: null,
409
421
  lineCount,
410
422
  map,
411
- functionMap: null,
412
423
  },
413
424
  type: jsType,
414
425
  },
@@ -442,8 +453,8 @@ function getBabelTransformArgs(
442
453
  const transform = async (config, projectRoot, filename, data, options) => {
443
454
  const context = {
444
455
  config,
445
- projectRoot,
446
456
  options,
457
+ projectRoot,
447
458
  };
448
459
  const sourceCode = data.toString("utf8");
449
460
  const reservedStrings = [];
@@ -469,28 +480,28 @@ const transform = async (config, projectRoot, filename, data, options) => {
469
480
  }
470
481
  if (filename.endsWith(".json")) {
471
482
  const jsonFile = {
483
+ code: sourceCode,
472
484
  filename,
473
485
  inputFileSize: data.length,
474
- code: sourceCode,
475
486
  type: options.type,
476
487
  };
477
488
  return await transformJSON(jsonFile, context);
478
489
  }
479
490
  if (options.type === "asset") {
480
491
  const file = {
492
+ code: sourceCode,
481
493
  filename,
482
494
  inputFileSize: data.length,
483
- code: sourceCode,
484
495
  type: options.type,
485
496
  };
486
497
  return await transformAsset(file, context);
487
498
  }
488
499
  const file = {
500
+ code: sourceCode,
489
501
  filename,
502
+ functionMap: null,
490
503
  inputFileSize: data.length,
491
- code: sourceCode,
492
504
  type: options.type === "script" ? "js/script" : "js/module",
493
- functionMap: null,
494
505
  };
495
506
  return await transformJSWithBabel(file, context);
496
507
  };
package/src/index.js.flow CHANGED
@@ -60,13 +60,13 @@ import nullthrows from 'nullthrows';
60
60
  const InternalInvalidRequireCallError =
61
61
  collectDependencies.InvalidRequireCallError;
62
62
 
63
- type MinifierConfig = $ReadOnly<{[string]: mixed, ...}>;
63
+ type MinifierConfig = Readonly<{[string]: unknown, ...}>;
64
64
 
65
65
  export type MinifierOptions = {
66
66
  code: string,
67
67
  map: ?BasicSourceMap,
68
68
  filename: string,
69
- reserved: $ReadOnlyArray<string>,
69
+ reserved: ReadonlyArray<string>,
70
70
  config: MinifierConfig,
71
71
  ...
72
72
  };
@@ -83,8 +83,8 @@ export type Minifier = MinifierOptions =>
83
83
 
84
84
  export type Type = 'script' | 'module' | 'asset';
85
85
 
86
- export type JsTransformerConfig = $ReadOnly<{
87
- assetPlugins: $ReadOnlyArray<string>,
86
+ export type JsTransformerConfig = Readonly<{
87
+ assetPlugins: ReadonlyArray<string>,
88
88
  assetRegistryPath: string,
89
89
  asyncRequireModulePath: string,
90
90
  babelTransformerPath: string,
@@ -107,50 +107,50 @@ export type JsTransformerConfig = $ReadOnly<{
107
107
  /** With inlineRequires, enable a module-scope memo var and inline as (v || v=require('foo')) */
108
108
  unstable_memoizeInlineRequires?: boolean,
109
109
  /** With inlineRequires, do not memoize these module specifiers */
110
- unstable_nonMemoizedInlineRequires?: $ReadOnlyArray<string>,
110
+ unstable_nonMemoizedInlineRequires?: ReadonlyArray<string>,
111
111
  /** Whether to rename scoped `require` functions to `_$$_REQUIRE`, usually an extraneous operation when serializing to iife (default). */
112
112
  unstable_renameRequire?: boolean,
113
113
  }>;
114
114
 
115
115
  export type {CustomTransformOptions} from 'metro-babel-transformer';
116
116
 
117
- export type JsTransformOptions = $ReadOnly<{
117
+ export type JsTransformOptions = Readonly<{
118
118
  customTransformOptions?: CustomTransformOptions,
119
119
  dev: boolean,
120
120
  experimentalImportSupport?: boolean,
121
121
  inlinePlatform: boolean,
122
122
  inlineRequires: boolean,
123
123
  minify: boolean,
124
- nonInlinedRequires?: $ReadOnlyArray<string>,
124
+ nonInlinedRequires?: ReadonlyArray<string>,
125
125
  platform: ?string,
126
126
  type: Type,
127
127
  unstable_memoizeInlineRequires?: boolean,
128
- unstable_nonMemoizedInlineRequires?: $ReadOnlyArray<string>,
128
+ unstable_nonMemoizedInlineRequires?: ReadonlyArray<string>,
129
129
  unstable_staticHermesOptimizedRequire?: boolean,
130
130
  unstable_transformProfile: TransformProfile,
131
131
  }>;
132
132
 
133
133
  opaque type Path = string;
134
134
 
135
- type BaseFile = $ReadOnly<{
135
+ type BaseFile = Readonly<{
136
136
  code: string,
137
137
  filename: Path,
138
138
  inputFileSize: number,
139
139
  }>;
140
140
 
141
- type AssetFile = $ReadOnly<{
141
+ type AssetFile = Readonly<{
142
142
  ...BaseFile,
143
143
  type: 'asset',
144
144
  }>;
145
145
 
146
146
  type JSFileType = 'js/script' | 'js/module' | 'js/module/asset';
147
147
 
148
- type JSFile = $ReadOnly<{
148
+ type JSFile = Readonly<{
149
149
  ...BaseFile,
150
150
  ast?: ?BabelNodeFile,
151
151
  type: JSFileType,
152
152
  functionMap: FBSourceFunctionMap | null,
153
- unstable_importDeclarationLocs?: ?$ReadOnlySet<string>,
153
+ unstable_importDeclarationLocs?: ?ReadonlySet<string>,
154
154
  }>;
155
155
 
156
156
  type JSONFile = {
@@ -158,14 +158,14 @@ type JSONFile = {
158
158
  type: Type,
159
159
  };
160
160
 
161
- type TransformationContext = $ReadOnly<{
161
+ type TransformationContext = Readonly<{
162
162
  config: JsTransformerConfig,
163
163
  projectRoot: Path,
164
164
  options: JsTransformOptions,
165
165
  }>;
166
166
 
167
- export type JsOutput = $ReadOnly<{
168
- data: $ReadOnly<{
167
+ export type JsOutput = Readonly<{
168
+ data: Readonly<{
169
169
  code: string,
170
170
  lineCount: number,
171
171
  map: Array<MetroSourceMapSegmentTuple>,
@@ -174,9 +174,9 @@ export type JsOutput = $ReadOnly<{
174
174
  type: JSFileType,
175
175
  }>;
176
176
 
177
- type TransformResponse = $ReadOnly<{
178
- dependencies: $ReadOnlyArray<TransformResultDependency>,
179
- output: $ReadOnlyArray<JsOutput>,
177
+ type TransformResponse = Readonly<{
178
+ dependencies: ReadonlyArray<TransformResultDependency>,
179
+ output: ReadonlyArray<JsOutput>,
180
180
  }>;
181
181
 
182
182
  function getDynamicDepsBehavior(
@@ -190,7 +190,7 @@ function getDynamicDepsBehavior(
190
190
  const isPackage = /(?:^|[/\\])node_modules[/\\]/.test(filename);
191
191
  return isPackage ? inPackages : 'reject';
192
192
  default:
193
- (inPackages: empty);
193
+ inPackages as empty;
194
194
  throw new Error(
195
195
  `invalid value for dynamic deps behavior: \`${inPackages}\``,
196
196
  );
@@ -204,7 +204,7 @@ const minifyCode = async (
204
204
  code: string,
205
205
  source: string,
206
206
  map: Array<MetroSourceMapSegmentTuple>,
207
- reserved?: $ReadOnlyArray<string> = [],
207
+ reserved?: ReadonlyArray<string> = [],
208
208
  ): Promise<{
209
209
  code: string,
210
210
  map: Array<MetroSourceMapSegmentTuple>,
@@ -213,13 +213,13 @@ const minifyCode = async (
213
213
  const sourceMap = fromRawMappings([
214
214
  {
215
215
  code,
216
- source,
217
- map,
218
216
  // functionMap is overridden by the serializer
219
217
  functionMap: null,
220
- path: filename,
221
218
  // isIgnored is overriden by the serializer
222
219
  isIgnored: false,
220
+ map,
221
+ path: filename,
222
+ source,
223
223
  },
224
224
  ]).toMap(undefined, {});
225
225
 
@@ -228,10 +228,10 @@ const minifyCode = async (
228
228
  try {
229
229
  const minified = await minify({
230
230
  code,
231
- map: sourceMap,
231
+ config: config.minifierConfig,
232
232
  filename,
233
+ map: sourceMap,
233
234
  reserved,
234
- config: config.minifierConfig,
235
235
  });
236
236
 
237
237
  return {
@@ -252,11 +252,11 @@ const minifyCode = async (
252
252
  };
253
253
 
254
254
  const disabledDependencyTransformer: DependencyTransformer = {
255
- transformSyncRequire: () => void 0,
255
+ transformIllegalDynamicRequire: () => void 0,
256
256
  transformImportCall: () => void 0,
257
257
  transformImportMaybeSyncCall: () => void 0,
258
258
  transformPrefetch: () => void 0,
259
- transformIllegalDynamicRequire: () => void 0,
259
+ transformSyncRequire: () => void 0,
260
260
  };
261
261
 
262
262
  class InvalidRequireCallError extends Error {
@@ -337,18 +337,18 @@ async function transformJS(
337
337
  transformFromAstSync(ast, '', {
338
338
  ast: true,
339
339
  babelrc: false,
340
- code: false,
341
- configFile: false,
342
- comments: true,
343
- filename: file.filename,
344
- plugins,
345
- sourceMaps: false,
346
340
  // Not-Cloning the input AST here should be safe because other code paths above this call
347
341
  // are mutating the AST as well and no code is depending on the original AST.
348
342
  // However, switching the flag to false caused issues with ES Modules if `experimentalImportSupport` isn't used https://github.com/facebook/metro/issues/641
349
343
  // either because one of the plugins is doing something funky or Babel messes up some caches.
350
344
  // Make sure to test the above mentioned case before flipping the flag back to false.
351
345
  cloneInputAst: true,
346
+ code: false,
347
+ comments: true,
348
+ configFile: false,
349
+ filename: file.filename,
350
+ plugins,
351
+ sourceMaps: false,
352
352
  }).ast,
353
353
  );
354
354
 
@@ -360,13 +360,13 @@ async function transformJS(
360
360
  transformFromAstSync(ast, '', {
361
361
  ast: true,
362
362
  babelrc: false,
363
+ cloneInputAst: false,
363
364
  code: false,
364
- configFile: false,
365
365
  comments: true,
366
+ configFile: false,
366
367
  filename: file.filename,
367
368
  plugins: [metroTransformPlugins.constantFoldingPlugin],
368
369
  sourceMaps: false,
369
- cloneInputAst: false,
370
370
  }).ast,
371
371
  );
372
372
  }
@@ -386,7 +386,9 @@ async function transformJS(
386
386
  try {
387
387
  const importDeclarationLocs = file.unstable_importDeclarationLocs ?? null;
388
388
  const opts = {
389
+ allowOptionalDependencies: config.allowOptionalDependencies,
389
390
  asyncRequireModulePath: config.asyncRequireModulePath,
391
+ dependencyMapName: config.unstable_dependencyMapReservedName,
390
392
  dependencyTransformer:
391
393
  config.unstable_disableModuleWrapping === true
392
394
  ? disabledDependencyTransformer
@@ -397,8 +399,6 @@ async function transformJS(
397
399
  ),
398
400
  inlineableCalls: [importDefault, importAll],
399
401
  keepRequireNames: options.dev,
400
- allowOptionalDependencies: config.allowOptionalDependencies,
401
- dependencyMapName: config.unstable_dependencyMapReservedName,
402
402
  unstable_allowRequireContext: config.unstable_allowRequireContext,
403
403
  unstable_isESMImportAtSource:
404
404
  importDeclarationLocs != null
@@ -493,9 +493,9 @@ async function transformJS(
493
493
  {
494
494
  data: {
495
495
  code,
496
+ functionMap: file.functionMap,
496
497
  lineCount,
497
498
  map,
498
- functionMap: file.functionMap,
499
499
  },
500
500
  type: file.type,
501
501
  },
@@ -524,9 +524,9 @@ async function transformAsset(
524
524
 
525
525
  const jsFile = {
526
526
  ...file,
527
- type: 'js/module/asset' as const,
528
527
  ast: result.ast,
529
528
  functionMap: null,
529
+ type: 'js/module/asset' as const,
530
530
  };
531
531
 
532
532
  return transformJS(jsFile, context);
@@ -616,7 +616,7 @@ async function transformJSON(
616
616
  ({lineCount, map} = countLinesAndTerminateMap(code, map));
617
617
  const output: Array<JsOutput> = [
618
618
  {
619
- data: {code, lineCount, map, functionMap: null},
619
+ data: {code, functionMap: null, lineCount, map},
620
620
  type: jsType,
621
621
  },
622
622
  ];
@@ -628,7 +628,7 @@ async function transformJSON(
628
628
  }
629
629
 
630
630
  function getBabelTransformArgs(
631
- file: $ReadOnly<{filename: Path, code: string, ...}>,
631
+ file: Readonly<{filename: Path, code: string, ...}>,
632
632
  {options, config, projectRoot}: TransformationContext,
633
633
  plugins?: Plugins = [],
634
634
  ): BabelTransformerArgs {
@@ -658,8 +658,8 @@ export const transform = async (
658
658
  ): Promise<TransformResponse> => {
659
659
  const context: TransformationContext = {
660
660
  config,
661
- projectRoot,
662
661
  options,
662
+ projectRoot,
663
663
  };
664
664
  const sourceCode = data.toString('utf8');
665
665
 
@@ -687,9 +687,9 @@ export const transform = async (
687
687
 
688
688
  if (filename.endsWith('.json')) {
689
689
  const jsonFile: JSONFile = {
690
+ code: sourceCode,
690
691
  filename,
691
692
  inputFileSize: data.length,
692
- code: sourceCode,
693
693
  type: options.type,
694
694
  };
695
695
 
@@ -698,9 +698,9 @@ export const transform = async (
698
698
 
699
699
  if (options.type === 'asset') {
700
700
  const file: AssetFile = {
701
+ code: sourceCode,
701
702
  filename,
702
703
  inputFileSize: data.length,
703
- code: sourceCode,
704
704
  type: options.type,
705
705
  };
706
706
 
@@ -708,11 +708,11 @@ export const transform = async (
708
708
  }
709
709
 
710
710
  const file: JSFile = {
711
+ code: sourceCode,
711
712
  filename,
713
+ functionMap: null,
712
714
  inputFileSize: data.length,
713
- code: sourceCode,
714
715
  type: options.type === 'script' ? 'js/script' : 'js/module',
715
- functionMap: null,
716
716
  };
717
717
 
718
718
  return await transformJSWithBabel(file, context);
@@ -743,7 +743,7 @@ export const getCacheKey = (config: JsTransformerConfig): string => {
743
743
 
744
744
  function countLinesAndTerminateMap(
745
745
  code: string,
746
- map: $ReadOnlyArray<MetroSourceMapSegmentTuple>,
746
+ map: ReadonlyArray<MetroSourceMapSegmentTuple>,
747
747
  ): {
748
748
  lineCount: number,
749
749
  map: Array<MetroSourceMapSegmentTuple>,
@@ -8,7 +8,11 @@ var _Assets = require("metro/private/Assets");
8
8
  var _util = require("metro/private/Bundler/util");
9
9
  var _path = _interopRequireDefault(require("path"));
10
10
  function _interopRequireDefault(e) {
11
- return e && e.__esModule ? e : { default: e };
11
+ return e && e.__esModule
12
+ ? e
13
+ : {
14
+ default: e,
15
+ };
12
16
  }
13
17
  async function transform(
14
18
  { filename, options, src },
@@ -19,7 +19,7 @@ import path from 'path';
19
19
  export async function transform(
20
20
  {filename, options, src}: BabelTransformerArgs,
21
21
  assetRegistryPath: string,
22
- assetDataPlugins: $ReadOnlyArray<string>,
22
+ assetDataPlugins: ReadonlyArray<string>,
23
23
  ): Promise<{ast: File, ...}> {
24
24
  options = options || {
25
25
  platform: '',
package/src/index.d.ts DELETED
@@ -1,138 +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
- * @oncall react_native
9
- */
10
-
11
- import type {DynamicRequiresBehavior} from 'metro';
12
- import type {
13
- CustomTransformOptions,
14
- TransformProfile,
15
- } from 'metro-babel-transformer';
16
- import type {
17
- BasicSourceMap,
18
- FBSourceFunctionMap,
19
- MetroSourceMapSegmentTuple,
20
- } from 'metro-source-map';
21
- import type {TransformResultDependency} from 'metro/private/DeltaBundler';
22
- import type {AllowOptionalDependencies} from 'metro/private/DeltaBundler/types';
23
-
24
- export type MinifierConfig = Readonly<Record<string, unknown>>;
25
-
26
- export interface MinifierOptions {
27
- code: string;
28
- map?: BasicSourceMap;
29
- filename: string;
30
- reserved: ReadonlyArray<string>;
31
- config: MinifierConfig;
32
- }
33
-
34
- export interface MinifierResult {
35
- code: string;
36
- map?: BasicSourceMap;
37
- }
38
-
39
- export type Minifier = (
40
- options: MinifierOptions,
41
- ) => MinifierResult | Promise<MinifierResult>;
42
-
43
- export type Type = 'script' | 'module' | 'asset';
44
-
45
- export type JsTransformerConfig = Readonly<{
46
- assetPlugins: ReadonlyArray<string>;
47
- assetRegistryPath: string;
48
- asyncRequireModulePath: string;
49
- babelTransformerPath: string;
50
- dynamicDepsInPackages: DynamicRequiresBehavior;
51
- enableBabelRCLookup: boolean;
52
- enableBabelRuntime: boolean;
53
- globalPrefix: string;
54
- hermesParser: boolean;
55
- minifierConfig: MinifierConfig;
56
- minifierPath: string;
57
- optimizationSizeLimit: number;
58
- publicPath: string;
59
- allowOptionalDependencies: AllowOptionalDependencies;
60
- unstable_collectDependenciesPath: string;
61
- unstable_dependencyMapReservedName?: string;
62
- unstable_disableModuleWrapping: boolean;
63
- unstable_disableNormalizePseudoGlobals: boolean;
64
- unstable_compactOutput: boolean;
65
- /** Enable `require.context` statements which can be used to import multiple files in a directory. */
66
- unstable_allowRequireContext: boolean;
67
- /** With inlineRequires, enable a module-scope memo var and inline as (v || v=require('foo')) */
68
- unstable_memoizeInlineRequires?: boolean;
69
- /** With inlineRequires, do not memoize these module specifiers */
70
- unstable_nonMemoizedInlineRequires?: ReadonlyArray<string>;
71
- /** Whether to rename scoped `require` functions to `_$$_REQUIRE`, usually an extraneous operation when serializing to iife (default). */
72
- unstable_renameRequire?: boolean;
73
- }>;
74
-
75
- export {CustomTransformOptions} from 'metro-babel-transformer';
76
-
77
- export type JsTransformOptions = Readonly<{
78
- customTransformOptions?: CustomTransformOptions;
79
- dev: boolean;
80
- experimentalImportSupport?: boolean;
81
- inlinePlatform: boolean;
82
- inlineRequires: boolean;
83
- minify: boolean;
84
- nonInlinedRequires?: ReadonlyArray<string>;
85
- platform?: string;
86
- runtimeBytecodeVersion?: number;
87
- type: Type;
88
- unstable_transformProfile: TransformProfile;
89
- }>;
90
-
91
- export type BytecodeFileType =
92
- | 'bytecode/module'
93
- | 'bytecode/module/asset'
94
- | 'bytecode/script';
95
-
96
- export type JSFileType = 'js/script' | 'js/module' | 'js/module/asset';
97
-
98
- export type JsOutput = Readonly<{
99
- data: Readonly<{
100
- code: string;
101
- lineCount: number;
102
- map: MetroSourceMapSegmentTuple[];
103
- functionMap: FBSourceFunctionMap | null;
104
- }>;
105
- type: JSFileType;
106
- }>;
107
-
108
- // Hermes byte-code output type
109
- export type BytecodeOutput = unknown;
110
-
111
- export type TransformResponse = Readonly<{
112
- dependencies: ReadonlyArray<TransformResultDependency>;
113
- output: ReadonlyArray<JsOutput | BytecodeOutput>;
114
- }>;
115
-
116
- export function transform(
117
- config: JsTransformerConfig,
118
- projectRoot: string,
119
- filename: string,
120
- data: Buffer,
121
- options: JsTransformOptions,
122
- ): Promise<TransformResponse>;
123
-
124
- export function getCacheKey(config: JsTransformerConfig): string;
125
-
126
- /**
127
- * Backwards-compatibility with CommonJS consumers using interopRequireDefault.
128
- * Do not add to this list.
129
- *
130
- * @deprecated Default import from 'metro-transform-worker' is deprecated, use named exports.
131
- */
132
- declare const $$EXPORT_DEFAULT_DECLARATION$$: {
133
- getCacheKey: typeof getCacheKey;
134
- transform: typeof transform;
135
- };
136
- declare type $$EXPORT_DEFAULT_DECLARATION$$ =
137
- typeof $$EXPORT_DEFAULT_DECLARATION$$;
138
- export default $$EXPORT_DEFAULT_DECLARATION$$;