metro 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.
Files changed (63) hide show
  1. package/package.json +23 -24
  2. package/src/Assets.js +2 -2
  3. package/src/Assets.js.flow +1 -1
  4. package/src/DeltaBundler/DeltaCalculator.js +18 -11
  5. package/src/DeltaBundler/DeltaCalculator.js.flow +15 -11
  6. package/src/DeltaBundler/Graph.js +11 -28
  7. package/src/DeltaBundler/Graph.js.flow +7 -0
  8. package/src/DeltaBundler/Serializers/helpers/js.js +2 -7
  9. package/src/DeltaBundler/types.flow.js.flow +2 -7
  10. package/src/HmrServer.js +9 -32
  11. package/src/IncrementalBundler.js +9 -9
  12. package/src/IncrementalBundler.js.flow +4 -0
  13. package/src/ModuleGraph/worker/collectDependencies.js +53 -89
  14. package/src/ModuleGraph/worker/collectDependencies.js.flow +113 -141
  15. package/src/Server/symbolicate.js +1 -5
  16. package/src/Server.js +15 -53
  17. package/src/Server.js.flow +5 -0
  18. package/src/commands/dependencies.js +1 -5
  19. package/src/index.flow.js +1 -2
  20. package/src/integration_tests/basic_bundle/TestBigInt.js +0 -3
  21. package/src/integration_tests/basic_bundle/TestBigInt.js.flow +0 -3
  22. package/src/integration_tests/basic_bundle/require-context/mode-sync.js +1 -0
  23. package/src/integration_tests/basic_bundle/require-context/mode-sync.js.flow +1 -0
  24. package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js +28 -0
  25. package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js.flow +33 -0
  26. package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js +20 -0
  27. package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js.flow +23 -0
  28. package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js +18 -0
  29. package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js.flow +21 -0
  30. package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js +28 -0
  31. package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js.flow +33 -0
  32. package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/counter-module.js +19 -0
  33. package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/counter-module.js.flow +18 -0
  34. package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/throwing-module.js +13 -0
  35. package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/throwing-module.js.flow +11 -0
  36. package/src/integration_tests/basic_bundle/require-resolveWeak/utils.js +1 -0
  37. package/src/integration_tests/basic_bundle/require-resolveWeak/utils.js.flow +14 -0
  38. package/src/lib/CountingSet.js +1 -5
  39. package/src/lib/RamBundleParser.js +0 -1
  40. package/src/lib/RamBundleParser.js.flow +0 -1
  41. package/src/lib/TerminalReporter.js +9 -17
  42. package/src/lib/TerminalReporter.js.flow +7 -0
  43. package/src/lib/contextModuleTemplates.js +1 -1
  44. package/src/lib/contextModuleTemplates.js.flow +1 -1
  45. package/src/lib/formatBundlingError.js +0 -3
  46. package/src/lib/formatBundlingError.js.flow +0 -3
  47. package/src/lib/getAppendScripts.js +0 -3
  48. package/src/lib/getAppendScripts.js.flow +0 -3
  49. package/src/lib/getGraphId.js +2 -11
  50. package/src/lib/getPrependedScripts.js +2 -1
  51. package/src/lib/getPrependedScripts.js.flow +2 -1
  52. package/src/lib/reporting.js.flow +4 -0
  53. package/src/lib/transformHelpers.js +16 -22
  54. package/src/lib/transformHelpers.js.flow +7 -8
  55. package/src/node-haste/DependencyGraph/ModuleResolution.js +13 -11
  56. package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +17 -5
  57. package/src/node-haste/DependencyGraph/createHasteMap.js +13 -38
  58. package/src/node-haste/DependencyGraph/createHasteMap.js.flow +2 -1
  59. package/src/node-haste/DependencyGraph.js +28 -22
  60. package/src/node-haste/DependencyGraph.js.flow +25 -9
  61. package/src/node-haste/Module.js +5 -3
  62. package/src/node-haste/Module.js.flow +2 -3
  63. package/src/node-haste/ModuleCache.js +1 -5
@@ -28,7 +28,7 @@ function createFileMap(
28
28
  let filePath = path.relative(modulePath, file);
29
29
 
30
30
  if (os.platform() === 'win32') {
31
- filePath = filePath.replace(/\\/g, '/');
31
+ filePath = filePath.replaceAll('\\', '/');
32
32
  }
33
33
 
34
34
  // NOTE(EvanBacon): I'd prefer we prevent the ability for a module to require itself (`require.context('./')`)
@@ -59,7 +59,6 @@ function formatBundlingError(error) {
59
59
  } else if (error instanceof ResourceNotFoundError) {
60
60
  return {
61
61
  type: "ResourceNotFoundError",
62
- // $FlowFixMe[missing-empty-array-annot]
63
62
  // $FlowFixMe[incompatible-return]
64
63
  errors: [],
65
64
  message: error.message,
@@ -67,7 +66,6 @@ function formatBundlingError(error) {
67
66
  } else if (error instanceof GraphNotFoundError) {
68
67
  return {
69
68
  type: "GraphNotFoundError",
70
- // $FlowFixMe[missing-empty-array-annot]
71
69
  // $FlowFixMe[incompatible-return]
72
70
  errors: [],
73
71
  message: error.message,
@@ -75,7 +73,6 @@ function formatBundlingError(error) {
75
73
  } else if (error instanceof RevisionNotFoundError) {
76
74
  return {
77
75
  type: "RevisionNotFoundError",
78
- // $FlowFixMe[missing-empty-array-annot]
79
76
  // $FlowFixMe[incompatible-return]
80
77
  errors: [],
81
78
  message: error.message,
@@ -74,7 +74,6 @@ function formatBundlingError(error: CustomError): FormattedError {
74
74
  } else if (error instanceof ResourceNotFoundError) {
75
75
  return {
76
76
  type: 'ResourceNotFoundError',
77
- // $FlowFixMe[missing-empty-array-annot]
78
77
  // $FlowFixMe[incompatible-return]
79
78
  errors: [],
80
79
  message: error.message,
@@ -82,7 +81,6 @@ function formatBundlingError(error: CustomError): FormattedError {
82
81
  } else if (error instanceof GraphNotFoundError) {
83
82
  return {
84
83
  type: 'GraphNotFoundError',
85
- // $FlowFixMe[missing-empty-array-annot]
86
84
  // $FlowFixMe[incompatible-return]
87
85
  errors: [],
88
86
  message: error.message,
@@ -90,7 +88,6 @@ function formatBundlingError(error: CustomError): FormattedError {
90
88
  } else if (error instanceof RevisionNotFoundError) {
91
89
  return {
92
90
  type: 'RevisionNotFoundError',
93
- // $FlowFixMe[missing-empty-array-annot]
94
91
  // $FlowFixMe[incompatible-return]
95
92
  errors: [],
96
93
  message: error.message,
@@ -39,7 +39,6 @@ function getAppendScripts(entryPoint, modules, options) {
39
39
  data: {
40
40
  code,
41
41
  lineCount: countLines(code),
42
- // $FlowFixMe[missing-empty-array-annot]
43
42
  map: [],
44
43
  },
45
44
  },
@@ -69,7 +68,6 @@ function getAppendScripts(entryPoint, modules, options) {
69
68
  data: {
70
69
  code,
71
70
  lineCount: countLines(code),
72
- // $FlowFixMe[missing-empty-array-annot]
73
71
  map: [],
74
72
  },
75
73
  },
@@ -89,7 +87,6 @@ function getAppendScripts(entryPoint, modules, options) {
89
87
  data: {
90
88
  code,
91
89
  lineCount: countLines(code),
92
- // $FlowFixMe[missing-empty-array-annot]
93
90
  map: [],
94
91
  },
95
92
  },
@@ -58,7 +58,6 @@ function getAppendScripts<T: number | string>(
58
58
  data: {
59
59
  code,
60
60
  lineCount: countLines(code),
61
- // $FlowFixMe[missing-empty-array-annot]
62
61
  map: [],
63
62
  },
64
63
  },
@@ -90,7 +89,6 @@ function getAppendScripts<T: number | string>(
90
89
  data: {
91
90
  code,
92
91
  lineCount: countLines(code),
93
- // $FlowFixMe[missing-empty-array-annot]
94
92
  map: [],
95
93
  },
96
94
  },
@@ -111,7 +109,6 @@ function getAppendScripts<T: number | string>(
111
109
  data: {
112
110
  code,
113
111
  lineCount: countLines(code),
114
- // $FlowFixMe[missing-empty-array-annot]
115
112
  map: [],
116
113
  },
117
114
  },
@@ -22,21 +22,12 @@ function getGraphId(
22
22
  resolverOptions,
23
23
  }
24
24
  ) {
25
- var _resolverOptions$cust, _options$customTransf;
26
25
  return JSON.stringify(
27
26
  {
28
27
  entryFile,
29
28
  options: {
30
- customResolverOptions:
31
- (_resolverOptions$cust = resolverOptions.customResolverOptions) !==
32
- null && _resolverOptions$cust !== void 0
33
- ? _resolverOptions$cust
34
- : {},
35
- customTransformOptions:
36
- (_options$customTransf = options.customTransformOptions) !== null &&
37
- _options$customTransf !== void 0
38
- ? _options$customTransf
39
- : null,
29
+ customResolverOptions: resolverOptions.customResolverOptions ?? {},
30
+ customTransformOptions: options.customTransformOptions ?? null,
40
31
  dev: options.dev,
41
32
  experimentalImportSupport: options.experimentalImportSupport || false,
42
33
  hot: options.hot,
@@ -59,6 +59,8 @@ async function getPrependedScripts(
59
59
  onProgress: null,
60
60
  experimentalImportBundleSupport:
61
61
  config.server.experimentalImportBundleSupport,
62
+ unstable_enablePackageExports:
63
+ config.resolver.unstable_enablePackageExports,
62
64
  shallow: false,
63
65
  }
64
66
  );
@@ -90,7 +92,6 @@ function _getPrelude({ dev, globalPrefix, requireCycleIgnorePatterns }) {
90
92
  data: {
91
93
  code,
92
94
  lineCount: countLines(code),
93
- // $FlowFixMe[missing-empty-array-annot]
94
95
  map: [],
95
96
  },
96
97
  },
@@ -69,6 +69,8 @@ async function getPrependedScripts(
69
69
  onProgress: null,
70
70
  experimentalImportBundleSupport:
71
71
  config.server.experimentalImportBundleSupport,
72
+ unstable_enablePackageExports:
73
+ config.resolver.unstable_enablePackageExports,
72
74
  shallow: false,
73
75
  },
74
76
  );
@@ -113,7 +115,6 @@ function _getPrelude({
113
115
  data: {
114
116
  code,
115
117
  lineCount: countLines(code),
116
- // $FlowFixMe[missing-empty-array-annot]
117
118
  map: [],
118
119
  },
119
120
  },
@@ -127,6 +127,10 @@ export type ReportableEvent =
127
127
  mode: 'BRIDGE' | 'NOBRIDGE',
128
128
  ...
129
129
  }
130
+ | {
131
+ type: 'resolver_warning',
132
+ message: string,
133
+ }
130
134
  | {
131
135
  type: 'transformer_load_started',
132
136
  }
@@ -12,7 +12,12 @@
12
12
  "use strict";
13
13
 
14
14
  var _contextModuleTemplates = require("./contextModuleTemplates");
15
- const path = require("path");
15
+ var _isAssetFile = _interopRequireDefault(
16
+ require("metro-resolver/src/utils/isAssetFile")
17
+ );
18
+ function _interopRequireDefault(obj) {
19
+ return obj && obj.__esModule ? obj : { default: obj };
20
+ }
16
21
  const baseIgnoredInlineRequires = ["React", "react", "react-native"];
17
22
  async function calcTransformerOptions(
18
23
  entryFiles,
@@ -67,6 +72,8 @@ async function calcTransformerOptions(
67
72
  config.server.experimentalImportBundleSupport,
68
73
  unstable_allowRequireContext:
69
74
  config.transformer.unstable_allowRequireContext,
75
+ unstable_enablePackageExports:
76
+ config.resolver.unstable_enablePackageExports,
70
77
  shallow: false,
71
78
  });
72
79
  return Array.from(dependencies.keys());
@@ -82,22 +89,12 @@ async function calcTransformerOptions(
82
89
  );
83
90
  return {
84
91
  ...baseOptions,
85
- inlineRequires:
86
- (transform === null || transform === void 0
87
- ? void 0
88
- : transform.inlineRequires) || false,
89
- experimentalImportSupport:
90
- (transform === null || transform === void 0
91
- ? void 0
92
- : transform.experimentalImportSupport) || false,
92
+ inlineRequires: transform?.inlineRequires || false,
93
+ experimentalImportSupport: transform?.experimentalImportSupport || false,
93
94
  unstable_disableES6Transforms:
94
- (transform === null || transform === void 0
95
- ? void 0
96
- : transform.unstable_disableES6Transforms) || false,
95
+ transform?.unstable_disableES6Transforms || false,
97
96
  nonInlinedRequires:
98
- (transform === null || transform === void 0
99
- ? void 0
100
- : transform.nonInlinedRequires) || baseIgnoredInlineRequires,
97
+ transform?.nonInlinedRequires || baseIgnoredInlineRequires,
101
98
  type: "module",
102
99
  };
103
100
  }
@@ -123,6 +120,7 @@ async function getTransformFn(
123
120
  options,
124
121
  resolverOptions
125
122
  );
123
+ const assetExts = new Set(config.resolver.assetExts);
126
124
  return async (modulePath, requireContext) => {
127
125
  let templateBuffer;
128
126
  if (requireContext) {
@@ -148,11 +146,7 @@ async function getTransformFn(
148
146
  modulePath,
149
147
  {
150
148
  ...transformOptions,
151
- type: getType(
152
- transformOptions.type,
153
- modulePath,
154
- config.resolver.assetExts
155
- ),
149
+ type: getType(transformOptions.type, modulePath, assetExts),
156
150
  inlineRequires: removeInlineRequiresBlockListFromOptions(
157
151
  modulePath,
158
152
  inlineRequires
@@ -166,7 +160,7 @@ function getType(type, filePath, assetExts) {
166
160
  if (type === "script") {
167
161
  return type;
168
162
  }
169
- if (assetExts.indexOf(path.extname(filePath).slice(1)) !== -1) {
163
+ if ((0, _isAssetFile.default)(filePath, assetExts)) {
170
164
  return "asset";
171
165
  }
172
166
  return "module";
@@ -177,7 +171,7 @@ async function getResolveDependencyFn(bundler, platform, resolverOptions) {
177
171
  dependencyGraph.resolveDependency(
178
172
  from,
179
173
  to,
180
- platform !== null && platform !== void 0 ? platform : null,
174
+ platform ?? null,
181
175
  resolverOptions
182
176
  );
183
177
  }
@@ -23,8 +23,8 @@ import type {Type} from 'metro-transform-worker';
23
23
  import type {RequireContext} from './contextModule';
24
24
 
25
25
  import {getContextModuleTemplate} from './contextModuleTemplates';
26
+ import isAssetFile from 'metro-resolver/src/utils/isAssetFile';
26
27
 
27
- const path = require('path');
28
28
  import type {ResolverInputOptions} from '../shared/types.flow';
29
29
 
30
30
  type InlineRequiresRaw = {+blockList: {[string]: true, ...}, ...} | boolean;
@@ -90,6 +90,8 @@ async function calcTransformerOptions(
90
90
  config.server.experimentalImportBundleSupport,
91
91
  unstable_allowRequireContext:
92
92
  config.transformer.unstable_allowRequireContext,
93
+ unstable_enablePackageExports:
94
+ config.resolver.unstable_enablePackageExports,
93
95
  shallow: false,
94
96
  });
95
97
 
@@ -141,6 +143,7 @@ async function getTransformFn(
141
143
  options,
142
144
  resolverOptions,
143
145
  );
146
+ const assetExts = new Set(config.resolver.assetExts);
144
147
 
145
148
  return async (modulePath: string, requireContext: ?RequireContext) => {
146
149
  let templateBuffer: Buffer;
@@ -171,11 +174,7 @@ async function getTransformFn(
171
174
  modulePath,
172
175
  {
173
176
  ...transformOptions,
174
- type: getType(
175
- transformOptions.type,
176
- modulePath,
177
- config.resolver.assetExts,
178
- ),
177
+ type: getType(transformOptions.type, modulePath, assetExts),
179
178
  inlineRequires: removeInlineRequiresBlockListFromOptions(
180
179
  modulePath,
181
180
  inlineRequires,
@@ -189,13 +188,13 @@ async function getTransformFn(
189
188
  function getType(
190
189
  type: string,
191
190
  filePath: string,
192
- assetExts: $ReadOnlyArray<string>,
191
+ assetExts: $ReadOnlySet<string>,
193
192
  ): Type {
194
193
  if (type === 'script') {
195
194
  return type;
196
195
  }
197
196
 
198
- if (assetExts.indexOf(path.extname(filePath).slice(1)) !== -1) {
197
+ if (isAssetFile(filePath, assetExts)) {
199
198
  return 'asset';
200
199
  }
201
200
 
@@ -23,7 +23,6 @@ class ModuleResolver {
23
23
 
24
24
  // An empty module, the result of resolving `emptyModulePath` from the project root.
25
25
 
26
- // $FlowFixMe[missing-local-annot]
27
26
  constructor(options) {
28
27
  this._options = options;
29
28
  const { projectRoot, moduleCache } = this._options;
@@ -61,10 +60,10 @@ class ModuleResolver {
61
60
  resolverOptions
62
61
  ) {
63
62
  const {
63
+ assetExts,
64
64
  disableHierarchicalLookup,
65
65
  doesFileExist,
66
66
  extraNodeModules,
67
- isAssetFile,
68
67
  mainFields,
69
68
  nodeModulesPaths,
70
69
  preferNativePlatform,
@@ -74,16 +73,16 @@ class ModuleResolver {
74
73
  unstable_conditionNames,
75
74
  unstable_conditionsByPlatform,
76
75
  unstable_enablePackageExports,
76
+ unstable_getRealPath,
77
77
  } = this._options;
78
78
  try {
79
- var _resolverOptions$cust;
80
79
  const result = Resolver.resolve(
81
80
  createDefaultContext({
82
81
  allowHaste,
82
+ assetExts,
83
83
  disableHierarchicalLookup,
84
84
  doesFileExist,
85
85
  extraNodeModules,
86
- isAssetFile,
87
86
  mainFields,
88
87
  nodeModulesPaths,
89
88
  preferNativePlatform,
@@ -93,11 +92,9 @@ class ModuleResolver {
93
92
  unstable_conditionNames,
94
93
  unstable_conditionsByPlatform,
95
94
  unstable_enablePackageExports,
96
- customResolverOptions:
97
- (_resolverOptions$cust = resolverOptions.customResolverOptions) !==
98
- null && _resolverOptions$cust !== void 0
99
- ? _resolverOptions$cust
100
- : {},
95
+ unstable_getRealPath,
96
+ unstable_logWarning: this._logWarning,
97
+ customResolverOptions: resolverOptions.customResolverOptions ?? {},
101
98
  originModulePath: fromModule.path,
102
99
  resolveHasteModule: (name) =>
103
100
  this._options.getHasteModulePath(name, platform),
@@ -202,6 +199,12 @@ class ModuleResolver {
202
199
  throw new Error("invalid type");
203
200
  }
204
201
  }
202
+ _logWarning = (message) => {
203
+ this._options.reporter.update({
204
+ type: "resolver_warning",
205
+ message,
206
+ });
207
+ };
205
208
  _removeRoot(candidates) {
206
209
  if (candidates.filePathPrefix) {
207
210
  candidates.filePathPrefix = path.relative(
@@ -250,8 +253,7 @@ class UnableToResolveError extends Error {
250
253
  originModulePath,
251
254
  message
252
255
  ) + (codeFrameMessage ? "\n" + codeFrameMessage : "");
253
- this.cause =
254
- options === null || options === void 0 ? void 0 : options.cause;
256
+ this.cause = options?.cause;
255
257
  }
256
258
  buildCodeFrameMessage() {
257
259
  let file;
@@ -15,7 +15,7 @@ import type {
15
15
  CustomResolver,
16
16
  DoesFileExist,
17
17
  FileCandidates,
18
- IsAssetFile,
18
+ GetRealPath,
19
19
  Resolution,
20
20
  ResolveAsset,
21
21
  } from 'metro-resolver';
@@ -30,6 +30,7 @@ const createDefaultContext = require('metro-resolver/src/createDefaultContext');
30
30
  const path = require('path');
31
31
  const util = require('util');
32
32
  import type {BundlerResolution} from '../../DeltaBundler/types.flow';
33
+ import type {Reporter} from '../../lib/reporting';
33
34
 
34
35
  export type DirExistsFn = (filePath: string) => boolean;
35
36
 
@@ -53,6 +54,7 @@ export type ModuleishCache<TPackage> = interface {
53
54
  };
54
55
 
55
56
  type Options<TPackage> = $ReadOnly<{
57
+ assetExts: $ReadOnlySet<string>,
56
58
  dirExists: DirExistsFn,
57
59
  disableHierarchicalLookup: boolean,
58
60
  doesFileExist: DoesFileExist,
@@ -60,12 +62,12 @@ type Options<TPackage> = $ReadOnly<{
60
62
  extraNodeModules: ?Object,
61
63
  getHasteModulePath: (name: string, platform: ?string) => ?string,
62
64
  getHastePackagePath: (name: string, platform: ?string) => ?string,
63
- isAssetFile: IsAssetFile,
64
65
  mainFields: $ReadOnlyArray<string>,
65
66
  moduleCache: ModuleishCache<TPackage>,
66
67
  nodeModulesPaths: $ReadOnlyArray<string>,
67
68
  preferNativePlatform: boolean,
68
69
  projectRoot: string,
70
+ reporter: Reporter,
69
71
  resolveAsset: ResolveAsset,
70
72
  resolveRequest: ?CustomResolver,
71
73
  sourceExts: $ReadOnlyArray<string>,
@@ -74,6 +76,7 @@ type Options<TPackage> = $ReadOnly<{
74
76
  [platform: string]: $ReadOnlyArray<string>,
75
77
  }>,
76
78
  unstable_enablePackageExports: boolean,
79
+ unstable_getRealPath: ?GetRealPath,
77
80
  }>;
78
81
 
79
82
  class ModuleResolver<TPackage: Packageish> {
@@ -83,7 +86,6 @@ class ModuleResolver<TPackage: Packageish> {
83
86
  // An empty module, the result of resolving `emptyModulePath` from the project root.
84
87
  _cachedEmptyModule: ?BundlerResolution;
85
88
 
86
- // $FlowFixMe[missing-local-annot]
87
89
  constructor(options: Options<TPackage>) {
88
90
  this._options = options;
89
91
  const {projectRoot, moduleCache} = this._options;
@@ -123,10 +125,10 @@ class ModuleResolver<TPackage: Packageish> {
123
125
  resolverOptions: ResolverInputOptions,
124
126
  ): BundlerResolution {
125
127
  const {
128
+ assetExts,
126
129
  disableHierarchicalLookup,
127
130
  doesFileExist,
128
131
  extraNodeModules,
129
- isAssetFile,
130
132
  mainFields,
131
133
  nodeModulesPaths,
132
134
  preferNativePlatform,
@@ -136,16 +138,17 @@ class ModuleResolver<TPackage: Packageish> {
136
138
  unstable_conditionNames,
137
139
  unstable_conditionsByPlatform,
138
140
  unstable_enablePackageExports,
141
+ unstable_getRealPath,
139
142
  } = this._options;
140
143
 
141
144
  try {
142
145
  const result = Resolver.resolve(
143
146
  createDefaultContext({
144
147
  allowHaste,
148
+ assetExts,
145
149
  disableHierarchicalLookup,
146
150
  doesFileExist,
147
151
  extraNodeModules,
148
- isAssetFile,
149
152
  mainFields,
150
153
  nodeModulesPaths,
151
154
  preferNativePlatform,
@@ -155,6 +158,8 @@ class ModuleResolver<TPackage: Packageish> {
155
158
  unstable_conditionNames,
156
159
  unstable_conditionsByPlatform,
157
160
  unstable_enablePackageExports,
161
+ unstable_getRealPath,
162
+ unstable_logWarning: this._logWarning,
158
163
  customResolverOptions: resolverOptions.customResolverOptions ?? {},
159
164
  originModulePath: fromModule.path,
160
165
  resolveHasteModule: (name: string) =>
@@ -268,6 +273,13 @@ class ModuleResolver<TPackage: Packageish> {
268
273
  }
269
274
  }
270
275
 
276
+ _logWarning = (message: string): void => {
277
+ this._options.reporter.update({
278
+ type: 'resolver_warning',
279
+ message,
280
+ });
281
+ };
282
+
271
283
  _removeRoot(candidates: FileCandidates): FileCandidates {
272
284
  if (candidates.filePathPrefix) {
273
285
  candidates.filePathPrefix = path.relative(
@@ -66,7 +66,7 @@ function getIgnorePattern(config) {
66
66
  const combine = (regexes) =>
67
67
  new RegExp(
68
68
  regexes
69
- .map((regex) => "(" + regex.source.replace(/\//g, path.sep) + ")")
69
+ .map((regex) => "(" + regex.source.replaceAll("/", path.sep) + ")")
70
70
  .join("|")
71
71
  );
72
72
 
@@ -77,37 +77,21 @@ function getIgnorePattern(config) {
77
77
  return ignorePattern;
78
78
  }
79
79
  function createHasteMap(config, options) {
80
- var _config$unstable_file, _options$throwOnModul;
81
80
  const dependencyExtractor =
82
- (options === null || options === void 0
83
- ? void 0
84
- : options.extractDependencies) === false
81
+ options?.extractDependencies === false
85
82
  ? null
86
83
  : config.resolver.dependencyExtractor;
87
84
  const computeDependencies = dependencyExtractor != null;
88
85
  return _metroFileMap.default.create({
89
86
  cacheManagerFactory:
90
- (_config$unstable_file =
91
- config === null || config === void 0
92
- ? void 0
93
- : config.unstable_fileMapCacheManagerFactory) !== null &&
94
- _config$unstable_file !== void 0
95
- ? _config$unstable_file
96
- : (buildParameters) => {
97
- var _config$fileMapCacheD;
98
- return new _metroFileMap.DiskCacheManager({
99
- buildParameters,
100
- cacheDirectory:
101
- (_config$fileMapCacheD = config.fileMapCacheDirectory) !==
102
- null && _config$fileMapCacheD !== void 0
103
- ? _config$fileMapCacheD
104
- : config.hasteMapCacheDirectory,
105
- cacheFilePrefix:
106
- options === null || options === void 0
107
- ? void 0
108
- : options.cacheFilePrefix,
109
- });
110
- },
87
+ config?.unstable_fileMapCacheManagerFactory ??
88
+ ((buildParameters) =>
89
+ new _metroFileMap.DiskCacheManager({
90
+ buildParameters,
91
+ cacheDirectory:
92
+ config.fileMapCacheDirectory ?? config.hasteMapCacheDirectory,
93
+ cacheFilePrefix: options?.cacheFilePrefix,
94
+ })),
111
95
  perfLoggerFactory: config.unstable_perfLoggerFactory,
112
96
  computeDependencies,
113
97
  computeSha1: true,
@@ -131,19 +115,10 @@ function createHasteMap(config, options) {
131
115
  resetCache: config.resetCache,
132
116
  rootDir: config.projectRoot,
133
117
  roots: config.watchFolders,
134
- throwOnModuleCollision:
135
- (_options$throwOnModul =
136
- options === null || options === void 0
137
- ? void 0
138
- : options.throwOnModuleCollision) !== null &&
139
- _options$throwOnModul !== void 0
140
- ? _options$throwOnModul
141
- : true,
118
+ throwOnModuleCollision: options?.throwOnModuleCollision ?? true,
119
+ unstable_preferTreeFS: config.watcher.unstable_preferTreeFS,
142
120
  useWatchman: config.resolver.useWatchman,
143
- watch:
144
- (options === null || options === void 0 ? void 0 : options.watch) == null
145
- ? !ci.isCI
146
- : options.watch,
121
+ watch: options?.watch == null ? !ci.isCI : options.watch,
147
122
  watchmanDeferStates: config.watcher.watchman.deferStates,
148
123
  });
149
124
  }
@@ -29,7 +29,7 @@ function getIgnorePattern(config: ConfigT): RegExp {
29
29
  const combine = (regexes: Array<RegExp>) =>
30
30
  new RegExp(
31
31
  regexes
32
- .map(regex => '(' + regex.source.replace(/\//g, path.sep) + ')')
32
+ .map(regex => '(' + regex.source.replaceAll('/', path.sep) + ')')
33
33
  .join('|'),
34
34
  );
35
35
 
@@ -90,6 +90,7 @@ function createHasteMap(
90
90
  rootDir: config.projectRoot,
91
91
  roots: config.watchFolders,
92
92
  throwOnModuleCollision: options?.throwOnModuleCollision ?? true,
93
+ unstable_preferTreeFS: config.watcher.unstable_preferTreeFS,
93
94
  useWatchman: config.resolver.useWatchman,
94
95
  watch: options?.watch == null ? !ci.isCI : options.watch,
95
96
  watchmanDeferStates: config.watcher.watchman.deferStates,