metro 0.83.0 → 0.83.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 +16 -16
- package/src/Assets.js +68 -42
- package/src/Assets.js.flow +13 -24
- package/src/Bundler/util.js +40 -17
- package/src/Bundler/util.js.flow +6 -13
- package/src/Bundler.js +17 -6
- package/src/Bundler.js.flow +3 -7
- package/src/DeltaBundler/DeltaCalculator.js +15 -15
- package/src/DeltaBundler/DeltaCalculator.js.flow +4 -7
- package/src/DeltaBundler/Graph.js +45 -40
- package/src/DeltaBundler/Graph.js.flow +3 -4
- package/src/DeltaBundler/Serializers/baseJSBundle.js +24 -10
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +6 -9
- package/src/DeltaBundler/Serializers/getAllFiles.js +9 -6
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +4 -8
- package/src/DeltaBundler/Serializers/getAssets.js +18 -11
- package/src/DeltaBundler/Serializers/getAssets.js.flow +5 -9
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +26 -0
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js +7 -6
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +3 -9
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js +40 -23
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +11 -18
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js +4 -1
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js.flow +1 -5
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js +7 -4
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +3 -7
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js +4 -1
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js.flow +2 -6
- package/src/DeltaBundler/Serializers/helpers/js.js +65 -31
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +21 -21
- package/src/DeltaBundler/Serializers/helpers/processModules.js +8 -5
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -7
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +70 -25
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +43 -33
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +19 -16
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -14
- package/src/DeltaBundler/Serializers/sourceMapObject.js +12 -10
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +4 -9
- package/src/DeltaBundler/Serializers/sourceMapString.js +14 -12
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +4 -9
- package/src/DeltaBundler/Transformer.js +32 -27
- package/src/DeltaBundler/Transformer.js.flow +10 -17
- package/src/DeltaBundler/Worker.flow.js +25 -18
- package/src/DeltaBundler/Worker.flow.js.flow +12 -18
- package/src/DeltaBundler/Worker.js.flow +2 -0
- package/src/DeltaBundler/WorkerFarm.js +13 -11
- package/src/DeltaBundler/WorkerFarm.js.flow +7 -9
- package/src/DeltaBundler/buildSubgraph.js +13 -17
- package/src/DeltaBundler/buildSubgraph.js.flow +1 -1
- package/src/DeltaBundler/getTransformCacheKey.js +12 -6
- package/src/DeltaBundler/getTransformCacheKey.js.flow +5 -7
- package/src/DeltaBundler/mergeDeltas.js +4 -1
- package/src/DeltaBundler/mergeDeltas.js.flow +5 -6
- package/src/DeltaBundler/types.d.ts +4 -1
- package/src/DeltaBundler/{types.flow.js → types.js} +1 -5
- package/src/DeltaBundler/{types.flow.js.flow → types.js.flow} +5 -3
- package/src/DeltaBundler.js +15 -6
- package/src/DeltaBundler.js.flow +4 -8
- package/src/HmrServer.js +116 -68
- package/src/HmrServer.js.flow +41 -52
- package/src/IncrementalBundler/GraphNotFoundError.js +5 -1
- package/src/IncrementalBundler/GraphNotFoundError.js.flow +1 -5
- package/src/IncrementalBundler/ResourceNotFoundError.js +5 -1
- package/src/IncrementalBundler/ResourceNotFoundError.js.flow +1 -5
- package/src/IncrementalBundler/RevisionNotFoundError.js +5 -1
- package/src/IncrementalBundler/RevisionNotFoundError.js.flow +1 -5
- package/src/IncrementalBundler.js +71 -35
- package/src/IncrementalBundler.js.flow +12 -16
- package/src/ModuleGraph/test-helpers.js +19 -14
- package/src/ModuleGraph/worker/JsFileWrapping.js +22 -29
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +1 -10
- package/src/ModuleGraph/worker/collectDependencies.js +81 -52
- package/src/ModuleGraph/worker/collectDependencies.js.flow +15 -22
- package/src/ModuleGraph/worker/generateImportNames.js +12 -6
- package/src/ModuleGraph/worker/generateImportNames.js.flow +3 -7
- package/src/ModuleGraph/worker/importLocationsPlugin.js +5 -4
- package/src/ModuleGraph/worker/importLocationsPlugin.js.flow +2 -4
- package/src/Server/MultipartResponse.js +11 -4
- package/src/Server/MultipartResponse.js.flow +2 -5
- package/src/Server/symbolicate.d.ts +31 -0
- package/src/Server/symbolicate.js +15 -16
- package/src/Server/symbolicate.js.flow +6 -16
- package/src/Server.d.ts +0 -1
- package/src/Server.js +298 -191
- package/src/Server.js.flow +136 -99
- package/src/cli-utils.js +13 -4
- package/src/cli-utils.js.flow +3 -5
- package/src/cli.js.flow +2 -0
- package/src/commands/build.js +18 -15
- package/src/commands/build.js.flow +6 -6
- package/src/commands/dependencies.js +26 -16
- package/src/commands/dependencies.js.flow +7 -9
- package/src/commands/serve.js +16 -11
- package/src/commands/serve.js.flow +5 -6
- package/src/index.d.ts +26 -3
- package/src/index.flow.js +162 -72
- package/src/index.flow.js.flow +60 -47
- package/src/index.js.flow +2 -0
- package/src/integration_tests/basic_bundle/TestBundle.js.flow +2 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js +1 -5
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js +1 -5
- package/src/integration_tests/basic_bundle/import-export/index.js +5 -13
- package/src/integration_tests/basic_bundle/require-context/mode-eager.js +2 -2
- package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js +2 -2
- package/src/integration_tests/basic_bundle/require-context/mode-lazy.js +2 -2
- package/src/integration_tests/basic_bundle/require-context/mode-sync.js +1 -1
- package/src/integration_tests/basic_bundle/require-context/utils.js +1 -1
- package/src/integration_tests/execBundle.js +7 -4
- package/src/integration_tests/execBundle.js.flow +1 -3
- package/src/integration_tests/metro.config.js +3 -3
- package/src/lib/BatchProcessor.js +15 -5
- package/src/lib/BatchProcessor.js.flow +2 -6
- package/src/lib/CountingSet.js.flow +2 -2
- package/src/lib/JsonReporter.js +6 -2
- package/src/lib/JsonReporter.js.flow +1 -5
- package/src/lib/RamBundleParser.js +12 -3
- package/src/lib/RamBundleParser.js.flow +2 -6
- package/src/lib/TerminalReporter.js +95 -56
- package/src/lib/TerminalReporter.js.flow +9 -12
- package/src/lib/bundleToString.js +4 -1
- package/src/lib/bundleToString.js.flow +2 -9
- package/src/lib/contextModule.js +3 -7
- package/src/lib/contextModuleTemplates.js +9 -19
- package/src/lib/countLines.js +5 -1
- package/src/lib/countLines.js.flow +1 -3
- package/src/lib/createWebsocketServer.js +7 -7
- package/src/lib/createWebsocketServer.js.flow +4 -4
- package/src/lib/debounceAsyncQueue.js +4 -1
- package/src/lib/debounceAsyncQueue.js.flow +1 -5
- package/src/lib/formatBundlingError.js +32 -22
- package/src/lib/formatBundlingError.js.flow +18 -20
- package/src/lib/getAppendScripts.js +20 -20
- package/src/lib/getAppendScripts.js.flow +9 -13
- package/src/lib/getGraphId.js +12 -6
- package/src/lib/getGraphId.js.flow +4 -10
- package/src/lib/getPreludeCode.js +7 -10
- package/src/lib/getPreludeCode.js.flow +2 -6
- package/src/lib/getPrependedScripts.js +40 -16
- package/src/lib/getPrependedScripts.js.flow +8 -13
- package/src/lib/isResolvedDependency.js.flow +1 -1
- package/src/lib/logToConsole.js +18 -12
- package/src/lib/logToConsole.js.flow +5 -14
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +144 -0
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.js.flow +146 -0
- package/src/lib/parseCustomResolverOptions.js +8 -6
- package/src/lib/parseCustomResolverOptions.js.flow +6 -12
- package/src/lib/parseCustomTransformOptions.js +8 -6
- package/src/lib/parseCustomTransformOptions.js.flow +11 -14
- package/src/lib/parseJsonBody.js +4 -1
- package/src/lib/parseJsonBody.js.flow +1 -3
- package/src/lib/pathUtils.js +34 -0
- package/src/lib/pathUtils.js.flow +16 -0
- package/src/lib/relativizeSourceMap.js +12 -3
- package/src/lib/relativizeSourceMap.js.flow +2 -6
- package/src/lib/reporting.js +25 -19
- package/src/lib/reporting.js.flow +6 -16
- package/src/lib/splitBundleOptions.js +4 -2
- package/src/lib/splitBundleOptions.js.flow +4 -7
- package/src/lib/transformHelpers.js +19 -25
- package/src/lib/transformHelpers.js.flow +5 -15
- package/src/node-haste/DependencyGraph/ModuleResolution.js +75 -57
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +28 -44
- package/src/node-haste/DependencyGraph/createFileMap.js +15 -13
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +2 -5
- package/src/node-haste/DependencyGraph.js +61 -45
- package/src/node-haste/DependencyGraph.js.flow +34 -31
- package/src/node-haste/Package.js +13 -6
- package/src/node-haste/Package.js.flow +3 -7
- package/src/node-haste/{ModuleCache.js → PackageCache.js} +11 -19
- package/src/node-haste/{ModuleCache.js.flow → PackageCache.js.flow} +2 -30
- package/src/node-haste/lib/AssetPaths.js +14 -8
- package/src/node-haste/lib/AssetPaths.js.flow +7 -8
- package/src/node-haste/lib/parsePlatformFilePath.js +10 -4
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +2 -6
- package/src/shared/output/RamBundle/as-assets.js +42 -22
- package/src/shared/output/RamBundle/as-assets.js.flow +12 -15
- package/src/shared/output/RamBundle/as-indexed-file.js +33 -23
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +10 -16
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js +11 -10
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +4 -6
- package/src/shared/output/RamBundle/magic-number.js +5 -1
- package/src/shared/output/RamBundle/magic-number.js.flow +1 -3
- package/src/shared/output/RamBundle/util.js +21 -18
- package/src/shared/output/RamBundle/util.js.flow +4 -6
- package/src/shared/output/RamBundle/write-sourcemap.js +9 -3
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +2 -6
- package/src/shared/output/RamBundle.js +16 -9
- package/src/shared/output/RamBundle.js.flow +8 -12
- package/src/shared/output/bundle.flow.js +37 -13
- package/src/shared/output/bundle.flow.js.flow +24 -12
- package/src/shared/output/bundle.js.flow +2 -0
- package/src/shared/output/meta.js +16 -9
- package/src/shared/output/meta.js.flow +3 -5
- package/src/shared/output/unbundle.js +14 -1
- package/src/shared/output/unbundle.js.flow +1 -3
- package/src/shared/output/writeFile.js +11 -4
- package/src/shared/output/writeFile.js.flow +3 -5
- package/src/shared/types.d.ts +0 -1
- package/src/shared/{types.flow.js.flow → types.js.flow} +16 -17
- package/src/lib/createModuleIdFactory.js +0 -15
- package/src/lib/createModuleIdFactory.js.flow +0 -27
- package/src/lib/getMaxWorkers.js +0 -9
- package/src/lib/getMaxWorkers.js.flow +0 -22
- package/src/lib/parseOptionsFromUrl.js +0 -62
- package/src/lib/parseOptionsFromUrl.js.flow +0 -97
- package/src/node-haste/Module.js +0 -24
- package/src/node-haste/Module.js.flow +0 -41
- /package/src/shared/{types.flow.js → types.js} +0 -0
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = formatBundlingError;
|
|
7
|
+
var _GraphNotFoundError = _interopRequireDefault(
|
|
8
|
+
require("../IncrementalBundler/GraphNotFoundError"),
|
|
9
|
+
);
|
|
10
|
+
var _ResourceNotFoundError = _interopRequireDefault(
|
|
11
|
+
require("../IncrementalBundler/ResourceNotFoundError"),
|
|
12
|
+
);
|
|
13
|
+
var _RevisionNotFoundError = _interopRequireDefault(
|
|
14
|
+
require("../IncrementalBundler/RevisionNotFoundError"),
|
|
15
|
+
);
|
|
16
|
+
var _ModuleResolution = require("../node-haste/DependencyGraph/ModuleResolution");
|
|
17
|
+
var _codeFrame = require("@babel/code-frame");
|
|
18
|
+
var _errorStackParser = _interopRequireDefault(require("error-stack-parser"));
|
|
19
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
20
|
+
var _metroCore = require("metro-core");
|
|
21
|
+
var _serializeError = _interopRequireDefault(require("serialize-error"));
|
|
22
|
+
function _interopRequireDefault(e) {
|
|
23
|
+
return e && e.__esModule ? e : { default: e };
|
|
24
|
+
}
|
|
14
25
|
function formatBundlingError(error) {
|
|
15
|
-
if (error instanceof AmbiguousModuleResolutionError) {
|
|
26
|
+
if (error instanceof _metroCore.AmbiguousModuleResolutionError) {
|
|
16
27
|
const he = error.hasteError;
|
|
17
28
|
const message =
|
|
18
29
|
"Ambiguous resolution: module '" +
|
|
@@ -34,12 +45,12 @@ function formatBundlingError(error) {
|
|
|
34
45
|
};
|
|
35
46
|
}
|
|
36
47
|
if (
|
|
37
|
-
error instanceof UnableToResolveError ||
|
|
48
|
+
error instanceof _ModuleResolution.UnableToResolveError ||
|
|
38
49
|
(error instanceof Error &&
|
|
39
50
|
(error.type === "TransformError" || error.type === "NotFoundError"))
|
|
40
51
|
) {
|
|
41
52
|
return {
|
|
42
|
-
...
|
|
53
|
+
...(0, _serializeError.default)(error),
|
|
43
54
|
type: error.type,
|
|
44
55
|
errors: [
|
|
45
56
|
{
|
|
@@ -49,33 +60,33 @@ function formatBundlingError(error) {
|
|
|
49
60
|
},
|
|
50
61
|
],
|
|
51
62
|
};
|
|
52
|
-
} else if (error instanceof
|
|
63
|
+
} else if (error instanceof _ResourceNotFoundError.default) {
|
|
53
64
|
return {
|
|
54
65
|
type: "ResourceNotFoundError",
|
|
55
66
|
errors: [],
|
|
56
67
|
message: error.message,
|
|
57
68
|
};
|
|
58
|
-
} else if (error instanceof
|
|
69
|
+
} else if (error instanceof _GraphNotFoundError.default) {
|
|
59
70
|
return {
|
|
60
71
|
type: "GraphNotFoundError",
|
|
61
72
|
errors: [],
|
|
62
73
|
message: error.message,
|
|
63
74
|
};
|
|
64
|
-
} else if (error instanceof
|
|
75
|
+
} else if (error instanceof _RevisionNotFoundError.default) {
|
|
65
76
|
return {
|
|
66
77
|
type: "RevisionNotFoundError",
|
|
67
78
|
errors: [],
|
|
68
79
|
message: error.message,
|
|
69
80
|
};
|
|
70
81
|
} else {
|
|
71
|
-
const stack =
|
|
82
|
+
const stack = _errorStackParser.default.parse(error);
|
|
72
83
|
const fileName = stack[0].fileName;
|
|
73
84
|
const column = stack[0].columnNumber;
|
|
74
85
|
const line = stack[0].lineNumber;
|
|
75
86
|
let codeFrame = "";
|
|
76
87
|
try {
|
|
77
|
-
codeFrame = codeFrameColumns(
|
|
78
|
-
|
|
88
|
+
codeFrame = (0, _codeFrame.codeFrameColumns)(
|
|
89
|
+
_fs.default.readFileSync(fileName, "utf8"),
|
|
79
90
|
{
|
|
80
91
|
start: {
|
|
81
92
|
column,
|
|
@@ -84,7 +95,7 @@ function formatBundlingError(error) {
|
|
|
84
95
|
},
|
|
85
96
|
{
|
|
86
97
|
forceColor: true,
|
|
87
|
-
}
|
|
98
|
+
},
|
|
88
99
|
);
|
|
89
100
|
} catch {}
|
|
90
101
|
return {
|
|
@@ -94,4 +105,3 @@ function formatBundlingError(error) {
|
|
|
94
105
|
};
|
|
95
106
|
}
|
|
96
107
|
}
|
|
97
|
-
module.exports = formatBundlingError;
|
|
@@ -8,21 +8,17 @@
|
|
|
8
8
|
* @flow
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
import type {FormattedError} from 'metro-runtime/src/modules/types';
|
|
12
12
|
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const ErrorStackParser = require('error-stack-parser');
|
|
23
|
-
const fs = require('fs');
|
|
24
|
-
const {AmbiguousModuleResolutionError} = require('metro-core');
|
|
25
|
-
const serializeError = require('serialize-error');
|
|
13
|
+
import GraphNotFoundError from '../IncrementalBundler/GraphNotFoundError';
|
|
14
|
+
import ResourceNotFoundError from '../IncrementalBundler/ResourceNotFoundError';
|
|
15
|
+
import RevisionNotFoundError from '../IncrementalBundler/RevisionNotFoundError';
|
|
16
|
+
import {UnableToResolveError} from '../node-haste/DependencyGraph/ModuleResolution';
|
|
17
|
+
import {codeFrameColumns} from '@babel/code-frame';
|
|
18
|
+
import ErrorStackParser from 'error-stack-parser';
|
|
19
|
+
import fs from 'fs';
|
|
20
|
+
import {AmbiguousModuleResolutionError} from 'metro-core';
|
|
21
|
+
import serializeError from 'serialize-error';
|
|
26
22
|
|
|
27
23
|
export type CustomError = Error &
|
|
28
24
|
interface {
|
|
@@ -37,7 +33,9 @@ export type CustomError = Error &
|
|
|
37
33
|
}>,
|
|
38
34
|
};
|
|
39
35
|
|
|
40
|
-
function formatBundlingError(
|
|
36
|
+
export default function formatBundlingError(
|
|
37
|
+
error: CustomError,
|
|
38
|
+
): FormattedError {
|
|
41
39
|
if (error instanceof AmbiguousModuleResolutionError) {
|
|
42
40
|
const he = error.hasteError;
|
|
43
41
|
const message =
|
|
@@ -60,6 +58,8 @@ function formatBundlingError(error: CustomError): FormattedError {
|
|
|
60
58
|
if (
|
|
61
59
|
error instanceof UnableToResolveError ||
|
|
62
60
|
(error instanceof Error &&
|
|
61
|
+
/* $FlowFixMe[invalid-compare] Error discovered during Constant Condition
|
|
62
|
+
* roll out. See https://fburl.com/workplace/4oq3zi07. */
|
|
63
63
|
(error.type === 'TransformError' || error.type === 'NotFoundError'))
|
|
64
64
|
) {
|
|
65
65
|
return {
|
|
@@ -77,21 +77,21 @@ function formatBundlingError(error: CustomError): FormattedError {
|
|
|
77
77
|
} else if (error instanceof ResourceNotFoundError) {
|
|
78
78
|
return {
|
|
79
79
|
type: 'ResourceNotFoundError',
|
|
80
|
-
// $FlowFixMe[incompatible-
|
|
80
|
+
// $FlowFixMe[incompatible-type]
|
|
81
81
|
errors: [],
|
|
82
82
|
message: error.message,
|
|
83
83
|
};
|
|
84
84
|
} else if (error instanceof GraphNotFoundError) {
|
|
85
85
|
return {
|
|
86
86
|
type: 'GraphNotFoundError',
|
|
87
|
-
// $FlowFixMe[incompatible-
|
|
87
|
+
// $FlowFixMe[incompatible-type]
|
|
88
88
|
errors: [],
|
|
89
89
|
message: error.message,
|
|
90
90
|
};
|
|
91
91
|
} else if (error instanceof RevisionNotFoundError) {
|
|
92
92
|
return {
|
|
93
93
|
type: 'RevisionNotFoundError',
|
|
94
|
-
// $FlowFixMe[incompatible-
|
|
94
|
+
// $FlowFixMe[incompatible-type]
|
|
95
95
|
errors: [],
|
|
96
96
|
message: error.message,
|
|
97
97
|
};
|
|
@@ -120,5 +120,3 @@ function formatBundlingError(error: CustomError): FormattedError {
|
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
|
|
124
|
-
module.exports = formatBundlingError;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = getAppendScripts;
|
|
7
|
+
var _getInlineSourceMappingURL = _interopRequireDefault(
|
|
8
|
+
require("../DeltaBundler/Serializers/helpers/getInlineSourceMappingURL"),
|
|
9
|
+
);
|
|
10
|
+
var _sourceMapString = require("../DeltaBundler/Serializers/sourceMapString");
|
|
3
11
|
var _CountingSet = _interopRequireDefault(require("./CountingSet"));
|
|
12
|
+
var _countLines = _interopRequireDefault(require("./countLines"));
|
|
13
|
+
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
4
14
|
function _interopRequireDefault(e) {
|
|
5
|
-
return e && e.__esModule
|
|
6
|
-
? e
|
|
7
|
-
: {
|
|
8
|
-
default: e,
|
|
9
|
-
};
|
|
15
|
+
return e && e.__esModule ? e : { default: e };
|
|
10
16
|
}
|
|
11
|
-
const getInlineSourceMappingURL = require("../DeltaBundler/Serializers/helpers/getInlineSourceMappingURL");
|
|
12
|
-
const {
|
|
13
|
-
sourceMapString,
|
|
14
|
-
} = require("../DeltaBundler/Serializers/sourceMapString");
|
|
15
|
-
const countLines = require("./countLines");
|
|
16
|
-
const nullthrows = require("nullthrows");
|
|
17
17
|
function getAppendScripts(entryPoint, modules, options) {
|
|
18
18
|
const output = [];
|
|
19
19
|
if (options.runModule) {
|
|
@@ -21,7 +21,8 @@ function getAppendScripts(entryPoint, modules, options) {
|
|
|
21
21
|
for (const path of paths) {
|
|
22
22
|
if (modules.some((module) => module.path === path)) {
|
|
23
23
|
const code = options.getRunModuleStatement(
|
|
24
|
-
options.createModuleId(path)
|
|
24
|
+
options.createModuleId(path),
|
|
25
|
+
options.globalPrefix,
|
|
25
26
|
);
|
|
26
27
|
output.push({
|
|
27
28
|
path: `require-${path}`,
|
|
@@ -33,7 +34,7 @@ function getAppendScripts(entryPoint, modules, options) {
|
|
|
33
34
|
type: "js/script/virtual",
|
|
34
35
|
data: {
|
|
35
36
|
code,
|
|
36
|
-
lineCount:
|
|
37
|
+
lineCount: (0, _countLines.default)(code),
|
|
37
38
|
map: [],
|
|
38
39
|
},
|
|
39
40
|
},
|
|
@@ -44,15 +45,15 @@ function getAppendScripts(entryPoint, modules, options) {
|
|
|
44
45
|
}
|
|
45
46
|
if (options.inlineSourceMap || options.sourceMapUrl) {
|
|
46
47
|
const sourceMappingURL = options.inlineSourceMap
|
|
47
|
-
?
|
|
48
|
-
sourceMapString(modules, {
|
|
48
|
+
? (0, _getInlineSourceMappingURL.default)(
|
|
49
|
+
(0, _sourceMapString.sourceMapString)(modules, {
|
|
49
50
|
processModuleFilter: () => true,
|
|
50
51
|
excludeSource: false,
|
|
51
52
|
shouldAddToIgnoreList: options.shouldAddToIgnoreList,
|
|
52
53
|
getSourceUrl: options.getSourceUrl,
|
|
53
|
-
})
|
|
54
|
+
}),
|
|
54
55
|
)
|
|
55
|
-
:
|
|
56
|
+
: (0, _nullthrows.default)(options.sourceMapUrl);
|
|
56
57
|
const code = `//# sourceMappingURL=${sourceMappingURL}`;
|
|
57
58
|
output.push({
|
|
58
59
|
path: "source-map",
|
|
@@ -64,7 +65,7 @@ function getAppendScripts(entryPoint, modules, options) {
|
|
|
64
65
|
type: "js/script/virtual",
|
|
65
66
|
data: {
|
|
66
67
|
code,
|
|
67
|
-
lineCount:
|
|
68
|
+
lineCount: (0, _countLines.default)(code),
|
|
68
69
|
map: [],
|
|
69
70
|
},
|
|
70
71
|
},
|
|
@@ -83,7 +84,7 @@ function getAppendScripts(entryPoint, modules, options) {
|
|
|
83
84
|
type: "js/script/virtual",
|
|
84
85
|
data: {
|
|
85
86
|
code,
|
|
86
|
-
lineCount:
|
|
87
|
+
lineCount: (0, _countLines.default)(code),
|
|
87
88
|
map: [],
|
|
88
89
|
},
|
|
89
90
|
},
|
|
@@ -92,4 +93,3 @@ function getAppendScripts(entryPoint, modules, options) {
|
|
|
92
93
|
}
|
|
93
94
|
return output;
|
|
94
95
|
}
|
|
95
|
-
module.exports = getAppendScripts;
|
|
@@ -9,23 +9,20 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
12
|
import type {Module} from '../DeltaBundler';
|
|
14
|
-
import type {Dependency} from '../DeltaBundler/types
|
|
13
|
+
import type {Dependency} from '../DeltaBundler/types';
|
|
15
14
|
|
|
15
|
+
import getInlineSourceMappingURL from '../DeltaBundler/Serializers/helpers/getInlineSourceMappingURL';
|
|
16
|
+
import {sourceMapString} from '../DeltaBundler/Serializers/sourceMapString';
|
|
16
17
|
import CountingSet from './CountingSet';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const {
|
|
20
|
-
sourceMapString,
|
|
21
|
-
} = require('../DeltaBundler/Serializers/sourceMapString');
|
|
22
|
-
const countLines = require('./countLines');
|
|
23
|
-
const nullthrows = require('nullthrows');
|
|
18
|
+
import countLines from './countLines';
|
|
19
|
+
import nullthrows from 'nullthrows';
|
|
24
20
|
|
|
25
21
|
type Options<T: number | string> = $ReadOnly<{
|
|
26
22
|
asyncRequireModulePath: string,
|
|
27
23
|
createModuleId: string => T,
|
|
28
|
-
getRunModuleStatement: T => string,
|
|
24
|
+
getRunModuleStatement: (moduleId: T, globalPrefix: string) => string,
|
|
25
|
+
globalPrefix: string,
|
|
29
26
|
inlineSourceMap: ?boolean,
|
|
30
27
|
runBeforeMainModule: $ReadOnlyArray<string>,
|
|
31
28
|
runModule: boolean,
|
|
@@ -36,7 +33,7 @@ type Options<T: number | string> = $ReadOnly<{
|
|
|
36
33
|
...
|
|
37
34
|
}>;
|
|
38
35
|
|
|
39
|
-
function getAppendScripts<T: number | string>(
|
|
36
|
+
export default function getAppendScripts<T: number | string>(
|
|
40
37
|
entryPoint: string,
|
|
41
38
|
modules: $ReadOnlyArray<Module<>>,
|
|
42
39
|
options: Options<T>,
|
|
@@ -50,6 +47,7 @@ function getAppendScripts<T: number | string>(
|
|
|
50
47
|
if (modules.some((module: Module<>) => module.path === path)) {
|
|
51
48
|
const code = options.getRunModuleStatement(
|
|
52
49
|
options.createModuleId(path),
|
|
50
|
+
options.globalPrefix,
|
|
53
51
|
);
|
|
54
52
|
output.push({
|
|
55
53
|
path: `require-${path}`,
|
|
@@ -124,5 +122,3 @@ function getAppendScripts<T: number | string>(
|
|
|
124
122
|
|
|
125
123
|
return output;
|
|
126
124
|
}
|
|
127
|
-
|
|
128
|
-
module.exports = getAppendScripts;
|
package/src/lib/getGraphId.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = getGraphId;
|
|
7
|
+
var _canonicalize = _interopRequireDefault(
|
|
8
|
+
require("metro-core/private/canonicalize"),
|
|
9
|
+
);
|
|
10
|
+
function _interopRequireDefault(e) {
|
|
11
|
+
return e && e.__esModule ? e : { default: e };
|
|
12
|
+
}
|
|
4
13
|
function getGraphId(
|
|
5
14
|
entryFile,
|
|
6
15
|
options,
|
|
7
|
-
{ shallow, lazy, unstable_allowRequireContext, resolverOptions }
|
|
16
|
+
{ shallow, lazy, unstable_allowRequireContext, resolverOptions },
|
|
8
17
|
) {
|
|
9
18
|
return JSON.stringify(
|
|
10
19
|
{
|
|
@@ -14,9 +23,7 @@ function getGraphId(
|
|
|
14
23
|
customTransformOptions: options.customTransformOptions ?? null,
|
|
15
24
|
dev: options.dev,
|
|
16
25
|
experimentalImportSupport: options.experimentalImportSupport || false,
|
|
17
|
-
hot: options.hot,
|
|
18
26
|
minify: options.minify,
|
|
19
|
-
unstable_disableES6Transforms: options.unstable_disableES6Transforms,
|
|
20
27
|
platform: options.platform != null ? options.platform : null,
|
|
21
28
|
type: options.type,
|
|
22
29
|
lazy,
|
|
@@ -26,7 +33,6 @@ function getGraphId(
|
|
|
26
33
|
options.unstable_transformProfile || "default",
|
|
27
34
|
},
|
|
28
35
|
},
|
|
29
|
-
|
|
36
|
+
_canonicalize.default,
|
|
30
37
|
);
|
|
31
38
|
}
|
|
32
|
-
module.exports = getGraphId;
|
|
@@ -9,16 +9,14 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
import type {TransformInputOptions} from '../DeltaBundler/types';
|
|
13
|
+
import type {ResolverInputOptions} from '../shared/types';
|
|
13
14
|
|
|
14
|
-
import
|
|
15
|
-
import type {ResolverInputOptions} from '../shared/types.flow';
|
|
16
|
-
|
|
17
|
-
const canonicalize = require('metro-core/private/canonicalize');
|
|
15
|
+
import canonicalize from 'metro-core/private/canonicalize';
|
|
18
16
|
|
|
19
17
|
export opaque type GraphId: string = string;
|
|
20
18
|
|
|
21
|
-
function getGraphId(
|
|
19
|
+
export default function getGraphId(
|
|
22
20
|
entryFile: string,
|
|
23
21
|
options: TransformInputOptions,
|
|
24
22
|
{
|
|
@@ -41,9 +39,7 @@ function getGraphId(
|
|
|
41
39
|
customTransformOptions: options.customTransformOptions ?? null,
|
|
42
40
|
dev: options.dev,
|
|
43
41
|
experimentalImportSupport: options.experimentalImportSupport || false,
|
|
44
|
-
hot: options.hot,
|
|
45
42
|
minify: options.minify,
|
|
46
|
-
unstable_disableES6Transforms: options.unstable_disableES6Transforms,
|
|
47
43
|
platform: options.platform != null ? options.platform : null,
|
|
48
44
|
type: options.type,
|
|
49
45
|
lazy,
|
|
@@ -56,5 +52,3 @@ function getGraphId(
|
|
|
56
52
|
canonicalize,
|
|
57
53
|
);
|
|
58
54
|
}
|
|
59
|
-
|
|
60
|
-
module.exports = getGraphId;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = getPreludeCode;
|
|
3
7
|
function getPreludeCode({
|
|
4
8
|
extraVars,
|
|
5
9
|
isDev,
|
|
@@ -15,14 +19,10 @@ function getPreludeCode({
|
|
|
15
19
|
];
|
|
16
20
|
if (isDev) {
|
|
17
21
|
vars.push(
|
|
18
|
-
`${globalPrefix}__requireCycleIgnorePatterns=[${requireCycleIgnorePatterns
|
|
19
|
-
.map((regex) => regex.toString())
|
|
20
|
-
.join(",")}]`
|
|
22
|
+
`${globalPrefix}__requireCycleIgnorePatterns=[${requireCycleIgnorePatterns.map((regex) => regex.toString()).join(",")}]`,
|
|
21
23
|
);
|
|
22
24
|
}
|
|
23
|
-
return `var ${vars.join(",")};${processEnv(
|
|
24
|
-
isDev ? "development" : "production"
|
|
25
|
-
)}`;
|
|
25
|
+
return `var ${vars.join(",")};${processEnv(isDev ? "development" : "production")}`;
|
|
26
26
|
}
|
|
27
27
|
const excluded = new Set(["__BUNDLE_START_TIME__", "__DEV__", "process"]);
|
|
28
28
|
function formatExtraVars(extraVars) {
|
|
@@ -35,8 +35,5 @@ function formatExtraVars(extraVars) {
|
|
|
35
35
|
return assignments;
|
|
36
36
|
}
|
|
37
37
|
function processEnv(nodeEnv) {
|
|
38
|
-
return `process.env=process.env||{};process.env.NODE_ENV=process.env.NODE_ENV||${JSON.stringify(
|
|
39
|
-
nodeEnv
|
|
40
|
-
)};`;
|
|
38
|
+
return `process.env=process.env||{};process.env.NODE_ENV=process.env.NODE_ENV||${JSON.stringify(nodeEnv)};`;
|
|
41
39
|
}
|
|
42
|
-
module.exports = getPreludeCode;
|
|
@@ -9,9 +9,7 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function getPreludeCode({
|
|
12
|
+
export default function getPreludeCode({
|
|
15
13
|
extraVars,
|
|
16
14
|
isDev,
|
|
17
15
|
globalPrefix,
|
|
@@ -54,7 +52,7 @@ function formatExtraVars(extraVars: ?{[string]: mixed, ...}): Array<string> {
|
|
|
54
52
|
|
|
55
53
|
for (const key in extraVars) {
|
|
56
54
|
if (extraVars.hasOwnProperty(key) && !excluded.has(key)) {
|
|
57
|
-
/* $FlowFixMe(>=0.95.0 site=react_native_fb) This comment suppresses an
|
|
55
|
+
/* $FlowFixMe[incompatible-type](>=0.95.0 site=react_native_fb) This comment suppresses an
|
|
58
56
|
* error found when Flow v0.95 was deployed. To see the error, delete
|
|
59
57
|
* this comment and run Flow. */
|
|
60
58
|
assignments.push(`${key}=${JSON.stringify(extraVars[key])}`);
|
|
@@ -69,5 +67,3 @@ function processEnv(nodeEnv: string): string {
|
|
|
69
67
|
nodeEnv,
|
|
70
68
|
)};`;
|
|
71
69
|
}
|
|
72
|
-
|
|
73
|
-
module.exports = getPreludeCode;
|
|
@@ -1,23 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = getPrependedScripts;
|
|
3
7
|
var _CountingSet = _interopRequireDefault(require("./CountingSet"));
|
|
8
|
+
var _countLines = _interopRequireDefault(require("./countLines"));
|
|
9
|
+
var _getPreludeCode = _interopRequireDefault(require("./getPreludeCode"));
|
|
10
|
+
var transformHelpers = _interopRequireWildcard(require("./transformHelpers"));
|
|
11
|
+
var defaults = _interopRequireWildcard(
|
|
12
|
+
require("metro-config/private/defaults/defaults"),
|
|
13
|
+
);
|
|
14
|
+
function _getRequireWildcardCache(e) {
|
|
15
|
+
if ("function" != typeof WeakMap) return null;
|
|
16
|
+
var r = new WeakMap(),
|
|
17
|
+
t = new WeakMap();
|
|
18
|
+
return (_getRequireWildcardCache = function (e) {
|
|
19
|
+
return e ? t : r;
|
|
20
|
+
})(e);
|
|
21
|
+
}
|
|
22
|
+
function _interopRequireWildcard(e, r) {
|
|
23
|
+
if (!r && e && e.__esModule) return e;
|
|
24
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
25
|
+
return { default: e };
|
|
26
|
+
var t = _getRequireWildcardCache(r);
|
|
27
|
+
if (t && t.has(e)) return t.get(e);
|
|
28
|
+
var n = { __proto__: null },
|
|
29
|
+
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
30
|
+
for (var u in e)
|
|
31
|
+
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
32
|
+
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
33
|
+
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
34
|
+
}
|
|
35
|
+
return ((n.default = e), t && t.set(e, n), n);
|
|
36
|
+
}
|
|
4
37
|
function _interopRequireDefault(e) {
|
|
5
|
-
return e && e.__esModule
|
|
6
|
-
? e
|
|
7
|
-
: {
|
|
8
|
-
default: e,
|
|
9
|
-
};
|
|
38
|
+
return e && e.__esModule ? e : { default: e };
|
|
10
39
|
}
|
|
11
|
-
const countLines = require("./countLines");
|
|
12
|
-
const getPreludeCode = require("./getPreludeCode");
|
|
13
|
-
const transformHelpers = require("./transformHelpers");
|
|
14
|
-
const defaults = require("metro-config/private/defaults/defaults");
|
|
15
40
|
async function getPrependedScripts(
|
|
16
41
|
config,
|
|
17
42
|
options,
|
|
18
43
|
resolverOptions,
|
|
19
44
|
bundler,
|
|
20
|
-
deltaBundler
|
|
45
|
+
deltaBundler,
|
|
21
46
|
) {
|
|
22
47
|
const polyfillModuleNames = config.serializer
|
|
23
48
|
.getPolyfills({
|
|
@@ -34,7 +59,7 @@ async function getPrependedScripts(
|
|
|
34
59
|
resolve: await transformHelpers.getResolveDependencyFn(
|
|
35
60
|
bundler,
|
|
36
61
|
options.platform,
|
|
37
|
-
resolverOptions
|
|
62
|
+
resolverOptions,
|
|
38
63
|
),
|
|
39
64
|
transform: await transformHelpers.getTransformFn(
|
|
40
65
|
[defaults.moduleSystem, ...polyfillModuleNames],
|
|
@@ -42,7 +67,7 @@ async function getPrependedScripts(
|
|
|
42
67
|
deltaBundler,
|
|
43
68
|
config,
|
|
44
69
|
transformOptions,
|
|
45
|
-
resolverOptions
|
|
70
|
+
resolverOptions,
|
|
46
71
|
),
|
|
47
72
|
unstable_allowRequireContext:
|
|
48
73
|
config.transformer.unstable_allowRequireContext,
|
|
@@ -52,7 +77,7 @@ async function getPrependedScripts(
|
|
|
52
77
|
unstable_enablePackageExports:
|
|
53
78
|
config.resolver.unstable_enablePackageExports,
|
|
54
79
|
shallow: false,
|
|
55
|
-
}
|
|
80
|
+
},
|
|
56
81
|
);
|
|
57
82
|
return [
|
|
58
83
|
_getPrelude({
|
|
@@ -64,7 +89,7 @@ async function getPrependedScripts(
|
|
|
64
89
|
];
|
|
65
90
|
}
|
|
66
91
|
function _getPrelude({ dev, globalPrefix, requireCycleIgnorePatterns }) {
|
|
67
|
-
const code =
|
|
92
|
+
const code = (0, _getPreludeCode.default)({
|
|
68
93
|
isDev: dev,
|
|
69
94
|
globalPrefix,
|
|
70
95
|
requireCycleIgnorePatterns,
|
|
@@ -80,11 +105,10 @@ function _getPrelude({ dev, globalPrefix, requireCycleIgnorePatterns }) {
|
|
|
80
105
|
type: "js/script/virtual",
|
|
81
106
|
data: {
|
|
82
107
|
code,
|
|
83
|
-
lineCount:
|
|
108
|
+
lineCount: (0, _countLines.default)(code),
|
|
84
109
|
map: [],
|
|
85
110
|
},
|
|
86
111
|
},
|
|
87
112
|
],
|
|
88
113
|
};
|
|
89
114
|
}
|
|
90
|
-
module.exports = getPrependedScripts;
|
|
@@ -9,22 +9,19 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
import type Bundler from '../Bundler';
|
|
15
13
|
import type DeltaBundler, {Module} from '../DeltaBundler';
|
|
16
|
-
import type {TransformInputOptions} from '../DeltaBundler/types
|
|
17
|
-
import type {ResolverInputOptions} from '../shared/types
|
|
18
|
-
import type {ConfigT} from 'metro-config
|
|
14
|
+
import type {TransformInputOptions} from '../DeltaBundler/types';
|
|
15
|
+
import type {ResolverInputOptions} from '../shared/types';
|
|
16
|
+
import type {ConfigT} from 'metro-config';
|
|
19
17
|
|
|
20
18
|
import CountingSet from './CountingSet';
|
|
19
|
+
import countLines from './countLines';
|
|
20
|
+
import getPreludeCode from './getPreludeCode';
|
|
21
|
+
import * as transformHelpers from './transformHelpers';
|
|
22
|
+
import * as defaults from 'metro-config/private/defaults/defaults';
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
const getPreludeCode = require('./getPreludeCode');
|
|
24
|
-
const transformHelpers = require('./transformHelpers');
|
|
25
|
-
const defaults = require('metro-config/private/defaults/defaults');
|
|
26
|
-
|
|
27
|
-
async function getPrependedScripts(
|
|
24
|
+
export default async function getPrependedScripts(
|
|
28
25
|
config: ConfigT,
|
|
29
26
|
options: Omit<TransformInputOptions, 'type'>,
|
|
30
27
|
resolverOptions: ResolverInputOptions,
|
|
@@ -115,5 +112,3 @@ function _getPrelude({
|
|
|
115
112
|
],
|
|
116
113
|
};
|
|
117
114
|
}
|
|
118
|
-
|
|
119
|
-
module.exports = getPrependedScripts;
|