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.
- package/package.json +22 -22
- package/src/Bundler.js +0 -2
- package/src/Bundler.js.flow +1 -1
- package/src/DeltaBundler/graphOperations.js +9 -2
- package/src/DeltaBundler/graphOperations.js.flow +6 -3
- package/src/DeltaBundler/types.flow.js +6 -0
- package/src/DeltaBundler/types.flow.js.flow +7 -1
- package/src/DeltaBundler.js +0 -2
- package/src/DeltaBundler.js.flow +1 -1
- package/src/HmrServer.js +0 -2
- package/src/HmrServer.js.flow +1 -2
- package/src/ModuleGraph/node-haste/node-haste.flow.js +0 -1
- package/src/ModuleGraph/node-haste/node-haste.flow.js.flow +1 -2
- package/src/ModuleGraph/worker/collectDependencies.js +215 -8
- package/src/ModuleGraph/worker/collectDependencies.js.flow +228 -11
- package/src/lib/CountingSet.js +116 -0
- package/src/lib/CountingSet.js.flow +126 -0
- package/src/lib/JsonReporter.js +0 -2
- package/src/lib/JsonReporter.js.flow +1 -1
- package/src/lib/getAppendScripts.js +10 -4
- package/src/lib/getAppendScripts.js.flow +6 -4
- package/src/lib/getPreludeCode.js +19 -1
- package/src/lib/getPreludeCode.js.flow +15 -0
- package/src/lib/getPrependedScripts.js +10 -2
- package/src/lib/getPrependedScripts.js.flow +11 -2
- package/src/lib/reporting.js +0 -2
- package/src/lib/reporting.js.flow +2 -1
- package/src/node-haste/DependencyGraph/createHasteMap.js +1 -0
- package/src/node-haste/DependencyGraph/createHasteMap.js.flow +1 -0
- package/src/node-haste/DependencyGraph.js +0 -2
- package/src/node-haste/DependencyGraph.js.flow +1 -1
|
@@ -9,14 +9,32 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
-
function getPreludeCode({
|
|
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
|
|
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({
|
|
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
|
|
100
|
+
inverseDependencies: new CountingSet(),
|
|
92
101
|
path: name,
|
|
93
102
|
output: [
|
|
94
103
|
{
|
package/src/lib/reporting.js
CHANGED
|
@@ -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');
|