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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metro",
3
- "version": "0.75.0",
3
+ "version": "0.76.0",
4
4
  "description": "🚇 The JavaScript bundler for React Native.",
5
5
  "main": "src/index.js",
6
6
  "bin": "src/cli.js",
@@ -20,7 +20,6 @@
20
20
  "@babel/template": "^7.0.0",
21
21
  "@babel/traverse": "^7.20.0",
22
22
  "@babel/types": "^7.20.0",
23
- "absolute-path": "^0.0.0",
24
23
  "accepts": "^1.3.7",
25
24
  "async": "^3.2.2",
26
25
  "chalk": "^4.0.0",
@@ -35,23 +34,23 @@
35
34
  "invariant": "^2.2.4",
36
35
  "jest-worker": "^27.2.0",
37
36
  "lodash.throttle": "^4.1.1",
38
- "metro-babel-transformer": "0.75.0",
39
- "metro-cache": "0.75.0",
40
- "metro-cache-key": "0.75.0",
41
- "metro-config": "0.75.0",
42
- "metro-core": "0.75.0",
43
- "metro-file-map": "0.75.0",
44
- "metro-hermes-compiler": "0.75.0",
45
- "metro-inspector-proxy": "0.75.0",
46
- "metro-minify-terser": "0.75.0",
47
- "metro-minify-uglify": "0.75.0",
48
- "metro-react-native-babel-preset": "0.75.0",
49
- "metro-resolver": "0.75.0",
50
- "metro-runtime": "0.75.0",
51
- "metro-source-map": "0.75.0",
52
- "metro-symbolicate": "0.75.0",
53
- "metro-transform-plugins": "0.75.0",
54
- "metro-transform-worker": "0.75.0",
37
+ "metro-babel-transformer": "0.76.0",
38
+ "metro-cache": "0.76.0",
39
+ "metro-cache-key": "0.76.0",
40
+ "metro-config": "0.76.0",
41
+ "metro-core": "0.76.0",
42
+ "metro-file-map": "0.76.0",
43
+ "metro-hermes-compiler": "0.76.0",
44
+ "metro-inspector-proxy": "0.76.0",
45
+ "metro-minify-terser": "0.76.0",
46
+ "metro-minify-uglify": "0.76.0",
47
+ "metro-react-native-babel-preset": "0.76.0",
48
+ "metro-resolver": "0.76.0",
49
+ "metro-runtime": "0.76.0",
50
+ "metro-source-map": "0.76.0",
51
+ "metro-symbolicate": "0.76.0",
52
+ "metro-transform-plugins": "0.76.0",
53
+ "metro-transform-worker": "0.76.0",
55
54
  "mime-types": "^2.1.27",
56
55
  "node-fetch": "^2.2.0",
57
56
  "nullthrows": "^1.1.1",
@@ -70,16 +69,16 @@
70
69
  "dedent": "^0.7.0",
71
70
  "jest-snapshot": "^26.5.2",
72
71
  "jest-snapshot-serializer-raw": "^1.2.0",
73
- "metro-babel-register": "0.75.0",
74
- "metro-memory-fs": "0.75.0",
75
- "metro-react-native-babel-preset": "0.75.0",
76
- "metro-react-native-babel-transformer": "0.75.0",
72
+ "metro-babel-register": "0.76.0",
73
+ "metro-memory-fs": "0.76.0",
74
+ "metro-react-native-babel-preset": "0.76.0",
75
+ "metro-react-native-babel-transformer": "0.76.0",
77
76
  "mock-req": "^0.2.0",
78
77
  "mock-res": "^0.6.0",
79
78
  "stack-trace": "^0.0.10"
80
79
  },
81
80
  "license": "MIT",
82
81
  "engines": {
83
- "node": ">=14.17.0"
82
+ "node": ">=16"
84
83
  }
85
84
  }
package/src/Assets.js CHANGED
@@ -93,7 +93,7 @@ async function getAbsoluteAssetRecord(assetPath, platform = null) {
93
93
  if (!record) {
94
94
  throw new Error(
95
95
  `Asset not found: ${assetPath} for platform: ${
96
- platform !== null && platform !== void 0 ? platform : "(unspecified)"
96
+ platform ?? "(unspecified)"
97
97
  }`
98
98
  );
99
99
  }
@@ -134,7 +134,7 @@ async function getAssetData(
134
134
 
135
135
  // On Windows, change backslashes to slashes to get proper URL path from file path.
136
136
  if (path.sep === "\\") {
137
- assetUrlPath = assetUrlPath.replace(/\\/g, "/");
137
+ assetUrlPath = assetUrlPath.replaceAll("\\", "/");
138
138
  }
139
139
  const isImage = isAssetTypeAnImage(path.extname(assetPath).slice(1));
140
140
  const assetInfo = await getAbsoluteAssetInfo(assetPath, platform);
@@ -200,7 +200,7 @@ async function getAssetData(
200
200
 
201
201
  // On Windows, change backslashes to slashes to get proper URL path from file path.
202
202
  if (path.sep === '\\') {
203
- assetUrlPath = assetUrlPath.replace(/\\/g, '/');
203
+ assetUrlPath = assetUrlPath.replaceAll('\\', '/');
204
204
  }
205
205
 
206
206
  const isImage = isAssetTypeAnImage(path.extname(assetPath).slice(1));
@@ -11,7 +11,11 @@
11
11
 
12
12
  "use strict";
13
13
 
14
+ var _path = _interopRequireDefault(require("path"));
14
15
  var _Graph = require("./Graph");
16
+ function _interopRequireDefault(obj) {
17
+ return obj && obj.__esModule ? obj : { default: obj };
18
+ }
15
19
  const debug = require("debug")("Metro:DeltaCalculator");
16
20
  const { EventEmitter } = require("events");
17
21
 
@@ -25,7 +29,7 @@ class DeltaCalculator extends EventEmitter {
25
29
  _deletedFiles = new Set();
26
30
  _modifiedFiles = new Set();
27
31
  _addedFiles = new Set();
28
- _hasSymlinkChanges = false;
32
+ _requiresReset = false;
29
33
  constructor(entryPoints, changeEventSource, options) {
30
34
  super();
31
35
  this._options = options;
@@ -78,13 +82,13 @@ class DeltaCalculator extends EventEmitter {
78
82
  this._deletedFiles = new Set();
79
83
  const addedFiles = this._addedFiles;
80
84
  this._addedFiles = new Set();
81
- const hasSymlinkChanges = this._hasSymlinkChanges;
82
- this._hasSymlinkChanges = false;
85
+ const requiresReset = this._requiresReset;
86
+ this._requiresReset = false;
83
87
 
84
- // Revisit all files if changes include symlinks - resolutions may be
88
+ // Revisit all files if changes require a graph reset - resolutions may be
85
89
  // invalidated but we don't yet know which. This should be optimized in the
86
90
  // future.
87
- if (hasSymlinkChanges) {
91
+ if (requiresReset) {
88
92
  const markModified = (file) => {
89
93
  if (!addedFiles.has(file) && !deletedFiles.has(file)) {
90
94
  modifiedFiles.add(file);
@@ -165,12 +169,15 @@ class DeltaCalculator extends EventEmitter {
165
169
  */
166
170
  _handleFileChange = ({ type, filePath, metadata }, logger) => {
167
171
  debug("Handling %s: %s (type: %s)", type, filePath, metadata.type);
168
- if (metadata.type === "l") {
169
- this._hasSymlinkChanges = true;
172
+ if (
173
+ metadata.type === "l" ||
174
+ (this._options.unstable_enablePackageExports &&
175
+ filePath.endsWith(_path.default.sep + "package.json"))
176
+ ) {
177
+ this._requiresReset = true;
170
178
  this.emit("change", {
171
179
  logger,
172
180
  });
173
- return;
174
181
  }
175
182
  let state;
176
183
  if (this._deletedFiles.has(filePath)) {
@@ -233,13 +240,13 @@ class DeltaCalculator extends EventEmitter {
233
240
  // If a file has been deleted, we want to invalidate any other file that
234
241
  // depends on it, so we can process it and correctly return an error.
235
242
  deletedFiles.forEach((filePath) => {
236
- for (const path of this._graph.getModifiedModulesForDeletedPath(
243
+ for (const modifiedModulePath of this._graph.getModifiedModulesForDeletedPath(
237
244
  filePath
238
245
  )) {
239
246
  // Only mark the inverse dependency as modified if it's not already
240
247
  // marked as deleted (in that case we can just ignore it).
241
- if (!deletedFiles.has(path)) {
242
- modifiedFiles.add(path);
248
+ if (!deletedFiles.has(modifiedModulePath)) {
249
+ modifiedFiles.add(modifiedModulePath);
243
250
  }
244
251
  }
245
252
  });
@@ -11,6 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ import path from 'path';
14
15
  import {Graph} from './Graph';
15
16
  import type {DeltaResult, Options} from './types.flow';
16
17
  import type {RootPerfLogger} from 'metro-config';
@@ -33,7 +34,7 @@ class DeltaCalculator<T> extends EventEmitter {
33
34
  _deletedFiles: Set<string> = new Set();
34
35
  _modifiedFiles: Set<string> = new Set();
35
36
  _addedFiles: Set<string> = new Set();
36
- _hasSymlinkChanges = false;
37
+ _requiresReset = false;
37
38
 
38
39
  _graph: Graph<T>;
39
40
 
@@ -104,13 +105,13 @@ class DeltaCalculator<T> extends EventEmitter {
104
105
  this._deletedFiles = new Set();
105
106
  const addedFiles = this._addedFiles;
106
107
  this._addedFiles = new Set();
107
- const hasSymlinkChanges = this._hasSymlinkChanges;
108
- this._hasSymlinkChanges = false;
108
+ const requiresReset = this._requiresReset;
109
+ this._requiresReset = false;
109
110
 
110
- // Revisit all files if changes include symlinks - resolutions may be
111
+ // Revisit all files if changes require a graph reset - resolutions may be
111
112
  // invalidated but we don't yet know which. This should be optimized in the
112
113
  // future.
113
- if (hasSymlinkChanges) {
114
+ if (requiresReset) {
114
115
  const markModified = (file: string) => {
115
116
  if (!addedFiles.has(file) && !deletedFiles.has(file)) {
116
117
  modifiedFiles.add(file);
@@ -207,10 +208,13 @@ class DeltaCalculator<T> extends EventEmitter {
207
208
  logger: ?RootPerfLogger,
208
209
  ): mixed => {
209
210
  debug('Handling %s: %s (type: %s)', type, filePath, metadata.type);
210
- if (metadata.type === 'l') {
211
- this._hasSymlinkChanges = true;
211
+ if (
212
+ metadata.type === 'l' ||
213
+ (this._options.unstable_enablePackageExports &&
214
+ filePath.endsWith(path.sep + 'package.json'))
215
+ ) {
216
+ this._requiresReset = true;
212
217
  this.emit('change', {logger});
213
- return;
214
218
  }
215
219
  let state: void | 'deleted' | 'modified' | 'added';
216
220
  if (this._deletedFiles.has(filePath)) {
@@ -281,13 +285,13 @@ class DeltaCalculator<T> extends EventEmitter {
281
285
  // If a file has been deleted, we want to invalidate any other file that
282
286
  // depends on it, so we can process it and correctly return an error.
283
287
  deletedFiles.forEach((filePath: string) => {
284
- for (const path of this._graph.getModifiedModulesForDeletedPath(
288
+ for (const modifiedModulePath of this._graph.getModifiedModulesForDeletedPath(
285
289
  filePath,
286
290
  )) {
287
291
  // Only mark the inverse dependency as modified if it's not already
288
292
  // marked as deleted (in that case we can just ignore it).
289
- if (!deletedFiles.has(path)) {
290
- modifiedFiles.add(path);
293
+ if (!deletedFiles.has(modifiedModulePath)) {
294
+ modifiedFiles.add(modifiedModulePath);
291
295
  }
292
296
  }
293
297
  });
@@ -284,6 +284,8 @@ class Graph {
284
284
  let module = this.dependencies.get(path);
285
285
  if (options.shallow) {
286
286
  // Don't add a node for the module if the graph is shallow (single-module).
287
+ } else if (dependency.data.data.asyncType === "weak") {
288
+ // Exclude weak dependencies from the bundle.
287
289
  } else if (
288
290
  options.experimentalImportBundleSupport &&
289
291
  dependency.data.data.asyncType != null
@@ -332,6 +334,10 @@ class Graph {
332
334
  _removeDependency(parentModule, key, dependency, delta, options) {
333
335
  parentModule.dependencies.delete(key);
334
336
  const { absolutePath } = dependency;
337
+ if (dependency.data.data.asyncType === "weak") {
338
+ // Weak dependencies are excluded from the bundle.
339
+ return;
340
+ }
335
341
  if (
336
342
  options.experimentalImportBundleSupport &&
337
343
  dependency.data.data.asyncType != null
@@ -376,26 +382,8 @@ class Graph {
376
382
  * traverseDependencies. Note that the list may contain duplicates.
377
383
  */
378
384
  *getModifiedModulesForDeletedPath(filePath) {
379
- var _this$dependencies$ge,
380
- _this$dependencies$ge2,
381
- _this$importBundleNod,
382
- _this$importBundleNod2;
383
- yield* (_this$dependencies$ge =
384
- (_this$dependencies$ge2 = this.dependencies.get(filePath)) === null ||
385
- _this$dependencies$ge2 === void 0
386
- ? void 0
387
- : _this$dependencies$ge2.inverseDependencies) !== null &&
388
- _this$dependencies$ge !== void 0
389
- ? _this$dependencies$ge
390
- : [];
391
- yield* (_this$importBundleNod =
392
- (_this$importBundleNod2 = this.#importBundleNodes.get(filePath)) ===
393
- null || _this$importBundleNod2 === void 0
394
- ? void 0
395
- : _this$importBundleNod2.inverseDependencies) !== null &&
396
- _this$importBundleNod !== void 0
397
- ? _this$importBundleNod
398
- : [];
385
+ yield* this.dependencies.get(filePath)?.inverseDependencies ?? [];
386
+ yield* this.#importBundleNodes.get(filePath)?.inverseDependencies ?? [];
399
387
  }
400
388
  _resolveDependencies(parentPath, dependencies, options) {
401
389
  const maybeResolvedDeps = new Map();
@@ -511,15 +499,10 @@ class Graph {
511
499
 
512
500
  // Add an entry to importBundleNodes (or record an inverse dependency of an existing one)
513
501
  _incrementImportBundleReference(dependency, parentModule) {
514
- var _this$importBundleNod3;
515
502
  const { absolutePath } = dependency;
516
- const importBundleNode =
517
- (_this$importBundleNod3 = this.#importBundleNodes.get(absolutePath)) !==
518
- null && _this$importBundleNod3 !== void 0
519
- ? _this$importBundleNod3
520
- : {
521
- inverseDependencies: new _CountingSet.default(),
522
- };
503
+ const importBundleNode = this.#importBundleNodes.get(absolutePath) ?? {
504
+ inverseDependencies: new _CountingSet.default(),
505
+ };
523
506
  importBundleNode.inverseDependencies.add(parentModule.path);
524
507
  this.#importBundleNodes.set(absolutePath, importBundleNode);
525
508
  }
@@ -355,6 +355,8 @@ export class Graph<T = MixedOutput> {
355
355
 
356
356
  if (options.shallow) {
357
357
  // Don't add a node for the module if the graph is shallow (single-module).
358
+ } else if (dependency.data.data.asyncType === 'weak') {
359
+ // Exclude weak dependencies from the bundle.
358
360
  } else if (
359
361
  options.experimentalImportBundleSupport &&
360
362
  dependency.data.data.asyncType != null
@@ -414,6 +416,11 @@ export class Graph<T = MixedOutput> {
414
416
 
415
417
  const {absolutePath} = dependency;
416
418
 
419
+ if (dependency.data.data.asyncType === 'weak') {
420
+ // Weak dependencies are excluded from the bundle.
421
+ return;
422
+ }
423
+
417
424
  if (
418
425
  options.experimentalImportBundleSupport &&
419
426
  dependency.data.data.asyncType != null
@@ -63,23 +63,18 @@ function getModuleParams(module, options) {
63
63
  return params;
64
64
  }
65
65
  function getJsOutput(module) {
66
- var _module$path, _module$path2;
67
66
  const jsModules = module.output.filter(({ type }) => type.startsWith("js/"));
68
67
  invariant(
69
68
  jsModules.length === 1,
70
69
  `Modules must have exactly one JS output, but ${
71
- (_module$path = module.path) !== null && _module$path !== void 0
72
- ? _module$path
73
- : "unknown module"
70
+ module.path ?? "unknown module"
74
71
  } has ${jsModules.length} JS outputs.`
75
72
  );
76
73
  const jsOutput = jsModules[0];
77
74
  invariant(
78
75
  Number.isFinite(jsOutput.data.lineCount),
79
76
  `JS output must populate lineCount, but ${
80
- (_module$path2 = module.path) !== null && _module$path2 !== void 0
81
- ? _module$path2
82
- : "unknown module"
77
+ module.path ?? "unknown module"
83
78
  } has ${jsOutput.type} output with lineCount '${jsOutput.data.lineCount}'`
84
79
  );
85
80
  return jsOutput;
@@ -23,7 +23,7 @@ export type MixedOutput = {
23
23
  +type: string,
24
24
  };
25
25
 
26
- export type AsyncDependencyType = 'async' | 'prefetch';
26
+ export type AsyncDependencyType = 'async' | 'prefetch' | 'weak';
27
27
 
28
28
  export type TransformResultDependency = {
29
29
  /**
@@ -44,12 +44,6 @@ export type TransformResultDependency = {
44
44
  * If not null, this dependency is due to a dynamic `import()` or `__prefetchImport()` call.
45
45
  */
46
46
  +asyncType: AsyncDependencyType | null,
47
- /**
48
- * The condition for splitting on this dependency edge.
49
- */
50
- +splitCondition?: {
51
- +mobileConfigName: string,
52
- },
53
47
  /**
54
48
  * The dependency is enclosed in a try/catch block.
55
49
  */
@@ -138,6 +132,7 @@ export type Options<T = MixedOutput> = {
138
132
  +onProgress: ?(numProcessed: number, total: number) => mixed,
139
133
  +experimentalImportBundleSupport: boolean,
140
134
  +unstable_allowRequireContext: boolean,
135
+ +unstable_enablePackageExports: boolean,
141
136
  +shallow: boolean,
142
137
  };
143
138
 
package/src/HmrServer.js CHANGED
@@ -56,7 +56,6 @@ class HmrServer {
56
56
  };
57
57
  };
58
58
  async _registerEntryPoint(client, requestUrl, sendFn) {
59
- var _this$_config$server$;
60
59
  requestUrl = this._config.server.rewriteRequestUrl(requestUrl);
61
60
  const clientUrl = nullthrows(url.parse(requestUrl, true));
62
61
  const options = parseOptionsFromUrl(
@@ -77,10 +76,8 @@ class HmrServer {
77
76
  resolverOptions
78
77
  );
79
78
  const resolvedEntryFilePath = resolutionFn(
80
- ((_this$_config$server$ = this._config.server.unstable_serverRoot) !==
81
- null && _this$_config$server$ !== void 0
82
- ? _this$_config$server$
83
- : this._config.projectRoot) + "/.",
79
+ (this._config.server.unstable_serverRoot ?? this._config.projectRoot) +
80
+ "/.",
84
81
  entryFile
85
82
  ).filePath;
86
83
  const graphId = getGraphId(resolvedEntryFilePath, transformOptions, {
@@ -212,11 +209,7 @@ class HmrServer {
212
209
  });
213
210
  };
214
211
  async _handleFileChange(group, options, changeEvent) {
215
- const logger = !options.isInitialUpdate
216
- ? changeEvent === null || changeEvent === void 0
217
- ? void 0
218
- : changeEvent.logger
219
- : null;
212
+ const logger = !options.isInitialUpdate ? changeEvent?.logger : null;
220
213
  if (logger) {
221
214
  logger.point("fileChange_end");
222
215
  logger.point("hmrPrepareAndSendMessage_start");
@@ -260,13 +253,8 @@ class HmrServer {
260
253
  }
261
254
  }
262
255
  async _prepareMessage(group, options, changeEvent) {
263
- const logger = !options.isInitialUpdate
264
- ? changeEvent === null || changeEvent === void 0
265
- ? void 0
266
- : changeEvent.logger
267
- : null;
256
+ const logger = !options.isInitialUpdate ? changeEvent?.logger : null;
268
257
  try {
269
- var _this$_config$server$2;
270
258
  const revPromise = this._bundler.getRevision(group.revisionId);
271
259
  if (!revPromise) {
272
260
  return {
@@ -276,16 +264,12 @@ class HmrServer {
276
264
  ),
277
265
  };
278
266
  }
279
- logger === null || logger === void 0
280
- ? void 0
281
- : logger.point("updateGraph_start");
267
+ logger?.point("updateGraph_start");
282
268
  const { revision, delta } = await this._bundler.updateGraph(
283
269
  await revPromise,
284
270
  false
285
271
  );
286
- logger === null || logger === void 0
287
- ? void 0
288
- : logger.point("updateGraph_end");
272
+ logger?.point("updateGraph_end");
289
273
  this._clientGroups.delete(group.revisionId);
290
274
  group.revisionId = revision.id;
291
275
  for (const client of group.clients) {
@@ -295,23 +279,16 @@ class HmrServer {
295
279
  client.revisionIds.push(revision.id);
296
280
  }
297
281
  this._clientGroups.set(group.revisionId, group);
298
- logger === null || logger === void 0
299
- ? void 0
300
- : logger.point("serialize_start");
282
+ logger?.point("serialize_start");
301
283
  const hmrUpdate = hmrJSBundle(delta, revision.graph, {
302
284
  clientUrl: group.clientUrl,
303
285
  createModuleId: this._createModuleId,
304
286
  includeAsyncPaths: this._config.server.experimentalImportBundleSupport,
305
287
  projectRoot: this._config.projectRoot,
306
288
  serverRoot:
307
- (_this$_config$server$2 = this._config.server.unstable_serverRoot) !==
308
- null && _this$_config$server$2 !== void 0
309
- ? _this$_config$server$2
310
- : this._config.projectRoot,
289
+ this._config.server.unstable_serverRoot ?? this._config.projectRoot,
311
290
  });
312
- logger === null || logger === void 0
313
- ? void 0
314
- : logger.point("serialize_end");
291
+ logger?.point("serialize_end");
315
292
  return {
316
293
  type: "update",
317
294
  body: {
@@ -81,6 +81,8 @@ class IncrementalBundler {
81
81
  this._config.server.experimentalImportBundleSupport,
82
82
  unstable_allowRequireContext:
83
83
  this._config.transformer.unstable_allowRequireContext,
84
+ unstable_enablePackageExports:
85
+ this._config.resolver.unstable_enablePackageExports,
84
86
  shallow: otherOptions.shallow,
85
87
  });
86
88
  this._config.serializer.experimentalSerializerHook(graph, {
@@ -123,6 +125,8 @@ class IncrementalBundler {
123
125
  this._config.server.experimentalImportBundleSupport,
124
126
  unstable_allowRequireContext:
125
127
  this._config.transformer.unstable_allowRequireContext,
128
+ unstable_enablePackageExports:
129
+ this._config.resolver.unstable_enablePackageExports,
126
130
  shallow: otherOptions.shallow,
127
131
  }
128
132
  );
@@ -253,16 +257,12 @@ class IncrementalBundler {
253
257
  this._revisionsById.delete(revision.id);
254
258
  }
255
259
  async _getAbsoluteEntryFiles(entryFiles) {
256
- const absoluteEntryFiles = entryFiles.map((entryFile) => {
257
- var _this$_config$server$;
258
- return path.resolve(
259
- (_this$_config$server$ = this._config.server.unstable_serverRoot) !==
260
- null && _this$_config$server$ !== void 0
261
- ? _this$_config$server$
262
- : this._config.projectRoot,
260
+ const absoluteEntryFiles = entryFiles.map((entryFile) =>
261
+ path.resolve(
262
+ this._config.server.unstable_serverRoot ?? this._config.projectRoot,
263
263
  entryFile
264
- );
265
- });
264
+ )
265
+ );
266
266
  await Promise.all(
267
267
  absoluteEntryFiles.map(
268
268
  (entryFile) =>
@@ -130,6 +130,8 @@ class IncrementalBundler {
130
130
  this._config.server.experimentalImportBundleSupport,
131
131
  unstable_allowRequireContext:
132
132
  this._config.transformer.unstable_allowRequireContext,
133
+ unstable_enablePackageExports:
134
+ this._config.resolver.unstable_enablePackageExports,
133
135
  shallow: otherOptions.shallow,
134
136
  });
135
137
 
@@ -176,6 +178,8 @@ class IncrementalBundler {
176
178
  this._config.server.experimentalImportBundleSupport,
177
179
  unstable_allowRequireContext:
178
180
  this._config.transformer.unstable_allowRequireContext,
181
+ unstable_enablePackageExports:
182
+ this._config.resolver.unstable_enablePackageExports,
179
183
  shallow: otherOptions.shallow,
180
184
  },
181
185
  );