metro 0.71.1 → 0.71.2

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.
@@ -9,14 +9,32 @@
9
9
  */
10
10
  "use strict";
11
11
 
12
- function getPreludeCode({ extraVars, isDev, globalPrefix }) {
12
+ function getPreludeCode({
13
+ extraVars,
14
+ isDev,
15
+ globalPrefix,
16
+ requireCycleIgnorePatterns,
17
+ }) {
13
18
  const vars = [
19
+ // Ensure these variable names match the ones referenced in metro-runtime
20
+ // require.js
14
21
  "__BUNDLE_START_TIME__=this.nativePerformanceNow?nativePerformanceNow():Date.now()",
15
22
  `__DEV__=${String(isDev)}`,
16
23
  ...formatExtraVars(extraVars),
17
24
  "process=this.process||{}",
18
25
  `__METRO_GLOBAL_PREFIX__='${globalPrefix}'`,
19
26
  ];
27
+
28
+ if (isDev) {
29
+ // Ensure these variable names match the ones referenced in metro-runtime
30
+ // require.js
31
+ vars.push(
32
+ `${globalPrefix}__requireCycleIgnorePatterns=[${requireCycleIgnorePatterns
33
+ .map((regex) => regex.toString())
34
+ .join(",")}]`
35
+ );
36
+ }
37
+
20
38
  return `var ${vars.join(",")};${processEnv(
21
39
  isDev ? "development" : "production"
22
40
  )}`;
@@ -14,18 +14,33 @@ function getPreludeCode({
14
14
  extraVars,
15
15
  isDev,
16
16
  globalPrefix,
17
+ requireCycleIgnorePatterns,
17
18
  }: {
18
19
  +extraVars?: {[string]: mixed, ...},
19
20
  +isDev: boolean,
20
21
  +globalPrefix: string,
22
+ +requireCycleIgnorePatterns: $ReadOnlyArray<RegExp>,
21
23
  }): string {
22
24
  const vars = [
25
+ // Ensure these variable names match the ones referenced in metro-runtime
26
+ // require.js
23
27
  '__BUNDLE_START_TIME__=this.nativePerformanceNow?nativePerformanceNow():Date.now()',
24
28
  `__DEV__=${String(isDev)}`,
25
29
  ...formatExtraVars(extraVars),
26
30
  'process=this.process||{}',
27
31
  `__METRO_GLOBAL_PREFIX__='${globalPrefix}'`,
28
32
  ];
33
+
34
+ if (isDev) {
35
+ // Ensure these variable names match the ones referenced in metro-runtime
36
+ // require.js
37
+ vars.push(
38
+ `${globalPrefix}__requireCycleIgnorePatterns=[${requireCycleIgnorePatterns
39
+ .map(regex => regex.toString())
40
+ .join(',')}]`,
41
+ );
42
+ }
43
+
29
44
  return `var ${vars.join(',')};${processEnv(
30
45
  isDev ? 'development' : 'production',
31
46
  )}`;
@@ -9,6 +9,12 @@
9
9
  */
10
10
  "use strict";
11
11
 
12
+ var _CountingSet = _interopRequireDefault(require("./CountingSet"));
13
+
14
+ function _interopRequireDefault(obj) {
15
+ return obj && obj.__esModule ? obj : { default: obj };
16
+ }
17
+
12
18
  const countLines = require("./countLines");
13
19
 
14
20
  const getPreludeCode = require("./getPreludeCode");
@@ -53,21 +59,23 @@ async function getPrependedScripts(config, options, bundler, deltaBundler) {
53
59
  _getPrelude({
54
60
  dev: options.dev,
55
61
  globalPrefix: config.transformer.globalPrefix,
62
+ requireCycleIgnorePatterns: config.resolver.requireCycleIgnorePatterns,
56
63
  }),
57
64
  ...dependencies.values(),
58
65
  ];
59
66
  }
60
67
 
61
- function _getPrelude({ dev, globalPrefix }) {
68
+ function _getPrelude({ dev, globalPrefix, requireCycleIgnorePatterns }) {
62
69
  const code = getPreludeCode({
63
70
  isDev: dev,
64
71
  globalPrefix,
72
+ requireCycleIgnorePatterns,
65
73
  });
66
74
  const name = "__prelude__";
67
75
  return {
68
76
  dependencies: new Map(),
69
77
  getSource: () => Buffer.from(code),
70
- inverseDependencies: new Set(),
78
+ inverseDependencies: new _CountingSet.default(),
71
79
  path: name,
72
80
  output: [
73
81
  {
@@ -15,6 +15,8 @@ import type DeltaBundler, {Module} from '../DeltaBundler';
15
15
  import type {TransformInputOptions} from '../DeltaBundler/types.flow';
16
16
  import type {ConfigT} from 'metro-config/src/configTypes.flow';
17
17
 
18
+ import CountingSet from './CountingSet';
19
+
18
20
  const countLines = require('./countLines');
19
21
  const getPreludeCode = require('./getPreludeCode');
20
22
  const transformHelpers = require('./transformHelpers');
@@ -69,6 +71,7 @@ async function getPrependedScripts(
69
71
  _getPrelude({
70
72
  dev: options.dev,
71
73
  globalPrefix: config.transformer.globalPrefix,
74
+ requireCycleIgnorePatterns: config.resolver.requireCycleIgnorePatterns,
72
75
  }),
73
76
  ...dependencies.values(),
74
77
  ];
@@ -77,18 +80,24 @@ async function getPrependedScripts(
77
80
  function _getPrelude({
78
81
  dev,
79
82
  globalPrefix,
83
+ requireCycleIgnorePatterns,
80
84
  }: {
81
85
  dev: boolean,
82
86
  globalPrefix: string,
87
+ requireCycleIgnorePatterns: $ReadOnlyArray<RegExp>,
83
88
  ...
84
89
  }): Module<> {
85
- const code = getPreludeCode({isDev: dev, globalPrefix});
90
+ const code = getPreludeCode({
91
+ isDev: dev,
92
+ globalPrefix,
93
+ requireCycleIgnorePatterns,
94
+ });
86
95
  const name = '__prelude__';
87
96
 
88
97
  return {
89
98
  dependencies: new Map(),
90
99
  getSource: (): Buffer => Buffer.from(code),
91
- inverseDependencies: new Set(),
100
+ inverseDependencies: new CountingSet(),
92
101
  path: name,
93
102
  output: [
94
103
  {
@@ -11,8 +11,6 @@
11
11
 
12
12
  const chalk = require("chalk");
13
13
 
14
- const { Terminal } = require("metro-core");
15
-
16
14
  const stripAnsi = require("strip-ansi");
17
15
 
18
16
  const util = require("util");
@@ -10,8 +10,9 @@
10
10
 
11
11
  'use strict';
12
12
 
13
+ import type {Terminal} from 'metro-core';
14
+
13
15
  const chalk = require('chalk');
14
- const {Terminal} = require('metro-core');
15
16
  const stripAnsi = require('strip-ansi');
16
17
  const util = require('util');
17
18
 
@@ -153,6 +153,7 @@ function createHasteMap(config, options) {
153
153
  (options === null || options === void 0 ? void 0 : options.watch) == null
154
154
  ? !ci.isCI
155
155
  : options.watch,
156
+ watchmanDeferStates: config.watcher.watchman.deferStates,
156
157
  });
157
158
  }
158
159
 
@@ -83,6 +83,7 @@ function createHasteMap(
83
83
  throwOnModuleCollision: options?.throwOnModuleCollision ?? true,
84
84
  useWatchman: config.resolver.useWatchman,
85
85
  watch: options?.watch == null ? !ci.isCI : options.watch,
86
+ watchmanDeferStates: config.watcher.watchman.deferStates,
86
87
  });
87
88
  }
88
89
 
@@ -15,8 +15,6 @@ const createHasteMap = require("./DependencyGraph/createHasteMap");
15
15
 
16
16
  const { ModuleResolver } = require("./DependencyGraph/ModuleResolution");
17
17
 
18
- const Module = require("./Module");
19
-
20
18
  const ModuleCache = require("./ModuleCache");
21
19
 
22
20
  const { EventEmitter } = require("events");
@@ -11,12 +11,12 @@
11
11
  import type Package from './Package';
12
12
  import type {ConfigT} from 'metro-config/src/configTypes.flow';
13
13
  import type MetroFileMap, {HasteFS} from 'metro-file-map';
14
+ import type Module from './Module';
14
15
 
15
16
  import {ModuleMap as MetroFileMapModuleMap} from 'metro-file-map';
16
17
 
17
18
  const createHasteMap = require('./DependencyGraph/createHasteMap');
18
19
  const {ModuleResolver} = require('./DependencyGraph/ModuleResolution');
19
- const Module = require('./Module');
20
20
  const ModuleCache = require('./ModuleCache');
21
21
  const {EventEmitter} = require('events');
22
22
  const fs = require('fs');