metro 0.85.0 → 0.86.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",
3
- "version": "0.85.0",
3
+ "version": "0.86.0",
4
4
  "description": "🚇 The JavaScript bundler for React Native.",
5
5
  "main": "src/index.js",
6
6
  "bin": "src/cli.js",
@@ -39,18 +39,18 @@
39
39
  "jest-worker": "^29.7.0",
40
40
  "jsc-safe-url": "^0.2.2",
41
41
  "lodash.throttle": "^4.1.1",
42
- "metro-babel-transformer": "0.85.0",
43
- "metro-cache": "0.85.0",
44
- "metro-cache-key": "0.85.0",
45
- "metro-config": "0.85.0",
46
- "metro-core": "0.85.0",
47
- "metro-file-map": "0.85.0",
48
- "metro-resolver": "0.85.0",
49
- "metro-runtime": "0.85.0",
50
- "metro-source-map": "0.85.0",
51
- "metro-symbolicate": "0.85.0",
52
- "metro-transform-plugins": "0.85.0",
53
- "metro-transform-worker": "0.85.0",
42
+ "metro-babel-transformer": "0.86.0",
43
+ "metro-cache": "0.86.0",
44
+ "metro-cache-key": "0.86.0",
45
+ "metro-config": "0.86.0",
46
+ "metro-core": "0.86.0",
47
+ "metro-file-map": "0.86.0",
48
+ "metro-resolver": "0.86.0",
49
+ "metro-runtime": "0.86.0",
50
+ "metro-source-map": "0.86.0",
51
+ "metro-symbolicate": "0.86.0",
52
+ "metro-transform-plugins": "0.86.0",
53
+ "metro-transform-worker": "0.86.0",
54
54
  "mime-types": "^3.0.1",
55
55
  "nullthrows": "^1.1.1",
56
56
  "serialize-error": "^2.1.0",
@@ -71,7 +71,7 @@
71
71
  "dedent": "^0.7.0",
72
72
  "jest-snapshot": "^29.7.0",
73
73
  "jest-snapshot-serializer-raw": "^1.2.0",
74
- "metro-babel-register": "0.85.0",
74
+ "metro-babel-register": "0.86.0",
75
75
  "metro-memory-fs": "*",
76
76
  "mock-req": "^0.2.0",
77
77
  "mock-res": "^0.6.0",
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @noformat
8
8
  * @oncall react_native
9
- * @generated SignedSource<<623892927b76c4f68802bb69f19d9974>>
9
+ * @generated SignedSource<<2f0ab0435f64798986366df74674d02a>>
10
10
  *
11
11
  * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
12
  * Original file: packages/metro/src/DeltaBundler/Serializers/getExplodedSourceMap.js
@@ -19,10 +19,11 @@ import type {Module} from '../types';
19
19
  import type {
20
20
  FBSourceFunctionMap,
21
21
  MetroSourceMapSegmentTuple,
22
+ VlqMap,
22
23
  } from 'metro-source-map';
23
24
 
24
25
  export type ExplodedSourceMap = ReadonlyArray<{
25
- readonly map: Array<MetroSourceMapSegmentTuple>;
26
+ readonly map: Array<MetroSourceMapSegmentTuple> | VlqMap;
26
27
  readonly firstLine1Based: number;
27
28
  readonly functionMap: null | undefined | FBSourceFunctionMap;
28
29
  readonly path: string;
@@ -13,12 +13,13 @@ import type {Module} from '../types';
13
13
  import type {
14
14
  FBSourceFunctionMap,
15
15
  MetroSourceMapSegmentTuple,
16
+ VlqMap,
16
17
  } from 'metro-source-map';
17
18
 
18
19
  import {getJsOutput, isJsModule} from './helpers/js';
19
20
 
20
21
  export type ExplodedSourceMap = ReadonlyArray<{
21
- readonly map: Array<MetroSourceMapSegmentTuple>,
22
+ readonly map: Array<MetroSourceMapSegmentTuple> | VlqMap,
22
23
  readonly firstLine1Based: number,
23
24
  readonly functionMap: ?FBSourceFunctionMap,
24
25
  readonly path: string,
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @noformat
8
8
  * @oncall react_native
9
- * @generated SignedSource<<cd7e523b4fdfbff33e663b21c4529401>>
9
+ * @generated SignedSource<<af4dc08fc7e742357f7e2c12d3c89662>>
10
10
  *
11
11
  * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
12
  * Original file: packages/metro/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js
@@ -19,6 +19,7 @@ import type {Module} from '../../types';
19
19
  import type {
20
20
  FBSourceFunctionMap,
21
21
  MetroSourceMapSegmentTuple,
22
+ VlqMap,
22
23
  } from 'metro-source-map';
23
24
 
24
25
  declare function getSourceMapInfo(
@@ -29,7 +30,7 @@ declare function getSourceMapInfo(
29
30
  getSourceUrl: null | undefined | ((module: Module) => string);
30
31
  },
31
32
  ): {
32
- readonly map: Array<MetroSourceMapSegmentTuple>;
33
+ readonly map: Array<MetroSourceMapSegmentTuple> | VlqMap;
33
34
  readonly functionMap: null | undefined | FBSourceFunctionMap;
34
35
  readonly code: string;
35
36
  readonly path: string;
@@ -13,6 +13,7 @@ import type {Module} from '../../types';
13
13
  import type {
14
14
  FBSourceFunctionMap,
15
15
  MetroSourceMapSegmentTuple,
16
+ VlqMap,
16
17
  } from 'metro-source-map';
17
18
 
18
19
  import {getJsOutput} from './js';
@@ -25,7 +26,7 @@ export default function getSourceMapInfo(
25
26
  getSourceUrl: ?(module: Module<>) => string,
26
27
  },
27
28
  ): {
28
- readonly map: Array<MetroSourceMapSegmentTuple>,
29
+ readonly map: Array<MetroSourceMapSegmentTuple> | VlqMap,
29
30
  readonly functionMap: ?FBSourceFunctionMap,
30
31
  readonly code: string,
31
32
  readonly path: string,
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @noformat
8
8
  * @oncall react_native
9
- * @generated SignedSource<<49bc83c20821024a7b77f5d5c3168d62>>
9
+ * @generated SignedSource<<6c7d6cff28e917c03235af1d0c98db4e>>
10
10
  *
11
11
  * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
12
  * Original file: packages/metro/src/DeltaBundler/Serializers/sourceMapGenerator.js
@@ -17,7 +17,7 @@
17
17
 
18
18
  import type {Module} from '../types';
19
19
 
20
- import {fromRawMappings, fromRawMappingsNonBlocking} from 'metro-source-map';
20
+ import {fromRawMappingsIndexed} from 'metro-source-map';
21
21
 
22
22
  export type SourceMapGeneratorOptions = Readonly<{
23
23
  excludeSource: boolean;
@@ -28,9 +28,9 @@ export type SourceMapGeneratorOptions = Readonly<{
28
28
  declare function sourceMapGenerator(
29
29
  modules: ReadonlyArray<Module>,
30
30
  options: SourceMapGeneratorOptions,
31
- ): ReturnType<typeof fromRawMappings>;
31
+ ): ReturnType<typeof fromRawMappingsIndexed>;
32
32
  declare function sourceMapGeneratorNonBlocking(
33
33
  modules: ReadonlyArray<Module>,
34
34
  options: SourceMapGeneratorOptions,
35
- ): ReturnType<typeof fromRawMappingsNonBlocking>;
35
+ ): Promise<ReturnType<typeof fromRawMappingsIndexed>>;
36
36
  export {sourceMapGenerator, sourceMapGeneratorNonBlocking};
@@ -66,11 +66,11 @@ function sourceMapGenerator(modules, options) {
66
66
  "Expected getSourceMapInfosImpl() to finish synchronously.",
67
67
  );
68
68
  }
69
- return (0, _metroSourceMap.fromRawMappings)(sourceMapInfos);
69
+ return (0, _metroSourceMap.fromRawMappingsIndexed)(sourceMapInfos);
70
70
  }
71
71
  async function sourceMapGeneratorNonBlocking(modules, options) {
72
72
  const sourceMapInfos = await new Promise((resolve) => {
73
73
  getSourceMapInfosImpl(false, resolve, modules, options);
74
74
  });
75
- return (0, _metroSourceMap.fromRawMappingsNonBlocking)(sourceMapInfos);
75
+ return (0, _metroSourceMap.fromRawMappingsIndexed)(sourceMapInfos);
76
76
  }
@@ -13,7 +13,7 @@ import type {Module} from '../types';
13
13
 
14
14
  import getSourceMapInfo from './helpers/getSourceMapInfo';
15
15
  import {isJsModule} from './helpers/js';
16
- import {fromRawMappings, fromRawMappingsNonBlocking} from 'metro-source-map';
16
+ import {fromRawMappingsIndexed} from 'metro-source-map';
17
17
 
18
18
  export type SourceMapGeneratorOptions = Readonly<{
19
19
  excludeSource: boolean,
@@ -78,7 +78,7 @@ function getSourceMapInfosImpl(
78
78
  function sourceMapGenerator(
79
79
  modules: ReadonlyArray<Module<>>,
80
80
  options: SourceMapGeneratorOptions,
81
- ): ReturnType<typeof fromRawMappings> {
81
+ ): ReturnType<typeof fromRawMappingsIndexed> {
82
82
  let sourceMapInfos;
83
83
  getSourceMapInfosImpl(
84
84
  true,
@@ -93,19 +93,21 @@ function sourceMapGenerator(
93
93
  'Expected getSourceMapInfosImpl() to finish synchronously.',
94
94
  );
95
95
  }
96
- return fromRawMappings(sourceMapInfos);
96
+ return fromRawMappingsIndexed(sourceMapInfos);
97
97
  }
98
98
 
99
99
  async function sourceMapGeneratorNonBlocking(
100
100
  modules: ReadonlyArray<Module<>>,
101
101
  options: SourceMapGeneratorOptions,
102
- ): ReturnType<typeof fromRawMappingsNonBlocking> {
102
+ ): Promise<ReturnType<typeof fromRawMappingsIndexed>> {
103
103
  const sourceMapInfos = await new Promise<
104
104
  ReadonlyArray<ReturnType<typeof getSourceMapInfo>>,
105
105
  >(resolve => {
106
106
  getSourceMapInfosImpl(false, resolve, modules, options);
107
107
  });
108
- return fromRawMappingsNonBlocking(sourceMapInfos);
108
+ // Building an index map is a cheap synchronous passthrough (VLQ maps carry
109
+ // over verbatim); only gathering the per-module info above needs to yield.
110
+ return fromRawMappingsIndexed(sourceMapInfos);
109
111
  }
110
112
 
111
113
  export {sourceMapGenerator, sourceMapGeneratorNonBlocking};
@@ -5,7 +5,67 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = symbolicate;
7
7
  var _search = require("metro-source-map/private/Consumer/search");
8
+ var _LineIndexedMappings = _interopRequireDefault(
9
+ require("metro-source-map/private/LineIndexedMappings"),
10
+ );
8
11
  var _Symbolication = require("metro-symbolicate/private/Symbolication");
12
+ function _interopRequireDefault(e) {
13
+ return e && e.__esModule ? e : { default: e };
14
+ }
15
+ const lineIndexCache = new WeakMap();
16
+ function originalPositionInModule(
17
+ map,
18
+ generatedLine1Based,
19
+ generatedColumn0Based,
20
+ ) {
21
+ if (Array.isArray(map)) {
22
+ return originalPositionInTuples(
23
+ map,
24
+ generatedLine1Based,
25
+ generatedColumn0Based,
26
+ );
27
+ }
28
+ let decoded = lineIndexCache.get(map);
29
+ if (decoded == null) {
30
+ decoded = new _LineIndexedMappings.default(map.mappings);
31
+ lineIndexCache.set(map, decoded);
32
+ }
33
+ return decoded.originalPositionFor(
34
+ generatedLine1Based,
35
+ generatedColumn0Based,
36
+ );
37
+ }
38
+ function originalPositionInTuples(
39
+ mappings,
40
+ generatedLine1Based,
41
+ generatedColumn0Based,
42
+ ) {
43
+ const target = {
44
+ line1Based: generatedLine1Based,
45
+ column0Based: generatedColumn0Based,
46
+ };
47
+ const mappingIndex = (0, _search.greatestLowerBound)(
48
+ mappings,
49
+ target,
50
+ (t, candidate) => {
51
+ if (t.line1Based === candidate[0]) {
52
+ return t.column0Based - candidate[1];
53
+ }
54
+ return t.line1Based - candidate[0];
55
+ },
56
+ );
57
+ if (mappingIndex == null) {
58
+ return null;
59
+ }
60
+ const mapping = mappings[mappingIndex];
61
+ if (mapping[0] !== target.line1Based || mapping.length < 4) {
62
+ return null;
63
+ }
64
+ return {
65
+ line1Based: mapping[2],
66
+ column0Based: mapping[3],
67
+ };
68
+ }
9
69
  function createFunctionNameGetter(module) {
10
70
  const consumer = new _Symbolication.SourceMetadataMapConsumer(
11
71
  {
@@ -46,38 +106,16 @@ async function symbolicate(stack, maps, config, extraData) {
46
106
  return map[moduleIndex];
47
107
  }
48
108
  function findOriginalPos(frame, module) {
49
- if (
50
- module.map == null ||
51
- frame.lineNumber == null ||
52
- frame.column == null
53
- ) {
109
+ const lineNumber = frame.lineNumber;
110
+ const column = frame.column;
111
+ if (module.map == null || lineNumber == null || column == null) {
54
112
  return null;
55
113
  }
56
- const generatedPosInModule = {
57
- line1Based: frame.lineNumber - module.firstLine1Based + 1,
58
- column0Based: frame.column,
59
- };
60
- const mappingIndex = (0, _search.greatestLowerBound)(
114
+ return originalPositionInModule(
61
115
  module.map,
62
- generatedPosInModule,
63
- (target, candidate) => {
64
- if (target.line1Based === candidate[0]) {
65
- return target.column0Based - candidate[1];
66
- }
67
- return target.line1Based - candidate[0];
68
- },
116
+ lineNumber - module.firstLine1Based + 1,
117
+ column,
69
118
  );
70
- if (mappingIndex == null) {
71
- return null;
72
- }
73
- const mapping = module.map[mappingIndex];
74
- if (mapping[0] !== generatedPosInModule.line1Based || mapping.length < 4) {
75
- return null;
76
- }
77
- return {
78
- line1Based: mapping[2],
79
- column0Based: mapping[3],
80
- };
81
119
  }
82
120
  function findFunctionName(originalPos, module) {
83
121
  if (module.functionMap) {
@@ -97,11 +135,6 @@ async function symbolicate(stack, maps, config, extraData) {
97
135
  ...frame,
98
136
  };
99
137
  }
100
- if (!Array.isArray(module.map)) {
101
- throw new Error(
102
- `Unexpected module with serialized source map found: ${module.path}`,
103
- );
104
- }
105
138
  const originalPos = findOriginalPos(frame, module);
106
139
  if (!originalPos) {
107
140
  return {
@@ -12,11 +12,13 @@
12
12
  import type {
13
13
  FBSourceFunctionMap,
14
14
  MetroSourceMapSegmentTuple,
15
+ VlqMap,
15
16
  } from '../../../metro-source-map/src/source-map';
16
17
  import type {ExplodedSourceMap} from '../DeltaBundler/Serializers/getExplodedSourceMap';
17
18
  import type {ConfigT} from 'metro-config';
18
19
 
19
20
  import {greatestLowerBound} from 'metro-source-map/private/Consumer/search';
21
+ import LineIndexedMappings from 'metro-source-map/private/LineIndexedMappings';
20
22
  import {SourceMetadataMapConsumer} from 'metro-symbolicate/private/Symbolication';
21
23
 
22
24
  export type StackFrameInput = {
@@ -35,6 +37,75 @@ export type StackFrameOutput = Readonly<IntermediateStackFrame>;
35
37
  type ExplodedSourceMapModule = ExplodedSourceMap[number];
36
38
  type Position = {readonly line1Based: number, column0Based: number};
37
39
 
40
+ // Cache of per-line indices, keyed on the VlqMap held by the module graph. A
41
+ // WeakMap lets an index outlive the request that built it, so later requests
42
+ // resolving frames in the same module reuse it, and releases it automatically
43
+ // when the module leaves the graph. The index references the graph's existing
44
+ // mappings string and adds only O(lines) integers, so retaining it alongside
45
+ // the graph stays cheap.
46
+ const lineIndexCache: WeakMap<VlqMap, LineIndexedMappings> = new WeakMap();
47
+
48
+ // Resolve a generated (line, column) within a module to its original position.
49
+ // Tuple-backed modules keep their decoded segments, so we search them directly;
50
+ // VLQ-backed modules go through a compact per-line `LineIndexedMappings` that
51
+ // decodes only the target line. Byte-identical either way.
52
+ function originalPositionInModule(
53
+ map: Array<MetroSourceMapSegmentTuple> | VlqMap,
54
+ generatedLine1Based: number,
55
+ generatedColumn0Based: number,
56
+ ): ?Position {
57
+ if (Array.isArray(map)) {
58
+ return originalPositionInTuples(
59
+ map,
60
+ generatedLine1Based,
61
+ generatedColumn0Based,
62
+ );
63
+ }
64
+ let decoded = lineIndexCache.get(map);
65
+ if (decoded == null) {
66
+ decoded = new LineIndexedMappings(map.mappings);
67
+ lineIndexCache.set(map, decoded);
68
+ }
69
+ return decoded.originalPositionFor(
70
+ generatedLine1Based,
71
+ generatedColumn0Based,
72
+ );
73
+ }
74
+
75
+ // greatestLowerBound over pre-decoded tuples, ordered by (line, column).
76
+ function originalPositionInTuples(
77
+ mappings: Array<MetroSourceMapSegmentTuple>,
78
+ generatedLine1Based: number,
79
+ generatedColumn0Based: number,
80
+ ): ?Position {
81
+ const target = {
82
+ line1Based: generatedLine1Based,
83
+ column0Based: generatedColumn0Based,
84
+ };
85
+ const mappingIndex = greatestLowerBound(mappings, target, (t, candidate) => {
86
+ if (t.line1Based === candidate[0]) {
87
+ return t.column0Based - candidate[1];
88
+ }
89
+ return t.line1Based - candidate[0];
90
+ });
91
+ if (mappingIndex == null) {
92
+ return null;
93
+ }
94
+ const mapping = mappings[mappingIndex];
95
+ if (
96
+ mapping[0] !== target.line1Based ||
97
+ mapping.length < 4 /* no source line/column info */
98
+ ) {
99
+ return null;
100
+ }
101
+ return {
102
+ // $FlowFixMe[invalid-tuple-index]: Length checks do not refine tuple unions.
103
+ line1Based: mapping[2],
104
+ // $FlowFixMe[invalid-tuple-index]: Length checks do not refine tuple unions.
105
+ column0Based: mapping[3],
106
+ };
107
+ }
108
+
38
109
  function createFunctionNameGetter(
39
110
  module: ExplodedSourceMapModule,
40
111
  ): Position => ?string {
@@ -70,7 +141,7 @@ export default async function symbolicate(
70
141
  {
71
142
  readonly firstLine1Based: number,
72
143
  readonly functionMap: ?FBSourceFunctionMap,
73
- readonly map: Array<MetroSourceMapSegmentTuple>,
144
+ readonly map: Array<MetroSourceMapSegmentTuple> | VlqMap,
74
145
  readonly path: string,
75
146
  },
76
147
  (Position) => ?string,
@@ -96,43 +167,16 @@ export default async function symbolicate(
96
167
  frame: StackFrameInput,
97
168
  module: ExplodedSourceMapModule,
98
169
  ): ?Position {
99
- if (
100
- module.map == null ||
101
- frame.lineNumber == null ||
102
- frame.column == null
103
- ) {
170
+ const lineNumber = frame.lineNumber;
171
+ const column = frame.column;
172
+ if (module.map == null || lineNumber == null || column == null) {
104
173
  return null;
105
174
  }
106
- const generatedPosInModule = {
107
- line1Based: frame.lineNumber - module.firstLine1Based + 1,
108
- column0Based: frame.column,
109
- };
110
- const mappingIndex = greatestLowerBound(
175
+ return originalPositionInModule(
111
176
  module.map,
112
- generatedPosInModule,
113
- (target, candidate) => {
114
- if (target.line1Based === candidate[0]) {
115
- return target.column0Based - candidate[1];
116
- }
117
- return target.line1Based - candidate[0];
118
- },
177
+ lineNumber - module.firstLine1Based + 1,
178
+ column,
119
179
  );
120
- if (mappingIndex == null) {
121
- return null;
122
- }
123
- const mapping = module.map[mappingIndex];
124
- if (
125
- mapping[0] !== generatedPosInModule.line1Based ||
126
- mapping.length < 4 /* no source line/column info */
127
- ) {
128
- return null;
129
- }
130
- return {
131
- // $FlowFixMe[invalid-tuple-index]: Length checks do not refine tuple unions.
132
- line1Based: mapping[2],
133
- // $FlowFixMe[invalid-tuple-index]: Length checks do not refine tuple unions.
134
- column0Based: mapping[3],
135
- };
136
180
  }
137
181
 
138
182
  function findFunctionName(
@@ -140,7 +184,7 @@ export default async function symbolicate(
140
184
  module: {
141
185
  readonly firstLine1Based: number,
142
186
  readonly functionMap: ?FBSourceFunctionMap,
143
- readonly map: Array<MetroSourceMapSegmentTuple>,
187
+ readonly map: Array<MetroSourceMapSegmentTuple> | VlqMap,
144
188
  readonly path: string,
145
189
  },
146
190
  ): ?string {
@@ -160,11 +204,6 @@ export default async function symbolicate(
160
204
  if (!module) {
161
205
  return {...frame};
162
206
  }
163
- if (!Array.isArray(module.map)) {
164
- throw new Error(
165
- `Unexpected module with serialized source map found: ${module.path}`,
166
- );
167
- }
168
207
  const originalPos = findOriginalPos(frame, module);
169
208
  if (!originalPos) {
170
209
  return {...frame};
package/src/index.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @noformat
8
8
  * @oncall react_native
9
- * @generated SignedSource<<3c6460427c6760887187d6b16151c609>>
9
+ * @generated SignedSource<<8cfd5068558051749a42bc72eb4b915f>>
10
10
  *
11
11
  * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
12
  * Original file: packages/metro/src/index.flow.js
@@ -182,25 +182,3 @@ export declare const attachMetroCli: (
182
182
  options?: AttachMetroCLIOptions,
183
183
  ) => Yargs;
184
184
  export declare type attachMetroCli = typeof attachMetroCli;
185
- /**
186
- * Backwards-compatibility with CommonJS consumers using interopRequireDefault.
187
- * Do not add to this list.
188
- *
189
- * @deprecated Default import from 'metro' is deprecated, use named exports.
190
- */
191
- declare const $$EXPORT_DEFAULT_DECLARATION$$: {
192
- attachMetroCli: typeof attachMetroCli;
193
- runServer: typeof runServer;
194
- Terminal: typeof Terminal;
195
- JsonReporter: typeof JsonReporter;
196
- TerminalReporter: typeof TerminalReporter;
197
- loadConfig: typeof loadConfig;
198
- mergeConfig: typeof mergeConfig;
199
- resolveConfig: typeof resolveConfig;
200
- createConnectMiddleware: typeof createConnectMiddleware;
201
- runBuild: typeof runBuild;
202
- buildGraph: typeof buildGraph;
203
- };
204
- declare type $$EXPORT_DEFAULT_DECLARATION$$ =
205
- typeof $$EXPORT_DEFAULT_DECLARATION$$;
206
- export default $$EXPORT_DEFAULT_DECLARATION$$;
package/src/index.flow.js CHANGED
@@ -21,8 +21,7 @@ Object.defineProperty(exports, "TerminalReporter", {
21
21
  return _TerminalReporter.default;
22
22
  },
23
23
  });
24
- exports.default =
25
- exports.createConnectMiddleware =
24
+ exports.createConnectMiddleware =
26
25
  exports.buildGraph =
27
26
  exports.attachMetroCli =
28
27
  void 0;
@@ -458,16 +457,3 @@ async function earlyPortCheck(host, port) {
458
457
  await new Promise((resolve) => server.close(() => resolve()));
459
458
  }
460
459
  }
461
- var _default = (exports.default = {
462
- attachMetroCli,
463
- runServer,
464
- Terminal: _metroCore.Terminal,
465
- JsonReporter: _JsonReporter.default,
466
- TerminalReporter: _TerminalReporter.default,
467
- loadConfig: _metroConfig.loadConfig,
468
- mergeConfig: _metroConfig.mergeConfig,
469
- resolveConfig: _metroConfig.resolveConfig,
470
- createConnectMiddleware,
471
- runBuild,
472
- buildGraph,
473
- });
@@ -587,23 +587,3 @@ async function earlyPortCheck(host: void | string, port: number) {
587
587
  await new Promise(resolve => server.close(() => resolve()));
588
588
  }
589
589
  }
590
-
591
- /**
592
- * Backwards-compatibility with CommonJS consumers using interopRequireDefault.
593
- * Do not add to this list.
594
- *
595
- * @deprecated Default import from 'metro' is deprecated, use named exports.
596
- */
597
- export default {
598
- attachMetroCli,
599
- runServer,
600
- Terminal,
601
- JsonReporter,
602
- TerminalReporter,
603
- loadConfig,
604
- mergeConfig,
605
- resolveConfig,
606
- createConnectMiddleware,
607
- runBuild,
608
- buildGraph,
609
- };
@@ -36,36 +36,29 @@ function _interopRequireWildcard(e, t) {
36
36
  function _interopRequireDefault(e) {
37
37
  return e && e.__esModule ? e : { default: e };
38
38
  }
39
- function getIgnorePattern(config) {
40
- const { blockList, blacklistRE } = config.resolver;
41
- const ignorePattern = blacklistRE || blockList;
42
- if (!ignorePattern) {
43
- return / ^/;
39
+ const flattenBlockList = (regexes) => {
40
+ if (!Array.isArray(regexes)) {
41
+ return regexes;
44
42
  }
45
- const combine = (regexes) =>
46
- new RegExp(
47
- regexes
48
- .map((regex, index) => {
49
- if (regex.flags !== regexes[0].flags) {
50
- throw new Error(
51
- "Cannot combine blockList patterns, because they have different flags:\n" +
52
- " - Pattern 0: " +
53
- regexes[0].toString() +
54
- "\n" +
55
- ` - Pattern ${index}: ` +
56
- regexes[index].toString(),
57
- );
58
- }
59
- return "(" + regex.source + ")";
60
- })
61
- .join("|"),
62
- regexes[0]?.flags ?? "",
63
- );
64
- if (Array.isArray(ignorePattern)) {
65
- return combine(ignorePattern);
66
- }
67
- return ignorePattern;
68
- }
43
+ return new RegExp(
44
+ regexes
45
+ .map((regex, index) => {
46
+ if (regex.flags !== regexes[0].flags) {
47
+ throw new Error(
48
+ "Cannot combine blockList patterns, because they have different flags:\n" +
49
+ " - Pattern 0: " +
50
+ regexes[0].toString() +
51
+ "\n" +
52
+ ` - Pattern ${index}: ` +
53
+ regexes[index].toString(),
54
+ );
55
+ }
56
+ return "(" + regex.source + ")";
57
+ })
58
+ .join("|"),
59
+ regexes[0]?.flags ?? "",
60
+ );
61
+ };
69
62
  function createFileMap(config, options) {
70
63
  const watch = options?.watch == null ? !_ciInfo.default.isCI : options.watch;
71
64
  const { enabled: autoSaveEnabled, ...autoSaveOpts } =
@@ -115,7 +108,7 @@ function createFileMap(config, options) {
115
108
  ]),
116
109
  ),
117
110
  healthCheck: config.watcher.healthCheck,
118
- ignorePattern: getIgnorePattern(config),
111
+ ignorePattern: flattenBlockList(config.resolver.blockList),
119
112
  maxWorkers: config.maxWorkers,
120
113
  plugins,
121
114
  retainAllFiles: true,
@@ -19,43 +19,29 @@ import MetroFileMap, {
19
19
  HastePlugin,
20
20
  } from 'metro-file-map';
21
21
 
22
- function getIgnorePattern(config: ConfigT): RegExp {
23
- // For now we support both options
24
- const {blockList, blacklistRE} = config.resolver;
25
- const ignorePattern = blacklistRE || blockList;
26
-
27
- // If neither option has been set, use default pattern
28
- if (!ignorePattern) {
29
- return / ^/;
30
- }
31
-
32
- const combine = (regexes: Array<RegExp>) =>
33
- new RegExp(
34
- regexes
35
- .map((regex, index) => {
36
- if (regex.flags !== regexes[0].flags) {
37
- throw new Error(
38
- 'Cannot combine blockList patterns, because they have different flags:\n' +
39
- ' - Pattern 0: ' +
40
- regexes[0].toString() +
41
- '\n' +
42
- ` - Pattern ${index}: ` +
43
- regexes[index].toString(),
44
- );
45
- }
46
- return '(' + regex.source + ')';
47
- })
48
- .join('|'),
49
- regexes[0]?.flags ?? '',
50
- );
51
-
52
- // If ignorePattern is an array, merge it into one
53
- if (Array.isArray(ignorePattern)) {
54
- return combine(ignorePattern);
22
+ const flattenBlockList = (regexes: ConfigT['resolver']['blockList']) => {
23
+ if (!Array.isArray(regexes)) {
24
+ return regexes;
55
25
  }
56
-
57
- return ignorePattern;
58
- }
26
+ return new RegExp(
27
+ regexes
28
+ .map((regex, index) => {
29
+ if (regex.flags !== regexes[0].flags) {
30
+ throw new Error(
31
+ 'Cannot combine blockList patterns, because they have different flags:\n' +
32
+ ' - Pattern 0: ' +
33
+ regexes[0].toString() +
34
+ '\n' +
35
+ ` - Pattern ${index}: ` +
36
+ regexes[index].toString(),
37
+ );
38
+ }
39
+ return '(' + regex.source + ')';
40
+ })
41
+ .join('|'),
42
+ regexes[0]?.flags ?? '',
43
+ );
44
+ };
59
45
 
60
46
  export default function createFileMap(
61
47
  config: ConfigT,
@@ -126,7 +112,7 @@ export default function createFileMap(
126
112
  ]),
127
113
  ),
128
114
  healthCheck: config.watcher.healthCheck,
129
- ignorePattern: getIgnorePattern(config),
115
+ ignorePattern: flattenBlockList(config.resolver.blockList),
130
116
  maxWorkers: config.maxWorkers,
131
117
  plugins,
132
118
  retainAllFiles: true,