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,33 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = getRamBundleInfo;
|
|
7
|
+
var _util = require("../../Bundler/util");
|
|
8
|
+
var _getAppendScripts = _interopRequireDefault(
|
|
9
|
+
require("../../lib/getAppendScripts"),
|
|
10
|
+
);
|
|
11
|
+
var _getTransitiveDependencies = _interopRequireDefault(
|
|
12
|
+
require("./helpers/getTransitiveDependencies"),
|
|
13
|
+
);
|
|
14
|
+
var _js = require("./helpers/js");
|
|
15
|
+
var _sourceMapObject = require("./sourceMapObject");
|
|
16
|
+
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
17
|
+
var _path = _interopRequireDefault(require("path"));
|
|
18
|
+
function _interopRequireDefault(e) {
|
|
19
|
+
return e && e.__esModule ? e : { default: e };
|
|
20
|
+
}
|
|
10
21
|
async function getRamBundleInfo(entryPoint, pre, graph, options) {
|
|
11
22
|
let modules = [...pre, ...graph.dependencies.values()];
|
|
12
|
-
modules = modules.concat(
|
|
23
|
+
modules = modules.concat(
|
|
24
|
+
(0, _getAppendScripts.default)(entryPoint, modules, options),
|
|
25
|
+
);
|
|
13
26
|
modules.forEach((module) => options.createModuleId(module.path));
|
|
14
27
|
const ramModules = modules
|
|
15
|
-
.filter(isJsModule)
|
|
28
|
+
.filter(_js.isJsModule)
|
|
16
29
|
.filter(options.processModuleFilter)
|
|
17
30
|
.map((module) => ({
|
|
18
31
|
id: options.createModuleId(module.path),
|
|
19
|
-
code: wrapModule(module, options),
|
|
20
|
-
map: sourceMapObject([module], {
|
|
32
|
+
code: (0, _js.wrapModule)(module, options),
|
|
33
|
+
map: (0, _sourceMapObject.sourceMapObject)([module], {
|
|
21
34
|
excludeSource: options.excludeSource,
|
|
22
35
|
processModuleFilter: options.processModuleFilter,
|
|
23
36
|
shouldAddToIgnoreList: options.shouldAddToIgnoreList,
|
|
24
37
|
getSourceUrl: options.getSourceUrl,
|
|
25
38
|
}),
|
|
26
|
-
name:
|
|
39
|
+
name: _path.default.basename(module.path),
|
|
27
40
|
sourcePath: module.path,
|
|
28
41
|
source: module.getSource().toString(),
|
|
29
|
-
type:
|
|
30
|
-
.type,
|
|
42
|
+
type: (0, _nullthrows.default)(
|
|
43
|
+
module.output.find(({ type }) => type.startsWith("js")),
|
|
44
|
+
).type,
|
|
31
45
|
}));
|
|
32
46
|
const { preloadedModules, ramGroups } = await _getRamOptions(
|
|
33
47
|
entryPoint,
|
|
@@ -35,8 +49,8 @@ async function getRamBundleInfo(entryPoint, pre, graph, options) {
|
|
|
35
49
|
dev: options.dev,
|
|
36
50
|
platform: options.platform,
|
|
37
51
|
},
|
|
38
|
-
(filePath) =>
|
|
39
|
-
options.getTransformOptions
|
|
52
|
+
(filePath) => (0, _getTransitiveDependencies.default)(filePath, graph),
|
|
53
|
+
options.getTransformOptions,
|
|
40
54
|
);
|
|
41
55
|
const startupModules = [];
|
|
42
56
|
const lazyModules = [];
|
|
@@ -53,11 +67,14 @@ async function getRamBundleInfo(entryPoint, pre, graph, options) {
|
|
|
53
67
|
lazyModules.push(module);
|
|
54
68
|
}
|
|
55
69
|
});
|
|
56
|
-
const groups = createRamBundleGroups(
|
|
70
|
+
const groups = (0, _util.createRamBundleGroups)(
|
|
57
71
|
ramGroups,
|
|
58
72
|
lazyModules,
|
|
59
73
|
(module, dependenciesByPath) => {
|
|
60
|
-
const deps =
|
|
74
|
+
const deps = (0, _getTransitiveDependencies.default)(
|
|
75
|
+
module.sourcePath,
|
|
76
|
+
graph,
|
|
77
|
+
);
|
|
61
78
|
const output = new Set();
|
|
62
79
|
for (const dependency of deps) {
|
|
63
80
|
const module = dependenciesByPath.get(dependency);
|
|
@@ -66,10 +83,11 @@ async function getRamBundleInfo(entryPoint, pre, graph, options) {
|
|
|
66
83
|
}
|
|
67
84
|
}
|
|
68
85
|
return output;
|
|
69
|
-
}
|
|
86
|
+
},
|
|
70
87
|
);
|
|
71
88
|
return {
|
|
72
|
-
getDependencies: (filePath) =>
|
|
89
|
+
getDependencies: (filePath) =>
|
|
90
|
+
(0, _getTransitiveDependencies.default)(filePath, graph),
|
|
73
91
|
groups,
|
|
74
92
|
lazyModules,
|
|
75
93
|
startupModules,
|
|
@@ -79,7 +97,7 @@ async function _getRamOptions(
|
|
|
79
97
|
entryFile,
|
|
80
98
|
options,
|
|
81
99
|
getDependencies,
|
|
82
|
-
getTransformOptions
|
|
100
|
+
getTransformOptions,
|
|
83
101
|
) {
|
|
84
102
|
if (getTransformOptions == null) {
|
|
85
103
|
return {
|
|
@@ -94,11 +112,10 @@ async function _getRamOptions(
|
|
|
94
112
|
hot: true,
|
|
95
113
|
platform: options.platform,
|
|
96
114
|
},
|
|
97
|
-
async (x) => Array.from(getDependencies)
|
|
115
|
+
async (x) => Array.from(getDependencies),
|
|
98
116
|
);
|
|
99
117
|
return {
|
|
100
118
|
preloadedModules: preloadedModules || {},
|
|
101
119
|
ramGroups: ramGroups || [],
|
|
102
120
|
};
|
|
103
121
|
}
|
|
104
|
-
module.exports = getRamBundleInfo;
|
|
@@ -9,23 +9,18 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import type {
|
|
15
|
-
ModuleTransportLike,
|
|
16
|
-
RamModuleTransport,
|
|
17
|
-
} from '../../shared/types.flow';
|
|
18
|
-
import type {Module, ReadOnlyGraph, SerializerOptions} from '../types.flow';
|
|
12
|
+
import type {ModuleTransportLike, RamModuleTransport} from '../../shared/types';
|
|
13
|
+
import type {Module, ReadOnlyGraph, SerializerOptions} from '../types';
|
|
19
14
|
import type {SourceMapGeneratorOptions} from './sourceMapGenerator';
|
|
20
15
|
import type {GetTransformOptions} from 'metro-config';
|
|
21
16
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
import {createRamBundleGroups} from '../../Bundler/util';
|
|
18
|
+
import getAppendScripts from '../../lib/getAppendScripts';
|
|
19
|
+
import getTransitiveDependencies from './helpers/getTransitiveDependencies';
|
|
20
|
+
import {isJsModule, wrapModule} from './helpers/js';
|
|
21
|
+
import {sourceMapObject} from './sourceMapObject';
|
|
22
|
+
import nullthrows from 'nullthrows';
|
|
23
|
+
import path from 'path';
|
|
29
24
|
|
|
30
25
|
type Options = $ReadOnly<{
|
|
31
26
|
...SerializerOptions,
|
|
@@ -41,7 +36,7 @@ export type RamBundleInfo = {
|
|
|
41
36
|
groups: Map<number, Set<number>>,
|
|
42
37
|
};
|
|
43
38
|
|
|
44
|
-
async function getRamBundleInfo(
|
|
39
|
+
export default async function getRamBundleInfo(
|
|
45
40
|
entryPoint: string,
|
|
46
41
|
pre: $ReadOnlyArray<Module<>>,
|
|
47
42
|
graph: ReadOnlyGraph<>,
|
|
@@ -162,7 +157,7 @@ async function _getRamOptions(
|
|
|
162
157
|
const {preloadedModules, ramGroups} = await getTransformOptions(
|
|
163
158
|
[entryFile],
|
|
164
159
|
{dev: options.dev, hot: true, platform: options.platform},
|
|
165
|
-
/* $FlowFixMe(>=0.99.0 site=react_native_fb) This comment suppresses an
|
|
160
|
+
/* $FlowFixMe[incompatible-type](>=0.99.0 site=react_native_fb) This comment suppresses an
|
|
166
161
|
* error found when Flow v0.99 was deployed. To see the error, delete this
|
|
167
162
|
* comment and run Flow. */
|
|
168
163
|
async (x: string) => Array.from(getDependencies),
|
|
@@ -174,5 +169,3 @@ async function _getRamOptions(
|
|
|
174
169
|
ramGroups: ramGroups || [],
|
|
175
170
|
};
|
|
176
171
|
}
|
|
177
|
-
|
|
178
|
-
module.exports = getRamBundleInfo;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = getInlineSourceMappingURL;
|
|
3
7
|
function getInlineSourceMappingURL(sourceMap) {
|
|
4
8
|
const base64 = Buffer.from(sourceMap).toString("base64");
|
|
5
9
|
return `data:application/json;charset=utf-8;base64,${base64}`;
|
|
6
10
|
}
|
|
7
|
-
module.exports = getInlineSourceMappingURL;
|
|
@@ -9,11 +9,7 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function getInlineSourceMappingURL(sourceMap: string): string {
|
|
12
|
+
export default function getInlineSourceMappingURL(sourceMap: string): string {
|
|
15
13
|
const base64 = Buffer.from(sourceMap).toString('base64');
|
|
16
14
|
return `data:application/json;charset=utf-8;base64,${base64}`;
|
|
17
15
|
}
|
|
18
|
-
|
|
19
|
-
module.exports = getInlineSourceMappingURL;
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = getSourceMapInfo;
|
|
7
|
+
var _js = require("./js");
|
|
4
8
|
function getSourceMapInfo(module, options) {
|
|
5
9
|
return {
|
|
6
|
-
...getJsOutput(module).data,
|
|
10
|
+
...(0, _js.getJsOutput)(module).data,
|
|
7
11
|
isIgnored: options.shouldAddToIgnoreList(module),
|
|
8
12
|
path: options?.getSourceUrl?.(module) ?? module.path,
|
|
9
13
|
source: options.excludeSource ? "" : getModuleSource(module),
|
|
10
14
|
};
|
|
11
15
|
}
|
|
12
16
|
function getModuleSource(module) {
|
|
13
|
-
if (getJsOutput(module).type === "js/module/asset") {
|
|
17
|
+
if ((0, _js.getJsOutput)(module).type === "js/module/asset") {
|
|
14
18
|
return "";
|
|
15
19
|
}
|
|
16
20
|
return module.getSource().toString();
|
|
17
21
|
}
|
|
18
|
-
module.exports = getSourceMapInfo;
|
|
@@ -9,17 +9,15 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import type {Module} from '../../types.flow';
|
|
12
|
+
import type {Module} from '../../types';
|
|
15
13
|
import type {
|
|
16
14
|
FBSourceFunctionMap,
|
|
17
15
|
MetroSourceMapSegmentTuple,
|
|
18
16
|
} from 'metro-source-map';
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
import {getJsOutput} from './js';
|
|
21
19
|
|
|
22
|
-
function getSourceMapInfo(
|
|
20
|
+
export default function getSourceMapInfo(
|
|
23
21
|
module: Module<>,
|
|
24
22
|
options: {
|
|
25
23
|
+excludeSource: boolean,
|
|
@@ -50,5 +48,3 @@ function getModuleSource(module: Module<>): string {
|
|
|
50
48
|
|
|
51
49
|
return module.getSource().toString();
|
|
52
50
|
}
|
|
53
|
-
|
|
54
|
-
module.exports = getSourceMapInfo;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = getTransitiveDependencies;
|
|
3
7
|
var _isResolvedDependency = require("../../../lib/isResolvedDependency");
|
|
4
8
|
function getTransitiveDependencies(path, graph) {
|
|
5
9
|
const dependencies = _getDeps(path, graph, new Set());
|
|
@@ -22,4 +26,3 @@ function _getDeps(path, graph, deps) {
|
|
|
22
26
|
}
|
|
23
27
|
return deps;
|
|
24
28
|
}
|
|
25
|
-
module.exports = getTransitiveDependencies;
|
|
@@ -9,13 +9,11 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import type {ReadOnlyGraph} from '../../types.flow';
|
|
12
|
+
import type {ReadOnlyGraph} from '../../types';
|
|
15
13
|
|
|
16
14
|
import {isResolvedDependency} from '../../../lib/isResolvedDependency';
|
|
17
15
|
|
|
18
|
-
function getTransitiveDependencies<T>(
|
|
16
|
+
export default function getTransitiveDependencies<T>(
|
|
19
17
|
path: string,
|
|
20
18
|
graph: ReadOnlyGraph<T>,
|
|
21
19
|
): Set<string> {
|
|
@@ -53,5 +51,3 @@ function _getDeps<T>(
|
|
|
53
51
|
|
|
54
52
|
return deps;
|
|
55
53
|
}
|
|
56
|
-
|
|
57
|
-
module.exports = getTransitiveDependencies;
|
|
@@ -1,17 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.getJsOutput = getJsOutput;
|
|
7
|
+
exports.getModuleParams = getModuleParams;
|
|
8
|
+
exports.isJsModule = isJsModule;
|
|
9
|
+
exports.wrapModule = wrapModule;
|
|
10
|
+
var _isResolvedDependency = require("../../../lib/isResolvedDependency");
|
|
11
|
+
var _pathUtils = require("../../../lib/pathUtils");
|
|
12
|
+
var _invariant = _interopRequireDefault(require("invariant"));
|
|
13
|
+
var jscSafeUrl = _interopRequireWildcard(require("jsc-safe-url"));
|
|
14
|
+
var _metroTransformPlugins = require("metro-transform-plugins");
|
|
15
|
+
var _path = _interopRequireDefault(require("path"));
|
|
16
|
+
function _getRequireWildcardCache(e) {
|
|
17
|
+
if ("function" != typeof WeakMap) return null;
|
|
18
|
+
var r = new WeakMap(),
|
|
19
|
+
t = new WeakMap();
|
|
20
|
+
return (_getRequireWildcardCache = function (e) {
|
|
21
|
+
return e ? t : r;
|
|
22
|
+
})(e);
|
|
23
|
+
}
|
|
24
|
+
function _interopRequireWildcard(e, r) {
|
|
25
|
+
if (!r && e && e.__esModule) return e;
|
|
26
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
27
|
+
return { default: e };
|
|
28
|
+
var t = _getRequireWildcardCache(r);
|
|
29
|
+
if (t && t.has(e)) return t.get(e);
|
|
30
|
+
var n = { __proto__: null },
|
|
31
|
+
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
32
|
+
for (var u in e)
|
|
33
|
+
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
34
|
+
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
35
|
+
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
36
|
+
}
|
|
37
|
+
return ((n.default = e), t && t.set(e, n), n);
|
|
38
|
+
}
|
|
39
|
+
function _interopRequireDefault(e) {
|
|
40
|
+
return e && e.__esModule ? e : { default: e };
|
|
41
|
+
}
|
|
8
42
|
function wrapModule(module, options) {
|
|
9
43
|
const output = getJsOutput(module);
|
|
10
44
|
if (output.type.startsWith("js/script")) {
|
|
11
45
|
return output.data.code;
|
|
12
46
|
}
|
|
13
47
|
const params = getModuleParams(module, options);
|
|
14
|
-
return
|
|
48
|
+
return (0, _metroTransformPlugins.addParamsToDefineCall)(
|
|
49
|
+
output.data.code,
|
|
50
|
+
...params,
|
|
51
|
+
);
|
|
15
52
|
}
|
|
16
53
|
function getModuleParams(module, options) {
|
|
17
54
|
const moduleId = options.createModuleId(module.path);
|
|
@@ -19,36 +56,39 @@ function getModuleParams(module, options) {
|
|
|
19
56
|
let hasPaths = false;
|
|
20
57
|
const dependencyMapArray = Array.from(module.dependencies.values()).map(
|
|
21
58
|
(dependency) => {
|
|
22
|
-
if (!isResolvedDependency(dependency)) {
|
|
59
|
+
if (!(0, _isResolvedDependency.isResolvedDependency)(dependency)) {
|
|
23
60
|
return null;
|
|
24
61
|
}
|
|
25
62
|
const id = options.createModuleId(dependency.absolutePath);
|
|
26
63
|
if (options.includeAsyncPaths && dependency.data.data.asyncType != null) {
|
|
27
64
|
hasPaths = true;
|
|
28
|
-
|
|
65
|
+
(0, _invariant.default)(
|
|
29
66
|
options.sourceUrl != null,
|
|
30
|
-
"sourceUrl is required when includeAsyncPaths is true"
|
|
67
|
+
"sourceUrl is required when includeAsyncPaths is true",
|
|
31
68
|
);
|
|
32
69
|
const { searchParams } = new URL(
|
|
33
|
-
jscSafeUrl.toNormalUrl(options.sourceUrl)
|
|
70
|
+
jscSafeUrl.toNormalUrl(options.sourceUrl),
|
|
34
71
|
);
|
|
35
72
|
searchParams.set("modulesOnly", "true");
|
|
36
73
|
searchParams.set("runModule", "false");
|
|
37
|
-
const bundlePath =
|
|
74
|
+
const bundlePath = _path.default.relative(
|
|
38
75
|
options.serverRoot,
|
|
39
|
-
dependency.absolutePath
|
|
76
|
+
dependency.absolutePath,
|
|
40
77
|
);
|
|
41
78
|
paths[id] =
|
|
42
79
|
"/" +
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
80
|
+
_path.default.join(
|
|
81
|
+
_path.default.dirname(bundlePath),
|
|
82
|
+
_path.default.basename(
|
|
83
|
+
bundlePath,
|
|
84
|
+
_path.default.extname(bundlePath),
|
|
85
|
+
),
|
|
46
86
|
) +
|
|
47
87
|
".bundle?" +
|
|
48
88
|
searchParams.toString();
|
|
49
89
|
}
|
|
50
90
|
return id;
|
|
51
|
-
}
|
|
91
|
+
},
|
|
52
92
|
);
|
|
53
93
|
const params = [
|
|
54
94
|
moduleId,
|
|
@@ -60,24 +100,24 @@ function getModuleParams(module, options) {
|
|
|
60
100
|
: dependencyMapArray,
|
|
61
101
|
];
|
|
62
102
|
if (options.dev) {
|
|
63
|
-
params.push(
|
|
103
|
+
params.push(
|
|
104
|
+
(0, _pathUtils.normalizePathSeparatorsToPosix)(
|
|
105
|
+
_path.default.relative(options.projectRoot, module.path),
|
|
106
|
+
),
|
|
107
|
+
);
|
|
64
108
|
}
|
|
65
109
|
return params;
|
|
66
110
|
}
|
|
67
111
|
function getJsOutput(module) {
|
|
68
112
|
const jsModules = module.output.filter(({ type }) => type.startsWith("js/"));
|
|
69
|
-
|
|
113
|
+
(0, _invariant.default)(
|
|
70
114
|
jsModules.length === 1,
|
|
71
|
-
`Modules must have exactly one JS output, but ${
|
|
72
|
-
module.path ?? "unknown module"
|
|
73
|
-
} has ${jsModules.length} JS outputs.`
|
|
115
|
+
`Modules must have exactly one JS output, but ${module.path ?? "unknown module"} has ${jsModules.length} JS outputs.`,
|
|
74
116
|
);
|
|
75
117
|
const jsOutput = jsModules[0];
|
|
76
|
-
|
|
118
|
+
(0, _invariant.default)(
|
|
77
119
|
Number.isFinite(jsOutput.data.lineCount),
|
|
78
|
-
`JS output must populate lineCount, but ${
|
|
79
|
-
module.path ?? "unknown module"
|
|
80
|
-
} has ${jsOutput.type} output with lineCount '${jsOutput.data.lineCount}'`
|
|
120
|
+
`JS output must populate lineCount, but ${module.path ?? "unknown module"} has ${jsOutput.type} output with lineCount '${jsOutput.data.lineCount}'`,
|
|
81
121
|
);
|
|
82
122
|
return jsOutput;
|
|
83
123
|
}
|
|
@@ -87,9 +127,3 @@ function isJsModule(module) {
|
|
|
87
127
|
function isJsOutput(output) {
|
|
88
128
|
return output.type.startsWith("js/");
|
|
89
129
|
}
|
|
90
|
-
module.exports = {
|
|
91
|
-
getJsOutput,
|
|
92
|
-
getModuleParams,
|
|
93
|
-
isJsModule,
|
|
94
|
-
wrapModule,
|
|
95
|
-
};
|
|
@@ -9,16 +9,15 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import type {MixedOutput, Module} from '../../types.flow';
|
|
12
|
+
import type {MixedOutput, Module} from '../../types';
|
|
15
13
|
import type {JsOutput} from 'metro-transform-worker';
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
import {isResolvedDependency} from '../../../lib/isResolvedDependency';
|
|
16
|
+
import {normalizePathSeparatorsToPosix} from '../../../lib/pathUtils';
|
|
17
|
+
import invariant from 'invariant';
|
|
18
|
+
import * as jscSafeUrl from 'jsc-safe-url';
|
|
19
|
+
import {addParamsToDefineCall} from 'metro-transform-plugins';
|
|
20
|
+
import path from 'path';
|
|
22
21
|
|
|
23
22
|
export type Options = $ReadOnly<{
|
|
24
23
|
createModuleId: string => number | string,
|
|
@@ -30,7 +29,7 @@ export type Options = $ReadOnly<{
|
|
|
30
29
|
...
|
|
31
30
|
}>;
|
|
32
31
|
|
|
33
|
-
function wrapModule(module: Module<>, options: Options): string {
|
|
32
|
+
export function wrapModule(module: Module<>, options: Options): string {
|
|
34
33
|
const output = getJsOutput(module);
|
|
35
34
|
|
|
36
35
|
if (output.type.startsWith('js/script')) {
|
|
@@ -41,7 +40,10 @@ function wrapModule(module: Module<>, options: Options): string {
|
|
|
41
40
|
return addParamsToDefineCall(output.data.code, ...params);
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
function getModuleParams(
|
|
43
|
+
export function getModuleParams(
|
|
44
|
+
module: Module<>,
|
|
45
|
+
options: Options,
|
|
46
|
+
): Array<mixed> {
|
|
45
47
|
const moduleId = options.createModuleId(module.path);
|
|
46
48
|
|
|
47
49
|
const paths: {[moduleID: number | string]: mixed} = {};
|
|
@@ -79,6 +81,7 @@ function getModuleParams(module: Module<>, options: Options): Array<mixed> {
|
|
|
79
81
|
paths[id] =
|
|
80
82
|
'/' +
|
|
81
83
|
path.join(
|
|
84
|
+
// TODO: This is not the proper Metro URL encoding of a file path
|
|
82
85
|
path.dirname(bundlePath),
|
|
83
86
|
// Strip the file extension
|
|
84
87
|
path.basename(bundlePath, path.extname(bundlePath)),
|
|
@@ -94,7 +97,7 @@ function getModuleParams(module: Module<>, options: Options): Array<mixed> {
|
|
|
94
97
|
moduleId,
|
|
95
98
|
hasPaths
|
|
96
99
|
? {
|
|
97
|
-
// $
|
|
100
|
+
// $FlowFixMe[not-an-object] Intentionally spreading an array into an object
|
|
98
101
|
...dependencyMapArray,
|
|
99
102
|
paths,
|
|
100
103
|
}
|
|
@@ -104,13 +107,17 @@ function getModuleParams(module: Module<>, options: Options): Array<mixed> {
|
|
|
104
107
|
if (options.dev) {
|
|
105
108
|
// Add the relative path of the module to make debugging easier.
|
|
106
109
|
// This is mapped to `module.verboseName` in `require.js`.
|
|
107
|
-
params.push(
|
|
110
|
+
params.push(
|
|
111
|
+
normalizePathSeparatorsToPosix(
|
|
112
|
+
path.relative(options.projectRoot, module.path),
|
|
113
|
+
),
|
|
114
|
+
);
|
|
108
115
|
}
|
|
109
116
|
|
|
110
117
|
return params;
|
|
111
118
|
}
|
|
112
119
|
|
|
113
|
-
function getJsOutput(
|
|
120
|
+
export function getJsOutput(
|
|
114
121
|
module: $ReadOnly<{
|
|
115
122
|
output: $ReadOnlyArray<MixedOutput>,
|
|
116
123
|
path?: string,
|
|
@@ -138,17 +145,10 @@ function getJsOutput(
|
|
|
138
145
|
return jsOutput;
|
|
139
146
|
}
|
|
140
147
|
|
|
141
|
-
function isJsModule(module: Module<>): boolean {
|
|
148
|
+
export function isJsModule(module: Module<>): boolean {
|
|
142
149
|
return module.output.filter(isJsOutput).length > 0;
|
|
143
150
|
}
|
|
144
151
|
|
|
145
152
|
function isJsOutput(output: MixedOutput): boolean {
|
|
146
153
|
return output.type.startsWith('js/');
|
|
147
154
|
}
|
|
148
|
-
|
|
149
|
-
module.exports = {
|
|
150
|
-
getJsOutput,
|
|
151
|
-
getModuleParams,
|
|
152
|
-
isJsModule,
|
|
153
|
-
wrapModule,
|
|
154
|
-
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = processModules;
|
|
7
|
+
var _js = require("./js");
|
|
4
8
|
function processModules(
|
|
5
9
|
modules,
|
|
6
10
|
{
|
|
@@ -11,14 +15,14 @@ function processModules(
|
|
|
11
15
|
projectRoot,
|
|
12
16
|
serverRoot,
|
|
13
17
|
sourceUrl,
|
|
14
|
-
}
|
|
18
|
+
},
|
|
15
19
|
) {
|
|
16
20
|
return [...modules]
|
|
17
|
-
.filter(isJsModule)
|
|
21
|
+
.filter(_js.isJsModule)
|
|
18
22
|
.filter(filter)
|
|
19
23
|
.map((module) => [
|
|
20
24
|
module,
|
|
21
|
-
wrapModule(module, {
|
|
25
|
+
(0, _js.wrapModule)(module, {
|
|
22
26
|
createModuleId,
|
|
23
27
|
dev,
|
|
24
28
|
includeAsyncPaths,
|
|
@@ -28,4 +32,3 @@ function processModules(
|
|
|
28
32
|
}),
|
|
29
33
|
]);
|
|
30
34
|
}
|
|
31
|
-
module.exports = processModules;
|
|
@@ -9,13 +9,11 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
import type {Module} from '../../types';
|
|
13
13
|
|
|
14
|
-
import
|
|
14
|
+
import {isJsModule, wrapModule} from './js';
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function processModules(
|
|
16
|
+
export default function processModules(
|
|
19
17
|
modules: $ReadOnlyArray<Module<>>,
|
|
20
18
|
{
|
|
21
19
|
filter = () => true,
|
|
@@ -50,5 +48,3 @@ function processModules(
|
|
|
50
48
|
}),
|
|
51
49
|
]);
|
|
52
50
|
}
|
|
53
|
-
|
|
54
|
-
module.exports = processModules;
|