metro 0.71.2 → 0.71.3

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",
3
- "version": "0.71.2",
3
+ "version": "0.71.3",
4
4
  "description": "🚇 The JavaScript bundler for React Native.",
5
5
  "main": "src/index.js",
6
6
  "bin": "src/cli.js",
@@ -36,22 +36,22 @@
36
36
  "invariant": "^2.2.4",
37
37
  "jest-worker": "^27.2.0",
38
38
  "lodash.throttle": "^4.1.1",
39
- "metro-babel-transformer": "0.71.2",
40
- "metro-cache": "0.71.2",
41
- "metro-cache-key": "0.71.2",
42
- "metro-config": "0.71.2",
43
- "metro-core": "0.71.2",
44
- "metro-file-map": "0.71.2",
45
- "metro-hermes-compiler": "0.71.2",
46
- "metro-inspector-proxy": "0.71.2",
47
- "metro-minify-uglify": "0.71.2",
48
- "metro-react-native-babel-preset": "0.71.2",
49
- "metro-resolver": "0.71.2",
50
- "metro-runtime": "0.71.2",
51
- "metro-source-map": "0.71.2",
52
- "metro-symbolicate": "0.71.2",
53
- "metro-transform-plugins": "0.71.2",
54
- "metro-transform-worker": "0.71.2",
39
+ "metro-babel-transformer": "0.71.3",
40
+ "metro-cache": "0.71.3",
41
+ "metro-cache-key": "0.71.3",
42
+ "metro-config": "0.71.3",
43
+ "metro-core": "0.71.3",
44
+ "metro-file-map": "0.71.3",
45
+ "metro-hermes-compiler": "0.71.3",
46
+ "metro-inspector-proxy": "0.71.3",
47
+ "metro-minify-uglify": "0.71.3",
48
+ "metro-react-native-babel-preset": "0.71.3",
49
+ "metro-resolver": "0.71.3",
50
+ "metro-runtime": "0.71.3",
51
+ "metro-source-map": "0.71.3",
52
+ "metro-symbolicate": "0.71.3",
53
+ "metro-transform-plugins": "0.71.3",
54
+ "metro-transform-worker": "0.71.3",
55
55
  "mime-types": "^2.1.27",
56
56
  "node-fetch": "^2.2.0",
57
57
  "nullthrows": "^1.1.1",
@@ -70,10 +70,10 @@
70
70
  "babel-jest": "^26.6.3",
71
71
  "dedent": "^0.7.0",
72
72
  "jest-snapshot": "^26.5.2",
73
- "metro-babel-register": "0.71.2",
74
- "metro-memory-fs": "0.71.2",
75
- "metro-react-native-babel-preset": "0.71.2",
76
- "metro-react-native-babel-transformer": "0.71.2",
73
+ "metro-babel-register": "0.71.3",
74
+ "metro-memory-fs": "0.71.3",
75
+ "metro-react-native-babel-preset": "0.71.3",
76
+ "metro-react-native-babel-transformer": "0.71.3",
77
77
  "stack-trace": "^0.0.10"
78
78
  },
79
79
  "license": "MIT"
@@ -130,6 +130,8 @@ class DeltaCalculator extends EventEmitter {
130
130
  getGraph() {
131
131
  return this._graph;
132
132
  }
133
+ /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
134
+ * LTI update could not be added via codemod */
133
135
 
134
136
  _handleMultipleFileChanges = ({ eventsQueue }) => {
135
137
  eventsQueue.forEach(this._handleFileChange);
@@ -158,6 +158,8 @@ class DeltaCalculator<T> extends EventEmitter {
158
158
  return this._graph;
159
159
  }
160
160
 
161
+ /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
162
+ * LTI update could not be added via codemod */
161
163
  _handleMultipleFileChanges = ({eventsQueue}) => {
162
164
  eventsQueue.forEach(this._handleFileChange);
163
165
  };
@@ -136,7 +136,7 @@ class WorkerFarm {
136
136
  return null;
137
137
  }
138
138
 
139
- _formatGenericError(err, filename: string): TransformError {
139
+ _formatGenericError(err: any, filename: string): TransformError {
140
140
  const error = new TransformError(`${filename}: ${err.message}`);
141
141
 
142
142
  return Object.assign(error, {
@@ -145,7 +145,7 @@ class WorkerFarm {
145
145
  });
146
146
  }
147
147
 
148
- _formatBabelError(err, filename: string): TransformError {
148
+ _formatBabelError(err: any, filename: string): TransformError {
149
149
  const error = new TransformError(
150
150
  `${err.type || 'Error'}${
151
151
  err.message.includes(filename) ? '' : ' in ' + filename
@@ -56,7 +56,7 @@ const NULL_MODULE: Moduleish = {
56
56
  };
57
57
 
58
58
  const NODE_MODULES = path.sep + 'node_modules' + path.sep;
59
- const isNodeModules = file => file.includes(NODE_MODULES);
59
+ const isNodeModules = (file: string) => file.includes(NODE_MODULES);
60
60
 
61
61
  // This function maps the ModuleGraph data structure to metro-file-map's ModuleMap
62
62
  const createModuleMap = ({
@@ -64,6 +64,11 @@ const createModuleMap = ({
64
64
  moduleCache,
65
65
  sourceExts,
66
66
  platforms,
67
+ }: {
68
+ files: Array<string>,
69
+ moduleCache: ModuleCache,
70
+ platforms: void | $ReadOnlyArray<string>,
71
+ sourceExts: Extensions,
67
72
  }): ModuleMapData => {
68
73
  const platformSet = new Set(
69
74
  (platforms ?? defaults.platforms).concat([NATIVE_PLATFORM]),
@@ -142,7 +147,7 @@ exports.createResolveFn = function (options: ResolveOptions): ResolveFn {
142
147
  );
143
148
 
144
149
  const assetExtensions = new Set(assetExts.map(asset => '.' + asset));
145
- const isAssetFile = file => assetExtensions.has(path.extname(file));
150
+ const isAssetFile = (file: string) => assetExtensions.has(path.extname(file));
146
151
 
147
152
  const moduleResolver = new ModuleResolver({
148
153
  dirExists: (filePath: string): boolean => hasteFS.dirExists(filePath),
@@ -62,11 +62,11 @@ type InlineModuleIdsOptions = $ReadOnly<{
62
62
  }>;
63
63
 
64
64
  // TS detection conditions copied from metro-react-native-babel-preset
65
- function isTypeScriptSource(fileName) {
65
+ function isTypeScriptSource(fileName: string) {
66
66
  return !!fileName && fileName.endsWith('.ts');
67
67
  }
68
68
 
69
- function isTSXSource(fileName) {
69
+ function isTSXSource(fileName: string) {
70
70
  return !!fileName && fileName.endsWith('.tsx');
71
71
  }
72
72
 
@@ -12,11 +12,12 @@
12
12
  const { Console } = require("console");
13
13
 
14
14
  const { Writable } = require("stream");
15
- /* $FlowFixMe(>=0.97.0 site=react_native_fb) This comment suppresses an error
16
- * found when Flow v0.97 was deployed. To see the error delete this comment and
17
- * run Flow. */
18
15
 
19
- const write = (_, __, callback) => callback();
16
+ const write = (_, __, callback) =>
17
+ /* $FlowFixMe(>=0.97.0 site=react_native_fb) This comment suppresses an error
18
+ * found when Flow v0.97 was deployed. To see the error delete this comment and
19
+ * run Flow. */
20
+ callback();
20
21
 
21
22
  module.exports = new Console(
22
23
  new Writable({
@@ -13,8 +13,12 @@
13
13
  const {Console} = require('console');
14
14
  const {Writable} = require('stream');
15
15
 
16
- /* $FlowFixMe(>=0.97.0 site=react_native_fb) This comment suppresses an error
17
- * found when Flow v0.97 was deployed. To see the error delete this comment and
18
- * run Flow. */
19
- const write = (_, __, callback) => callback();
16
+ const write = (
17
+ _: Buffer | string | Array<{chunk: Buffer | string, encoding: string, ...}>,
18
+ __: string | ((error?: Error) => void),
19
+ callback: void | ((error?: Error) => void),
20
+ /* $FlowFixMe(>=0.97.0 site=react_native_fb) This comment suppresses an error
21
+ * found when Flow v0.97 was deployed. To see the error delete this comment and
22
+ * run Flow. */
23
+ ) => callback();
20
24
  module.exports = (new Console(new Writable({write, writev: write})): Console);
@@ -175,7 +175,10 @@ function collectDependencies<TSplitCondition = void>(
175
175
  };
176
176
 
177
177
  const visitor = {
178
- CallExpression(path, state): void {
178
+ CallExpression(
179
+ path: NodePath<BabelNodeCallExpression>,
180
+ state: State<TSplitCondition>,
181
+ ): void {
179
182
  if (visited.has(path.node)) {
180
183
  return;
181
184
  }
@@ -254,7 +257,7 @@ function collectDependencies<TSplitCondition = void>(
254
257
  ExportNamedDeclaration: collectImports,
255
258
  ExportAllDeclaration: collectImports,
256
259
 
257
- Program(path, state) {
260
+ Program(path: NodePath<BabelNodeProgram>, state: State<TSplitCondition>) {
258
261
  state.asyncRequireModulePathStringLiteral = types.stringLiteral(
259
262
  options.asyncRequireModulePath,
260
263
  );
package/src/Server.js CHANGED
@@ -660,6 +660,8 @@ class Server {
660
660
 
661
661
  const serializer =
662
662
  this._config.serializer.customSerializer ||
663
+ /* $FlowFixMe[missing-local-annot] The type annotation(s) required by
664
+ * Flow's LTI update could not be added via codemod */
663
665
  ((...args) => bundleToString(baseJSBundle(...args)).code);
664
666
 
665
667
  const bundle = await serializer(
@@ -9,6 +9,8 @@
9
9
  */
10
10
 
11
11
  'use strict';
12
+
13
+ import type {StackFrameOutput} from './Server/symbolicate';
12
14
  import type {AssetData} from './Assets';
13
15
  import type {ExplodedSourceMap} from './DeltaBundler/Serializers/getExplodedSourceMap';
14
16
  import type {RamBundleInfo} from './DeltaBundler/Serializers/getRamBundleInfo';
@@ -733,6 +735,8 @@ class Server {
733
735
 
734
736
  const serializer =
735
737
  this._config.serializer.customSerializer ||
738
+ /* $FlowFixMe[missing-local-annot] The type annotation(s) required by
739
+ * Flow's LTI update could not be added via codemod */
736
740
  ((...args) => bundleToString(baseJSBundle(...args)).code);
737
741
 
738
742
  const bundle = await serializer(
@@ -1011,7 +1015,10 @@ class Server {
1011
1015
  });
1012
1016
 
1013
1017
  async _symbolicate(req: IncomingMessage, res: ServerResponse) {
1014
- const getCodeFrame = (urls, symbolicatedStack) => {
1018
+ const getCodeFrame = (
1019
+ urls: Set<string>,
1020
+ symbolicatedStack: $ReadOnlyArray<StackFrameOutput>,
1021
+ ) => {
1015
1022
  for (let i = 0; i < symbolicatedStack.length; i++) {
1016
1023
  const {collapse, column, file, lineNumber} = symbolicatedStack[i];
1017
1024
  const fileAbsolute = path.resolve(this._config.projectRoot, file ?? '');
@@ -1161,7 +1168,7 @@ class Server {
1161
1168
  }
1162
1169
 
1163
1170
  async _resolveRelativePath(
1164
- filePath,
1171
+ filePath: string,
1165
1172
  {
1166
1173
  transformOptions,
1167
1174
  relativeTo,
@@ -25,7 +25,7 @@ function getIgnorePattern(config: ConfigT): RegExp {
25
25
  return / ^/;
26
26
  }
27
27
 
28
- const combine = regexes =>
28
+ const combine = (regexes: Array<RegExp>) =>
29
29
  new RegExp(
30
30
  regexes
31
31
  .map(regex => '(' + regex.source.replace(/\//g, path.sep) + ')')
@@ -115,6 +115,8 @@ class DependencyGraph extends EventEmitter {
115
115
 
116
116
  return null;
117
117
  }
118
+ /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
119
+ * LTI update could not be added via codemod */
118
120
 
119
121
  _onHasteChange({ eventsQueue, hasteFS, moduleMap }) {
120
122
  this._hasteFS = hasteFS;
@@ -33,7 +33,7 @@ const {DuplicateHasteCandidatesError} = MetroFileMapModuleMap;
33
33
 
34
34
  function getOrCreate<T>(
35
35
  map: Map<string, Map<string, T>>,
36
- field,
36
+ field: string,
37
37
  ): Map<string, T> {
38
38
  let subMap = map.get(field);
39
39
  if (!subMap) {
@@ -131,6 +131,8 @@ class DependencyGraph extends EventEmitter {
131
131
  return null;
132
132
  }
133
133
 
134
+ /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
135
+ * LTI update could not be added via codemod */
134
136
  _onHasteChange({eventsQueue, hasteFS, moduleMap}) {
135
137
  this._hasteFS = hasteFS;
136
138
  this._resolutionCache = new Map();