metro-transform-worker 0.83.5 → 0.83.7

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.5",
3
+ "version": "0.83.7",
4
4
  "description": "🚇 Transform worker for Metro.",
5
5
  "main": "src/index.js",
6
6
  "exports": {
@@ -24,13 +24,13 @@
24
24
  "@babel/parser": "^7.29.0",
25
25
  "@babel/types": "^7.29.0",
26
26
  "flow-enums-runtime": "^0.0.6",
27
- "metro": "0.83.5",
28
- "metro-babel-transformer": "0.83.5",
29
- "metro-cache": "0.83.5",
30
- "metro-cache-key": "0.83.5",
31
- "metro-minify-terser": "0.83.5",
32
- "metro-source-map": "0.83.5",
33
- "metro-transform-plugins": "0.83.5",
27
+ "metro": "0.83.7",
28
+ "metro-babel-transformer": "0.83.7",
29
+ "metro-cache": "0.83.7",
30
+ "metro-cache-key": "0.83.7",
31
+ "metro-minify-terser": "0.83.7",
32
+ "metro-source-map": "0.83.7",
33
+ "metro-transform-plugins": "0.83.7",
34
34
  "nullthrows": "^1.1.1"
35
35
  },
36
36
  "devDependencies": {
package/src/index.d.ts CHANGED
@@ -4,8 +4,15 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @format
7
+ * @noformat
8
8
  * @oncall react_native
9
+ * @generated SignedSource<<165882da0b131608da36b1cbd00ecf28>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro-transform-worker/src/index.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
9
16
  */
10
17
 
11
18
  import type {
@@ -100,7 +107,10 @@ export declare const transform: (
100
107
  options: JsTransformOptions,
101
108
  ) => Promise<TransformResponse>;
102
109
  export declare type transform = typeof transform;
103
- export declare const getCacheKey: (config: JsTransformerConfig) => string;
110
+ export declare const getCacheKey: (
111
+ config: JsTransformerConfig,
112
+ opts?: Readonly<{projectRoot: string}>,
113
+ ) => string;
104
114
  export declare type getCacheKey = typeof getCacheKey;
105
115
  /**
106
116
  * Backwards-compatibility with CommonJS consumers using interopRequireDefault.
package/src/index.js CHANGED
@@ -499,7 +499,7 @@ const transform = async (config, projectRoot, filename, data, options) => {
499
499
  return await transformJSWithBabel(file, context);
500
500
  };
501
501
  exports.transform = transform;
502
- const getCacheKey = (config) => {
502
+ const getCacheKey = (config, opts) => {
503
503
  const { babelTransformerPath, minifierPath, ...remainingConfig } = config;
504
504
  const filesKey = (0, _metroCacheKey.getCacheKey)([
505
505
  __filename,
@@ -512,10 +512,16 @@ const getCacheKey = (config) => {
512
512
  ..._metroTransformPlugins.default.getTransformPluginCacheKeyFiles(),
513
513
  ]);
514
514
  const babelTransformer = require(babelTransformerPath);
515
+ const babelTransformerCacheKey = babelTransformer.getCacheKey
516
+ ? babelTransformer.getCacheKey({
517
+ projectRoot: opts?.projectRoot,
518
+ enableBabelRCLookup: config.enableBabelRCLookup,
519
+ })
520
+ : "";
515
521
  return [
516
522
  filesKey,
517
523
  (0, _metroCache.stableHash)(remainingConfig).toString("hex"),
518
- babelTransformer.getCacheKey ? babelTransformer.getCacheKey() : "",
524
+ babelTransformerCacheKey,
519
525
  ].join("$");
520
526
  };
521
527
  exports.getCacheKey = getCacheKey;
package/src/index.js.flow CHANGED
@@ -215,7 +215,7 @@ const minifyCode = async (
215
215
  code,
216
216
  // functionMap is overridden by the serializer
217
217
  functionMap: null,
218
- // isIgnored is overriden by the serializer
218
+ // isIgnored is overridden by the serializer
219
219
  isIgnored: false,
220
220
  map,
221
221
  path: filename,
@@ -376,7 +376,7 @@ async function transformJS(
376
376
  let wrappedAst;
377
377
 
378
378
  // If the module to transform is a script (meaning that is not part of the
379
- // dependency graph and it code will just be prepended to the bundle modules),
379
+ // dependency graph and its code will just be prepended to the bundle modules),
380
380
  // we need to wrap it differently than a commonJS module (also, scripts do
381
381
  // not have dependencies).
382
382
  if (file.type === 'js/script') {
@@ -718,7 +718,10 @@ export const transform = async (
718
718
  return await transformJSWithBabel(file, context);
719
719
  };
720
720
 
721
- export const getCacheKey = (config: JsTransformerConfig): string => {
721
+ export const getCacheKey = (
722
+ config: JsTransformerConfig,
723
+ opts?: Readonly<{projectRoot: string, ...}>,
724
+ ): string => {
722
725
  const {babelTransformerPath, minifierPath, ...remainingConfig} = config;
723
726
 
724
727
  const filesKey = metroGetCacheKey([
@@ -733,11 +736,20 @@ export const getCacheKey = (config: JsTransformerConfig): string => {
733
736
  ]);
734
737
 
735
738
  // $FlowFixMe[unsupported-syntax]
736
- const babelTransformer = require(babelTransformerPath);
739
+ const babelTransformer = require(babelTransformerPath) as BabelTransformer;
740
+
741
+ // Get cache key from babel transformer, which may include user's babel config files
742
+ const babelTransformerCacheKey = babelTransformer.getCacheKey
743
+ ? babelTransformer.getCacheKey({
744
+ projectRoot: opts?.projectRoot,
745
+ enableBabelRCLookup: config.enableBabelRCLookup,
746
+ })
747
+ : '';
748
+
737
749
  return [
738
750
  filesKey,
739
751
  stableHash(remainingConfig).toString('hex'),
740
- babelTransformer.getCacheKey ? babelTransformer.getCacheKey() : '',
752
+ babelTransformerCacheKey,
741
753
  ].join('$');
742
754
  };
743
755
 
@@ -4,8 +4,15 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @format
7
+ * @noformat
8
8
  * @oncall react_native
9
+ * @generated SignedSource<<b122890ad90539195b3a9805a1a7e02f>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro-transform-worker/src/utils/assetTransformer.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
9
16
  */
10
17
 
11
18
  import type {File} from '@babel/types';
@@ -4,8 +4,15 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @format
7
+ * @noformat
8
8
  * @oncall react_native
9
+ * @generated SignedSource<<410ba17e82af72676f3993ebd1d0f60f>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro-transform-worker/src/utils/getMinifier.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
9
16
  */
10
17
 
11
18
  import type {Minifier} from '../index.js';