metro 0.83.5 → 0.83.7
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 +15 -16
- package/src/Assets.d.ts +8 -1
- package/src/Assets.js +20 -13
- package/src/Assets.js.flow +20 -13
- package/src/Bundler/util.d.ts +8 -1
- package/src/Bundler/util.js.flow +3 -3
- package/src/Bundler.d.ts +8 -1
- package/src/DeltaBundler/DeltaCalculator.d.ts +8 -11
- package/src/DeltaBundler/DeltaCalculator.js +55 -46
- package/src/DeltaBundler/DeltaCalculator.js.flow +72 -61
- package/src/DeltaBundler/Graph.d.ts +8 -1
- package/src/DeltaBundler/Serializers/baseJSBundle.d.ts +8 -1
- package/src/DeltaBundler/Serializers/getAllFiles.d.ts +8 -1
- package/src/DeltaBundler/Serializers/getAssets.d.ts +8 -1
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +8 -1
- package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +8 -1
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.d.ts +8 -1
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.d.ts +8 -1
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.d.ts +8 -1
- package/src/DeltaBundler/Serializers/helpers/js.d.ts +8 -1
- package/src/DeltaBundler/Serializers/helpers/processModules.d.ts +8 -1
- package/src/DeltaBundler/Serializers/hmrJSBundle.d.ts +8 -1
- package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +8 -1
- package/src/DeltaBundler/Serializers/sourceMapObject.d.ts +8 -1
- package/src/DeltaBundler/Serializers/sourceMapString.d.ts +8 -1
- package/src/DeltaBundler/Transformer.d.ts +8 -1
- package/src/DeltaBundler/Worker.d.ts +8 -1
- package/src/DeltaBundler/WorkerFarm.d.ts +8 -1
- package/src/DeltaBundler/buildSubgraph.d.ts +8 -1
- package/src/DeltaBundler/getTransformCacheKey.d.ts +8 -1
- package/src/DeltaBundler/getTransformCacheKey.js +3 -1
- package/src/DeltaBundler/getTransformCacheKey.js.flow +7 -2
- package/src/DeltaBundler/mergeDeltas.d.ts +8 -1
- package/src/DeltaBundler/types.d.ts +8 -1
- package/src/DeltaBundler.d.ts +8 -1
- package/src/HmrServer.d.ts +22 -3
- package/src/HmrServer.js +7 -0
- package/src/HmrServer.js.flow +15 -5
- package/src/IncrementalBundler/GraphNotFoundError.d.ts +8 -1
- package/src/IncrementalBundler/ResourceNotFoundError.d.ts +8 -1
- package/src/IncrementalBundler/RevisionNotFoundError.d.ts +8 -1
- package/src/IncrementalBundler.d.ts +8 -1
- package/src/ModuleGraph/worker/JsFileWrapping.d.ts +8 -1
- package/src/ModuleGraph/worker/collectDependencies.d.ts +8 -1
- package/src/ModuleGraph/worker/collectDependencies.js +52 -0
- package/src/ModuleGraph/worker/collectDependencies.js.flow +67 -0
- package/src/ModuleGraph/worker/generateImportNames.d.ts +8 -1
- package/src/ModuleGraph/worker/importLocationsPlugin.d.ts +8 -1
- package/src/Server/MultipartResponse.d.ts +8 -1
- package/src/Server/symbolicate.d.ts +8 -1
- package/src/Server.d.ts +11 -1
- package/src/Server.js +42 -5
- package/src/Server.js.flow +45 -5
- package/src/cli/parseKeyValueParamArray.d.ts +8 -1
- package/src/cli-utils.d.ts +8 -1
- package/src/commands/build.d.ts +8 -1
- package/src/commands/dependencies.d.ts +8 -1
- package/src/commands/serve.d.ts +8 -1
- package/src/index.d.ts +29 -3
- package/src/index.flow.js +2 -2
- package/src/index.flow.js.flow +23 -4
- package/src/lib/BatchProcessor.d.ts +8 -1
- package/src/lib/CountingSet.d.ts +8 -1
- package/src/lib/JsonReporter.d.ts +8 -1
- package/src/lib/JsonReporter.js.flow +2 -2
- package/src/lib/RamBundleParser.d.ts +8 -1
- package/src/lib/TerminalReporter.d.ts +8 -1
- package/src/lib/TerminalReporter.js +39 -41
- package/src/lib/TerminalReporter.js.flow +51 -32
- package/src/lib/bundleProgressUtils.d.ts +8 -1
- package/src/lib/bundleToString.d.ts +8 -1
- package/src/lib/contextModule.d.ts +8 -1
- package/src/lib/contextModuleTemplates.d.ts +8 -1
- package/src/lib/countLines.d.ts +8 -1
- package/src/lib/createWebsocketServer.d.ts +8 -1
- package/src/lib/debounceAsyncQueue.d.ts +8 -1
- package/src/lib/formatBundlingError.d.ts +8 -1
- package/src/lib/getAppendScripts.d.ts +8 -1
- package/src/lib/getAppendScripts.js.flow +2 -2
- package/src/lib/getGraphId.d.ts +8 -1
- package/src/lib/getPreludeCode.d.ts +8 -1
- package/src/lib/getPrependedScripts.d.ts +8 -1
- package/src/lib/isResolvedDependency.d.ts +8 -1
- package/src/lib/logToConsole.d.ts +8 -1
- package/src/lib/logToConsole.js +8 -7
- package/src/lib/logToConsole.js.flow +7 -7
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.d.ts +8 -1
- package/src/lib/parseCustomResolverOptions.d.ts +8 -1
- package/src/lib/parseCustomTransformOptions.d.ts +8 -1
- package/src/lib/parseJsonBody.d.ts +8 -1
- package/src/lib/pathUtils.d.ts +8 -1
- package/src/lib/relativizeSourceMap.d.ts +8 -1
- package/src/lib/reporting.d.ts +8 -1
- package/src/lib/reporting.js +16 -7
- package/src/lib/reporting.js.flow +16 -5
- package/src/lib/splitBundleOptions.d.ts +8 -1
- package/src/lib/transformHelpers.d.ts +8 -1
- package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +16 -22
- package/src/node-haste/DependencyGraph/ModuleResolution.js +4 -22
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +10 -59
- package/src/node-haste/DependencyGraph/createFileMap.d.ts +8 -1
- package/src/node-haste/DependencyGraph/createFileMap.js +1 -2
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +4 -3
- package/src/node-haste/DependencyGraph.d.ts +9 -5
- package/src/node-haste/DependencyGraph.js +22 -11
- package/src/node-haste/DependencyGraph.js.flow +24 -13
- package/src/node-haste/PackageCache.d.ts +19 -16
- package/src/node-haste/PackageCache.js +65 -54
- package/src/node-haste/PackageCache.js.flow +103 -79
- package/src/node-haste/lib/AssetPaths.d.ts +8 -1
- package/src/node-haste/lib/parsePlatformFilePath.d.ts +8 -1
- package/src/shared/output/RamBundle/as-assets.d.ts +8 -1
- package/src/shared/output/RamBundle/as-indexed-file.d.ts +8 -1
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.d.ts +8 -1
- package/src/shared/output/RamBundle/magic-number.d.ts +8 -1
- package/src/shared/output/RamBundle/util.d.ts +8 -1
- package/src/shared/output/RamBundle/write-sourcemap.d.ts +8 -1
- package/src/shared/output/RamBundle.d.ts +8 -1
- package/src/shared/output/bundle.d.ts +8 -1
- package/src/shared/output/meta.d.ts +8 -1
- package/src/shared/output/unbundle.d.ts +8 -1
- package/src/shared/output/writeFile.d.ts +8 -1
- package/src/shared/types.d.ts +8 -1
- package/src/node-haste/Package.d.ts +0 -21
- package/src/node-haste/Package.js +0 -28
- package/src/node-haste/Package.js.flow +0 -39
package/src/lib/logToConsole.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true,
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
7
|
var _util = _interopRequireDefault(require("util"));
|
|
9
8
|
function _interopRequireDefault(e) {
|
|
10
9
|
return e && e.__esModule ? e : { default: e };
|
|
@@ -15,10 +14,10 @@ var _default = (terminal, level, ...data) => {
|
|
|
15
14
|
const logFunction = console[level] && level !== "trace" ? level : "log";
|
|
16
15
|
const color =
|
|
17
16
|
level === "error"
|
|
18
|
-
?
|
|
17
|
+
? ["inverse", "red"]
|
|
19
18
|
: level === "warn"
|
|
20
|
-
?
|
|
21
|
-
:
|
|
19
|
+
? ["inverse", "yellow"]
|
|
20
|
+
: ["inverse", "white"];
|
|
22
21
|
if (level === "group") {
|
|
23
22
|
groupStack.push(level);
|
|
24
23
|
} else if (level === "groupCollapsed") {
|
|
@@ -27,7 +26,7 @@ var _default = (terminal, level, ...data) => {
|
|
|
27
26
|
collapsedGuardTimer = setTimeout(() => {
|
|
28
27
|
if (groupStack.includes("groupCollapsed")) {
|
|
29
28
|
terminal.log(
|
|
30
|
-
|
|
29
|
+
_util.default.styleText(["inverse", "yellow", "bold"], " WARN "),
|
|
31
30
|
"Expected `console.groupEnd` to be called after `console.groupCollapsed`.",
|
|
32
31
|
);
|
|
33
32
|
groupStack.length = 0;
|
|
@@ -47,8 +46,10 @@ var _default = (terminal, level, ...data) => {
|
|
|
47
46
|
data[data.length - 1] = lastItem.trimEnd();
|
|
48
47
|
}
|
|
49
48
|
terminal.log(
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
_util.default.styleText(
|
|
50
|
+
[...color, "bold"],
|
|
51
|
+
` ${logFunction.toUpperCase()} `,
|
|
52
|
+
) + "".padEnd(groupStack.length * 2, " "),
|
|
52
53
|
_util.default.format(...data),
|
|
53
54
|
);
|
|
54
55
|
}
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
/* eslint-disable no-console */
|
|
12
12
|
|
|
13
13
|
import type {Terminal} from 'metro-core';
|
|
14
|
+
import type {BackgroundColors, ForegroundColors, Modifiers} from 'util';
|
|
14
15
|
|
|
15
|
-
import chalk from 'chalk';
|
|
16
16
|
import util from 'util';
|
|
17
17
|
|
|
18
18
|
const groupStack = [];
|
|
@@ -21,12 +21,12 @@ let collapsedGuardTimer;
|
|
|
21
21
|
export default (terminal: Terminal, level: string, ...data: Array<unknown>) => {
|
|
22
22
|
// $FlowFixMe[invalid-computed-prop]
|
|
23
23
|
const logFunction = console[level] && level !== 'trace' ? level : 'log';
|
|
24
|
-
const color =
|
|
24
|
+
const color: ReadonlyArray<ForegroundColors | BackgroundColors | Modifiers> =
|
|
25
25
|
level === 'error'
|
|
26
|
-
?
|
|
26
|
+
? ['inverse', 'red']
|
|
27
27
|
: level === 'warn'
|
|
28
|
-
?
|
|
29
|
-
:
|
|
28
|
+
? ['inverse', 'yellow']
|
|
29
|
+
: ['inverse', 'white'];
|
|
30
30
|
|
|
31
31
|
if (level === 'group') {
|
|
32
32
|
groupStack.push(level);
|
|
@@ -37,7 +37,7 @@ export default (terminal: Terminal, level: string, ...data: Array<unknown>) => {
|
|
|
37
37
|
collapsedGuardTimer = setTimeout(() => {
|
|
38
38
|
if (groupStack.includes('groupCollapsed')) {
|
|
39
39
|
terminal.log(
|
|
40
|
-
|
|
40
|
+
util.styleText(['inverse', 'yellow', 'bold'], ' WARN '),
|
|
41
41
|
'Expected `console.groupEnd` to be called after `console.groupCollapsed`.',
|
|
42
42
|
);
|
|
43
43
|
groupStack.length = 0;
|
|
@@ -60,7 +60,7 @@ export default (terminal: Terminal, level: string, ...data: Array<unknown>) => {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
terminal.log(
|
|
63
|
-
color
|
|
63
|
+
util.styleText([...color, 'bold'], ` ${logFunction.toUpperCase()} `) +
|
|
64
64
|
''.padEnd(groupStack.length * 2, ' '),
|
|
65
65
|
// `util.format` actually accepts any arguments.
|
|
66
66
|
// If the first argument is a string, it tries to format it.
|
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<972fc847af4a55ba0e4863c90532e99c>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/parseBundleOptionsFromBundleRequestUrl.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
9
16
|
*/
|
|
10
17
|
|
|
11
18
|
import type {BundleOptions} from '../shared/types';
|
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<e0f212b1e687fef985215d8c152e7c04>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/parseCustomResolverOptions.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
9
16
|
*/
|
|
10
17
|
|
|
11
18
|
import type {CustomResolverOptions} from 'metro-resolver';
|
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<086e5d861160a99775fa58beba59492a>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/parseCustomTransformOptions.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
9
16
|
*/
|
|
10
17
|
|
|
11
18
|
import type {CustomTransformOptions} from 'metro-transform-worker';
|
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<cd5e7346556814416374b8c8e79a8674>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/parseJsonBody.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
9
16
|
*/
|
|
10
17
|
|
|
11
18
|
import type {IncomingMessage} from 'http';
|
package/src/lib/pathUtils.d.ts
CHANGED
|
@@ -4,7 +4,14 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @noformat
|
|
8
|
+
* @generated SignedSource<<61d935169a7ad0d7f2d7b4c6e4eb0a96>>
|
|
9
|
+
*
|
|
10
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
11
|
+
* Original file: packages/metro/src/lib/pathUtils.js
|
|
12
|
+
* To regenerate, run:
|
|
13
|
+
* js1 build metro-ts-defs (internal) OR
|
|
14
|
+
* yarn run build-ts-defs (OSS)
|
|
8
15
|
*/
|
|
9
16
|
|
|
10
17
|
export declare const normalizePathSeparatorsToPosix: (
|
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<5282fe2c42baa79f957ef2a40bec560b>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/relativizeSourceMap.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
9
16
|
*/
|
|
10
17
|
|
|
11
18
|
import type {MixedSourceMap} from 'metro-source-map';
|
package/src/lib/reporting.d.ts
CHANGED
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<1ff95f1ad6bb911f3d2c2bc41d59bc1a>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/reporting.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
9
16
|
*/
|
|
10
17
|
|
|
11
18
|
import type {Terminal} from 'metro-core';
|
package/src/lib/reporting.js
CHANGED
|
@@ -7,30 +7,39 @@ exports.logError = logError;
|
|
|
7
7
|
exports.logInfo = logInfo;
|
|
8
8
|
exports.logWarning = logWarning;
|
|
9
9
|
exports.nullReporter = void 0;
|
|
10
|
-
var
|
|
10
|
+
var _tty = _interopRequireDefault(require("tty"));
|
|
11
11
|
var _util = _interopRequireDefault(require("util"));
|
|
12
12
|
function _interopRequireDefault(e) {
|
|
13
13
|
return e && e.__esModule ? e : { default: e };
|
|
14
14
|
}
|
|
15
|
+
const supportsColor = () =>
|
|
16
|
+
process.stdout instanceof _tty.default.WriteStream &&
|
|
17
|
+
process.stdout.hasColors();
|
|
15
18
|
function logWarning(terminal, format, ...args) {
|
|
16
19
|
const str = _util.default.format(format, ...args);
|
|
17
|
-
terminal.log(
|
|
20
|
+
terminal.log(
|
|
21
|
+
"%s %s",
|
|
22
|
+
_util.default.styleText(["yellow", "inverse", "bold"], " WARN "),
|
|
23
|
+
str,
|
|
24
|
+
);
|
|
18
25
|
}
|
|
19
26
|
function logError(terminal, format, ...args) {
|
|
20
27
|
terminal.log(
|
|
21
28
|
"%s %s",
|
|
22
|
-
|
|
29
|
+
_util.default.styleText(["red", "inverse", "bold"], " ERROR "),
|
|
23
30
|
_util.default.format(
|
|
24
|
-
|
|
25
|
-
? format
|
|
26
|
-
: _util.default.stripVTControlCharacters(format),
|
|
31
|
+
supportsColor() ? format : _util.default.stripVTControlCharacters(format),
|
|
27
32
|
...args,
|
|
28
33
|
),
|
|
29
34
|
);
|
|
30
35
|
}
|
|
31
36
|
function logInfo(terminal, format, ...args) {
|
|
32
37
|
const str = _util.default.format(format, ...args);
|
|
33
|
-
terminal.log(
|
|
38
|
+
terminal.log(
|
|
39
|
+
"%s %s",
|
|
40
|
+
_util.default.styleText(["cyan", "inverse", "bold"], " INFO "),
|
|
41
|
+
str,
|
|
42
|
+
);
|
|
34
43
|
}
|
|
35
44
|
const nullReporter = (exports.nullReporter = {
|
|
36
45
|
update() {},
|
|
@@ -14,9 +14,12 @@ import type {HealthCheckResult, WatcherStatus} from 'metro-file-map';
|
|
|
14
14
|
import type {CustomResolverOptions} from 'metro-resolver';
|
|
15
15
|
import type {CustomTransformOptions} from 'metro-transform-worker';
|
|
16
16
|
|
|
17
|
-
import
|
|
17
|
+
import tty from 'tty';
|
|
18
18
|
import util from 'util';
|
|
19
19
|
|
|
20
|
+
const supportsColor = (): boolean =>
|
|
21
|
+
process.stdout instanceof tty.WriteStream && process.stdout.hasColors();
|
|
22
|
+
|
|
20
23
|
export type BundleDetails = {
|
|
21
24
|
bundleType: string,
|
|
22
25
|
customResolverOptions: CustomResolverOptions,
|
|
@@ -190,7 +193,11 @@ export function logWarning(
|
|
|
190
193
|
...args: Array<unknown>
|
|
191
194
|
): void {
|
|
192
195
|
const str = util.format(format, ...args);
|
|
193
|
-
terminal.log(
|
|
196
|
+
terminal.log(
|
|
197
|
+
'%s %s',
|
|
198
|
+
util.styleText(['yellow', 'inverse', 'bold'], ' WARN '),
|
|
199
|
+
str,
|
|
200
|
+
);
|
|
194
201
|
}
|
|
195
202
|
|
|
196
203
|
/**
|
|
@@ -203,13 +210,13 @@ export function logError(
|
|
|
203
210
|
): void {
|
|
204
211
|
terminal.log(
|
|
205
212
|
'%s %s',
|
|
206
|
-
|
|
213
|
+
util.styleText(['red', 'inverse', 'bold'], ' ERROR '),
|
|
207
214
|
// Syntax errors may have colors applied for displaying code frames
|
|
208
215
|
// in various places outside of where Metro is currently running.
|
|
209
216
|
// If the current terminal does not support color, we'll strip the colors
|
|
210
217
|
// here.
|
|
211
218
|
util.format(
|
|
212
|
-
|
|
219
|
+
supportsColor() ? format : util.stripVTControlCharacters(format),
|
|
213
220
|
...args,
|
|
214
221
|
),
|
|
215
222
|
);
|
|
@@ -224,7 +231,11 @@ export function logInfo(
|
|
|
224
231
|
...args: Array<unknown>
|
|
225
232
|
): void {
|
|
226
233
|
const str = util.format(format, ...args);
|
|
227
|
-
terminal.log(
|
|
234
|
+
terminal.log(
|
|
235
|
+
'%s %s',
|
|
236
|
+
util.styleText(['cyan', 'inverse', 'bold'], ' INFO '),
|
|
237
|
+
str,
|
|
238
|
+
);
|
|
228
239
|
}
|
|
229
240
|
|
|
230
241
|
/**
|
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<cf1e935fe7a5b1c8573b53b1c1921e70>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/splitBundleOptions.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
9
16
|
*/
|
|
10
17
|
|
|
11
18
|
import type {BundleOptions, SplitBundleOptions} from '../shared/types';
|
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<dfdfdf9ddb80994cc031e3767a87b56f>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/transformHelpers.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
9
16
|
*/
|
|
10
17
|
|
|
11
18
|
import type Bundler from '../Bundler';
|
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<0024fd05b95efe19a24f9acc84ff474b>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/node-haste/DependencyGraph/ModuleResolution.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
9
16
|
*/
|
|
10
17
|
|
|
11
18
|
import type {
|
|
@@ -25,19 +32,7 @@ import type {
|
|
|
25
32
|
import type {PackageForModule, PackageJson} from 'metro-resolver/private/types';
|
|
26
33
|
|
|
27
34
|
export type DirExistsFn = (filePath: string) => boolean;
|
|
28
|
-
|
|
29
|
-
export type Moduleish = {readonly path: string};
|
|
30
|
-
export type PackageishCache<TPackage> = {
|
|
31
|
-
getPackage(
|
|
32
|
-
name: string,
|
|
33
|
-
platform?: string,
|
|
34
|
-
supportsNativePlatform?: boolean,
|
|
35
|
-
): TPackage;
|
|
36
|
-
getPackageOf(
|
|
37
|
-
absolutePath: string,
|
|
38
|
-
): null | undefined | {pkg: TPackage; packageRelativePath: string};
|
|
39
|
-
};
|
|
40
|
-
type Options<TPackage> = Readonly<{
|
|
35
|
+
type Options = Readonly<{
|
|
41
36
|
assetExts: ReadonlySet<string>;
|
|
42
37
|
dirExists: DirExistsFn;
|
|
43
38
|
disableHierarchicalLookup: boolean;
|
|
@@ -54,7 +49,10 @@ type Options<TPackage> = Readonly<{
|
|
|
54
49
|
platform: null | undefined | string,
|
|
55
50
|
) => null | undefined | string;
|
|
56
51
|
mainFields: ReadonlyArray<string>;
|
|
57
|
-
|
|
52
|
+
getPackage: (packageJsonPath: string) => null | undefined | PackageJson;
|
|
53
|
+
getPackageForModule: (
|
|
54
|
+
absolutePath: string,
|
|
55
|
+
) => null | undefined | PackageForModule;
|
|
58
56
|
nodeModulesPaths: ReadonlyArray<string>;
|
|
59
57
|
preferNativePlatform: boolean;
|
|
60
58
|
projectRoot: string;
|
|
@@ -69,11 +67,11 @@ type Options<TPackage> = Readonly<{
|
|
|
69
67
|
unstable_enablePackageExports: boolean;
|
|
70
68
|
unstable_incrementalResolution: boolean;
|
|
71
69
|
}>;
|
|
72
|
-
export declare class ModuleResolver
|
|
73
|
-
_options: Options
|
|
70
|
+
export declare class ModuleResolver {
|
|
71
|
+
_options: Options;
|
|
74
72
|
_projectRootFakeModulePath: string;
|
|
75
73
|
_cachedEmptyModule: null | undefined | BundlerResolution;
|
|
76
|
-
constructor(options: Options
|
|
74
|
+
constructor(options: Options);
|
|
77
75
|
_getEmptyModule(): BundlerResolution;
|
|
78
76
|
resolveDependency(
|
|
79
77
|
originModulePath: string,
|
|
@@ -82,10 +80,6 @@ export declare class ModuleResolver<TPackage extends Packageish> {
|
|
|
82
80
|
platform: string | null,
|
|
83
81
|
resolverOptions: ResolverInputOptions,
|
|
84
82
|
): BundlerResolution;
|
|
85
|
-
_getPackage: (packageJsonPath: string) => null | undefined | PackageJson;
|
|
86
|
-
_getPackageForModule: (
|
|
87
|
-
absolutePath: string,
|
|
88
|
-
) => null | undefined | PackageForModule;
|
|
89
83
|
/**
|
|
90
84
|
* TODO: Return Resolution instead of coercing to BundlerResolution here
|
|
91
85
|
*/
|
|
@@ -86,6 +86,8 @@ class ModuleResolver {
|
|
|
86
86
|
doesFileExist,
|
|
87
87
|
extraNodeModules,
|
|
88
88
|
fileSystemLookup,
|
|
89
|
+
getPackage,
|
|
90
|
+
getPackageForModule,
|
|
89
91
|
mainFields,
|
|
90
92
|
nodeModulesPaths,
|
|
91
93
|
preferNativePlatform,
|
|
@@ -109,9 +111,8 @@ class ModuleResolver {
|
|
|
109
111
|
doesFileExist,
|
|
110
112
|
extraNodeModules,
|
|
111
113
|
fileSystemLookup,
|
|
112
|
-
getPackage
|
|
113
|
-
getPackageForModule
|
|
114
|
-
this._getPackageForModule(absoluteModulePath),
|
|
114
|
+
getPackage,
|
|
115
|
+
getPackageForModule,
|
|
115
116
|
isESMImport: dependency.data.isESMImport,
|
|
116
117
|
mainFields,
|
|
117
118
|
nodeModulesPaths,
|
|
@@ -191,25 +192,6 @@ class ModuleResolver {
|
|
|
191
192
|
throw error;
|
|
192
193
|
}
|
|
193
194
|
}
|
|
194
|
-
_getPackage = (packageJsonPath) => {
|
|
195
|
-
try {
|
|
196
|
-
return this._options.packageCache.getPackage(packageJsonPath).read();
|
|
197
|
-
} catch (e) {}
|
|
198
|
-
return null;
|
|
199
|
-
};
|
|
200
|
-
_getPackageForModule = (absolutePath) => {
|
|
201
|
-
let result;
|
|
202
|
-
try {
|
|
203
|
-
result = this._options.packageCache.getPackageOf(absolutePath);
|
|
204
|
-
} catch (e) {}
|
|
205
|
-
return result != null
|
|
206
|
-
? {
|
|
207
|
-
packageJson: result.pkg.read(),
|
|
208
|
-
packageRelativePath: result.packageRelativePath,
|
|
209
|
-
rootPath: _path.default.dirname(result.pkg.path),
|
|
210
|
-
}
|
|
211
|
-
: null;
|
|
212
|
-
};
|
|
213
195
|
_getFileResolvedModule(resolution) {
|
|
214
196
|
switch (resolution.type) {
|
|
215
197
|
case "sourceFile":
|
|
@@ -35,28 +35,7 @@ import util from 'util';
|
|
|
35
35
|
|
|
36
36
|
export type DirExistsFn = (filePath: string) => boolean;
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
path: string,
|
|
40
|
-
read(): PackageJson,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export type Moduleish = interface {
|
|
44
|
-
+path: string,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export type PackageishCache<TPackage> = interface {
|
|
48
|
-
getPackage(
|
|
49
|
-
name: string,
|
|
50
|
-
platform?: string,
|
|
51
|
-
supportsNativePlatform?: boolean,
|
|
52
|
-
): TPackage,
|
|
53
|
-
getPackageOf(absolutePath: string): ?{
|
|
54
|
-
pkg: TPackage,
|
|
55
|
-
packageRelativePath: string,
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
type Options<TPackage> = Readonly<{
|
|
38
|
+
type Options = Readonly<{
|
|
60
39
|
assetExts: ReadonlySet<string>,
|
|
61
40
|
dirExists: DirExistsFn,
|
|
62
41
|
disableHierarchicalLookup: boolean,
|
|
@@ -67,7 +46,8 @@ type Options<TPackage> = Readonly<{
|
|
|
67
46
|
getHasteModulePath: (name: string, platform: ?string) => ?string,
|
|
68
47
|
getHastePackagePath: (name: string, platform: ?string) => ?string,
|
|
69
48
|
mainFields: ReadonlyArray<string>,
|
|
70
|
-
|
|
49
|
+
getPackage: (packageJsonPath: string) => ?PackageJson,
|
|
50
|
+
getPackageForModule: (absolutePath: string) => ?PackageForModule,
|
|
71
51
|
nodeModulesPaths: ReadonlyArray<string>,
|
|
72
52
|
preferNativePlatform: boolean,
|
|
73
53
|
projectRoot: string,
|
|
@@ -83,14 +63,14 @@ type Options<TPackage> = Readonly<{
|
|
|
83
63
|
unstable_incrementalResolution: boolean,
|
|
84
64
|
}>;
|
|
85
65
|
|
|
86
|
-
export class ModuleResolver
|
|
87
|
-
_options: Options
|
|
66
|
+
export class ModuleResolver {
|
|
67
|
+
_options: Options;
|
|
88
68
|
// A module representing the project root, used as the origin when resolving `emptyModulePath`.
|
|
89
69
|
_projectRootFakeModulePath: string;
|
|
90
70
|
// An empty module, the result of resolving `emptyModulePath` from the project root.
|
|
91
71
|
_cachedEmptyModule: ?BundlerResolution;
|
|
92
72
|
|
|
93
|
-
constructor(options: Options
|
|
73
|
+
constructor(options: Options) {
|
|
94
74
|
this._options = options;
|
|
95
75
|
const {projectRoot} = this._options;
|
|
96
76
|
this._projectRootFakeModulePath = path.join(projectRoot, '_');
|
|
@@ -132,6 +112,8 @@ export class ModuleResolver<TPackage: Packageish> {
|
|
|
132
112
|
doesFileExist,
|
|
133
113
|
extraNodeModules,
|
|
134
114
|
fileSystemLookup,
|
|
115
|
+
getPackage,
|
|
116
|
+
getPackageForModule,
|
|
135
117
|
mainFields,
|
|
136
118
|
nodeModulesPaths,
|
|
137
119
|
preferNativePlatform,
|
|
@@ -156,9 +138,8 @@ export class ModuleResolver<TPackage: Packageish> {
|
|
|
156
138
|
doesFileExist,
|
|
157
139
|
extraNodeModules,
|
|
158
140
|
fileSystemLookup,
|
|
159
|
-
getPackage
|
|
160
|
-
getPackageForModule
|
|
161
|
-
this._getPackageForModule(absoluteModulePath),
|
|
141
|
+
getPackage,
|
|
142
|
+
getPackageForModule,
|
|
162
143
|
isESMImport: dependency.data.isESMImport,
|
|
163
144
|
mainFields,
|
|
164
145
|
nodeModulesPaths,
|
|
@@ -240,36 +221,6 @@ export class ModuleResolver<TPackage: Packageish> {
|
|
|
240
221
|
}
|
|
241
222
|
}
|
|
242
223
|
|
|
243
|
-
_getPackage = (packageJsonPath: string): ?PackageJson => {
|
|
244
|
-
try {
|
|
245
|
-
return this._options.packageCache.getPackage(packageJsonPath).read();
|
|
246
|
-
} catch (e) {
|
|
247
|
-
// Do nothing. The standard module cache does not trigger any error, but
|
|
248
|
-
// the ModuleGraph one does, if the module does not exist.
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return null;
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
_getPackageForModule = (absolutePath: string): ?PackageForModule => {
|
|
255
|
-
let result;
|
|
256
|
-
|
|
257
|
-
try {
|
|
258
|
-
result = this._options.packageCache.getPackageOf(absolutePath);
|
|
259
|
-
} catch (e) {
|
|
260
|
-
// Do nothing. The standard module cache does not trigger any error, but
|
|
261
|
-
// the ModuleGraph one does, if the module does not exist.
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
return result != null
|
|
265
|
-
? {
|
|
266
|
-
packageJson: result.pkg.read(),
|
|
267
|
-
packageRelativePath: result.packageRelativePath,
|
|
268
|
-
rootPath: path.dirname(result.pkg.path),
|
|
269
|
-
}
|
|
270
|
-
: null;
|
|
271
|
-
};
|
|
272
|
-
|
|
273
224
|
/**
|
|
274
225
|
* TODO: Return Resolution instead of coercing to BundlerResolution here
|
|
275
226
|
*/
|
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<c008adad2ea747972e2f301a6375b447>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/node-haste/DependencyGraph/createFileMap.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
9
16
|
*/
|
|
10
17
|
|
|
11
18
|
import type {ConfigT} from 'metro-config';
|
|
@@ -71,7 +71,7 @@ function createFileMap(config, options) {
|
|
|
71
71
|
const { enabled: autoSaveEnabled, ...autoSaveOpts } =
|
|
72
72
|
config.watcher.unstable_autoSaveCache ?? {};
|
|
73
73
|
const autoSave = watch && autoSaveEnabled ? autoSaveOpts : false;
|
|
74
|
-
const plugins = [];
|
|
74
|
+
const plugins = [...(config.unstable_fileMapPlugins ?? [])];
|
|
75
75
|
let dependencyPlugin = null;
|
|
76
76
|
if (
|
|
77
77
|
config.resolver.dependencyExtractor != null &&
|
|
@@ -80,7 +80,6 @@ function createFileMap(config, options) {
|
|
|
80
80
|
dependencyPlugin = new _metroFileMap.DependencyPlugin({
|
|
81
81
|
dependencyExtractor: config.resolver.dependencyExtractor,
|
|
82
82
|
computeDependencies: true,
|
|
83
|
-
rootDir: config.projectRoot,
|
|
84
83
|
});
|
|
85
84
|
plugins.push(dependencyPlugin);
|
|
86
85
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import type {ConfigT} from 'metro-config';
|
|
13
|
-
import type {HasteMap} from 'metro-file-map';
|
|
13
|
+
import type {HasteMap, InputFileMapPlugin} from 'metro-file-map';
|
|
14
14
|
|
|
15
15
|
import ci from 'ci-info';
|
|
16
16
|
import MetroFileMap, {
|
|
@@ -75,7 +75,9 @@ export default function createFileMap(
|
|
|
75
75
|
config.watcher.unstable_autoSaveCache ?? {};
|
|
76
76
|
const autoSave = watch && autoSaveEnabled ? autoSaveOpts : false;
|
|
77
77
|
|
|
78
|
-
const plugins: Array<
|
|
78
|
+
const plugins: Array<InputFileMapPlugin> = [
|
|
79
|
+
...(config.unstable_fileMapPlugins ?? []),
|
|
80
|
+
];
|
|
79
81
|
|
|
80
82
|
let dependencyPlugin = null;
|
|
81
83
|
// Add DependencyPlugin if dependencies should be extracted
|
|
@@ -86,7 +88,6 @@ export default function createFileMap(
|
|
|
86
88
|
dependencyPlugin = new DependencyPlugin({
|
|
87
89
|
dependencyExtractor: config.resolver.dependencyExtractor,
|
|
88
90
|
computeDependencies: true,
|
|
89
|
-
rootDir: config.projectRoot,
|
|
90
91
|
});
|
|
91
92
|
plugins.push(dependencyPlugin);
|
|
92
93
|
}
|