metro 0.83.1 → 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 +15 -15
- 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 +14 -10
- package/src/DeltaBundler/DeltaCalculator.js.flow +4 -7
- package/src/DeltaBundler/Graph.js +44 -35
- 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 +31 -22
- 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 +12 -12
- 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.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 +19 -18
- 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 +17 -10
- 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/import-export/index.js +2 -2
- 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 +2 -2
- package/src/lib/contextModuleTemplates.js +7 -13
- package/src/lib/countLines.js +5 -1
- package/src/lib/countLines.js.flow +1 -3
- package/src/lib/createWebsocketServer.js +6 -2
- 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 +19 -15
- 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 +39 -11
- 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 +18 -20
- 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 +13 -7
- 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 +20 -13
- 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 -20
- package/src/node-haste/Module.js.flow +0 -41
- /package/src/DeltaBundler/{types.flow.js → types.js} +0 -0
- /package/src/shared/{types.flow.js → types.js} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro",
|
|
3
|
-
"version": "0.83.
|
|
3
|
+
"version": "0.83.2",
|
|
4
4
|
"description": "🚇 The JavaScript bundler for React Native.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": "src/cli.js",
|
|
@@ -33,24 +33,24 @@
|
|
|
33
33
|
"error-stack-parser": "^2.0.6",
|
|
34
34
|
"flow-enums-runtime": "^0.0.6",
|
|
35
35
|
"graceful-fs": "^4.2.4",
|
|
36
|
-
"hermes-parser": "0.
|
|
36
|
+
"hermes-parser": "0.32.0",
|
|
37
37
|
"image-size": "^1.0.2",
|
|
38
38
|
"invariant": "^2.2.4",
|
|
39
39
|
"jest-worker": "^29.7.0",
|
|
40
40
|
"jsc-safe-url": "^0.2.2",
|
|
41
41
|
"lodash.throttle": "^4.1.1",
|
|
42
|
-
"metro-babel-transformer": "0.83.
|
|
43
|
-
"metro-cache": "0.83.
|
|
44
|
-
"metro-cache-key": "0.83.
|
|
45
|
-
"metro-config": "0.83.
|
|
46
|
-
"metro-core": "0.83.
|
|
47
|
-
"metro-file-map": "0.83.
|
|
48
|
-
"metro-resolver": "0.83.
|
|
49
|
-
"metro-runtime": "0.83.
|
|
50
|
-
"metro-source-map": "0.83.
|
|
51
|
-
"metro-symbolicate": "0.83.
|
|
52
|
-
"metro-transform-plugins": "0.83.
|
|
53
|
-
"metro-transform-worker": "0.83.
|
|
42
|
+
"metro-babel-transformer": "0.83.2",
|
|
43
|
+
"metro-cache": "0.83.2",
|
|
44
|
+
"metro-cache-key": "0.83.2",
|
|
45
|
+
"metro-config": "0.83.2",
|
|
46
|
+
"metro-core": "0.83.2",
|
|
47
|
+
"metro-file-map": "0.83.2",
|
|
48
|
+
"metro-resolver": "0.83.2",
|
|
49
|
+
"metro-runtime": "0.83.2",
|
|
50
|
+
"metro-source-map": "0.83.2",
|
|
51
|
+
"metro-symbolicate": "0.83.2",
|
|
52
|
+
"metro-transform-plugins": "0.83.2",
|
|
53
|
+
"metro-transform-worker": "0.83.2",
|
|
54
54
|
"mime-types": "^2.1.27",
|
|
55
55
|
"nullthrows": "^1.1.1",
|
|
56
56
|
"serialize-error": "^2.1.0",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"dedent": "^0.7.0",
|
|
70
70
|
"jest-snapshot": "^29.7.0",
|
|
71
71
|
"jest-snapshot-serializer-raw": "^1.2.0",
|
|
72
|
-
"metro-babel-register": "0.83.
|
|
72
|
+
"metro-babel-register": "0.83.2",
|
|
73
73
|
"metro-memory-fs": "*",
|
|
74
74
|
"mock-req": "^0.2.0",
|
|
75
75
|
"mock-res": "^0.6.0",
|
package/src/Assets.js
CHANGED
|
@@ -1,10 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.getAsset = getAsset;
|
|
7
|
+
exports.getAssetData = getAssetData;
|
|
8
|
+
exports.getAssetFiles = getAssetFiles;
|
|
9
|
+
exports.getAssetSize = getAssetSize;
|
|
10
|
+
exports.isAssetTypeAnImage = isAssetTypeAnImage;
|
|
11
|
+
var _pathUtils = require("./lib/pathUtils");
|
|
12
|
+
var AssetPaths = _interopRequireWildcard(
|
|
13
|
+
require("./node-haste/lib/AssetPaths"),
|
|
14
|
+
);
|
|
15
|
+
var _crypto = _interopRequireDefault(require("crypto"));
|
|
16
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
17
|
+
var _imageSize = _interopRequireDefault(require("image-size"));
|
|
18
|
+
var _path = _interopRequireDefault(require("path"));
|
|
19
|
+
function _interopRequireDefault(e) {
|
|
20
|
+
return e && e.__esModule ? e : { default: e };
|
|
21
|
+
}
|
|
22
|
+
function _getRequireWildcardCache(e) {
|
|
23
|
+
if ("function" != typeof WeakMap) return null;
|
|
24
|
+
var r = new WeakMap(),
|
|
25
|
+
t = new WeakMap();
|
|
26
|
+
return (_getRequireWildcardCache = function (e) {
|
|
27
|
+
return e ? t : r;
|
|
28
|
+
})(e);
|
|
29
|
+
}
|
|
30
|
+
function _interopRequireWildcard(e, r) {
|
|
31
|
+
if (!r && e && e.__esModule) return e;
|
|
32
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
33
|
+
return { default: e };
|
|
34
|
+
var t = _getRequireWildcardCache(r);
|
|
35
|
+
if (t && t.has(e)) return t.get(e);
|
|
36
|
+
var n = { __proto__: null },
|
|
37
|
+
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
38
|
+
for (var u in e)
|
|
39
|
+
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
40
|
+
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
41
|
+
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
42
|
+
}
|
|
43
|
+
return ((n.default = e), t && t.set(e, n), n);
|
|
44
|
+
}
|
|
8
45
|
function isAssetTypeAnImage(type) {
|
|
9
46
|
return (
|
|
10
47
|
[
|
|
@@ -28,7 +65,7 @@ function getAssetSize(type, content, filePath) {
|
|
|
28
65
|
if (content.length === 0) {
|
|
29
66
|
throw new Error(`Image asset \`${filePath}\` cannot be an empty file.`);
|
|
30
67
|
}
|
|
31
|
-
const { width, height } =
|
|
68
|
+
const { width, height } = (0, _imageSize.default)(content);
|
|
32
69
|
return {
|
|
33
70
|
width,
|
|
34
71
|
height,
|
|
@@ -60,7 +97,7 @@ function buildAssetMap(dir, files, platform) {
|
|
|
60
97
|
}
|
|
61
98
|
}
|
|
62
99
|
record.scales.splice(insertIndex, 0, asset.resolution);
|
|
63
|
-
record.files.splice(insertIndex, 0,
|
|
100
|
+
record.files.splice(insertIndex, 0, _path.default.join(dir, file));
|
|
64
101
|
});
|
|
65
102
|
return map;
|
|
66
103
|
}
|
|
@@ -72,12 +109,12 @@ function getAssetKey(assetName, platform) {
|
|
|
72
109
|
}
|
|
73
110
|
}
|
|
74
111
|
async function getAbsoluteAssetRecord(assetPath, platform = null) {
|
|
75
|
-
const filename =
|
|
76
|
-
const dir =
|
|
77
|
-
const files = await
|
|
112
|
+
const filename = _path.default.basename(assetPath);
|
|
113
|
+
const dir = _path.default.dirname(assetPath);
|
|
114
|
+
const files = await _fs.default.promises.readdir(dir);
|
|
78
115
|
const assetData = AssetPaths.parse(
|
|
79
116
|
filename,
|
|
80
|
-
new Set(platform != null ? [platform] : [])
|
|
117
|
+
new Set(platform != null ? [platform] : []),
|
|
81
118
|
);
|
|
82
119
|
const map = buildAssetMap(dir, files, platform);
|
|
83
120
|
let record;
|
|
@@ -90,9 +127,7 @@ async function getAbsoluteAssetRecord(assetPath, platform = null) {
|
|
|
90
127
|
}
|
|
91
128
|
if (!record) {
|
|
92
129
|
throw new Error(
|
|
93
|
-
`Asset not found: ${assetPath} for platform: ${
|
|
94
|
-
platform ?? "(unspecified)"
|
|
95
|
-
}`
|
|
130
|
+
`Asset not found: ${assetPath} for platform: ${platform ?? "(unspecified)"}`,
|
|
96
131
|
);
|
|
97
132
|
}
|
|
98
133
|
return record;
|
|
@@ -100,13 +135,13 @@ async function getAbsoluteAssetRecord(assetPath, platform = null) {
|
|
|
100
135
|
async function getAbsoluteAssetInfo(assetPath, platform = null) {
|
|
101
136
|
const nameData = AssetPaths.parse(
|
|
102
137
|
assetPath,
|
|
103
|
-
new Set(platform != null ? [platform] : [])
|
|
138
|
+
new Set(platform != null ? [platform] : []),
|
|
104
139
|
);
|
|
105
140
|
const { name, type } = nameData;
|
|
106
141
|
const { scales, files } = await getAbsoluteAssetRecord(assetPath, platform);
|
|
107
|
-
const hasher =
|
|
142
|
+
const hasher = _crypto.default.createHash("md5");
|
|
108
143
|
const fileData = await Promise.all(
|
|
109
|
-
files.map((file) =>
|
|
144
|
+
files.map((file) => _fs.default.promises.readFile(file)),
|
|
110
145
|
);
|
|
111
146
|
for (const data of fileData) {
|
|
112
147
|
hasher.update(data);
|
|
@@ -124,24 +159,22 @@ async function getAssetData(
|
|
|
124
159
|
localPath,
|
|
125
160
|
assetDataPlugins,
|
|
126
161
|
platform = null,
|
|
127
|
-
publicPath
|
|
162
|
+
publicPath,
|
|
128
163
|
) {
|
|
129
164
|
let assetUrlPath = localPath.startsWith("..")
|
|
130
|
-
? publicPath.replace(/\/$/, "") + "/" +
|
|
131
|
-
:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
const isImage = isAssetTypeAnImage(path.extname(assetPath).slice(1));
|
|
165
|
+
? publicPath.replace(/\/$/, "") + "/" + _path.default.dirname(localPath)
|
|
166
|
+
: _path.default.join(publicPath, _path.default.dirname(localPath));
|
|
167
|
+
assetUrlPath = (0, _pathUtils.normalizePathSeparatorsToPosix)(assetUrlPath);
|
|
168
|
+
const isImage = isAssetTypeAnImage(_path.default.extname(assetPath).slice(1));
|
|
136
169
|
const assetInfo = await getAbsoluteAssetInfo(assetPath, platform);
|
|
137
170
|
const isImageInput = assetInfo.files[0].includes(".zip/")
|
|
138
|
-
?
|
|
171
|
+
? _fs.default.readFileSync(assetInfo.files[0])
|
|
139
172
|
: assetInfo.files[0];
|
|
140
|
-
const dimensions = isImage ?
|
|
173
|
+
const dimensions = isImage ? (0, _imageSize.default)(isImageInput) : null;
|
|
141
174
|
const scale = assetInfo.scales[0];
|
|
142
175
|
const assetData = {
|
|
143
176
|
__packager_asset: true,
|
|
144
|
-
fileSystemLocation:
|
|
177
|
+
fileSystemLocation: _path.default.dirname(assetPath),
|
|
145
178
|
httpServerLocation: assetUrlPath,
|
|
146
179
|
width: dimensions ? dimensions.width / scale : undefined,
|
|
147
180
|
height: dimensions ? dimensions.height / scale : undefined,
|
|
@@ -171,43 +204,36 @@ async function getAsset(
|
|
|
171
204
|
projectRoot,
|
|
172
205
|
watchFolders,
|
|
173
206
|
platform = null,
|
|
174
|
-
assetExts
|
|
207
|
+
assetExts,
|
|
175
208
|
) {
|
|
176
209
|
const assetData = AssetPaths.parse(
|
|
177
210
|
relativePath,
|
|
178
|
-
new Set(platform != null ? [platform] : [])
|
|
211
|
+
new Set(platform != null ? [platform] : []),
|
|
179
212
|
);
|
|
180
|
-
const absolutePath =
|
|
213
|
+
const absolutePath = _path.default.resolve(projectRoot, relativePath);
|
|
181
214
|
if (!assetExts.includes(assetData.type)) {
|
|
182
215
|
throw new Error(
|
|
183
|
-
`'${relativePath}' cannot be loaded as its extension is not registered in assetExts
|
|
216
|
+
`'${relativePath}' cannot be loaded as its extension is not registered in assetExts`,
|
|
184
217
|
);
|
|
185
218
|
}
|
|
186
219
|
if (!pathBelongsToRoots(absolutePath, [projectRoot, ...watchFolders])) {
|
|
187
220
|
throw new Error(
|
|
188
|
-
`'${relativePath}' could not be found, because it cannot be found in the project root or any watch folder
|
|
221
|
+
`'${relativePath}' could not be found, because it cannot be found in the project root or any watch folder`,
|
|
189
222
|
);
|
|
190
223
|
}
|
|
191
224
|
const record = await getAbsoluteAssetRecord(absolutePath, platform);
|
|
192
225
|
for (let i = 0; i < record.scales.length; i++) {
|
|
193
226
|
if (record.scales[i] >= assetData.resolution) {
|
|
194
|
-
return
|
|
227
|
+
return _fs.default.promises.readFile(record.files[i]);
|
|
195
228
|
}
|
|
196
229
|
}
|
|
197
|
-
return
|
|
230
|
+
return _fs.default.promises.readFile(record.files[record.files.length - 1]);
|
|
198
231
|
}
|
|
199
232
|
function pathBelongsToRoots(pathToCheck, roots) {
|
|
200
233
|
for (const rootFolder of roots) {
|
|
201
|
-
if (pathToCheck.startsWith(
|
|
234
|
+
if (pathToCheck.startsWith(_path.default.resolve(rootFolder))) {
|
|
202
235
|
return true;
|
|
203
236
|
}
|
|
204
237
|
}
|
|
205
238
|
return false;
|
|
206
239
|
}
|
|
207
|
-
module.exports = {
|
|
208
|
-
getAsset,
|
|
209
|
-
getAssetSize,
|
|
210
|
-
getAssetData,
|
|
211
|
-
getAssetFiles,
|
|
212
|
-
isAssetTypeAnImage,
|
|
213
|
-
};
|
package/src/Assets.js.flow
CHANGED
|
@@ -9,15 +9,14 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
import type {AssetPath} from './node-haste/lib/AssetPaths';
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
import {normalizePathSeparatorsToPosix} from './lib/pathUtils';
|
|
15
|
+
import * as AssetPaths from './node-haste/lib/AssetPaths';
|
|
16
|
+
import crypto from 'crypto';
|
|
17
|
+
import fs from 'fs';
|
|
18
|
+
import getImageSize from 'image-size';
|
|
19
|
+
import path from 'path';
|
|
21
20
|
|
|
22
21
|
export type AssetInfo = {
|
|
23
22
|
+files: Array<string>,
|
|
@@ -53,7 +52,7 @@ export type AssetDataFiltered = {
|
|
|
53
52
|
|
|
54
53
|
// Test extension against all types supported by image-size module.
|
|
55
54
|
// If it's not one of these, we won't treat it as an image.
|
|
56
|
-
function isAssetTypeAnImage(type: string): boolean {
|
|
55
|
+
export function isAssetTypeAnImage(type: string): boolean {
|
|
57
56
|
return (
|
|
58
57
|
[
|
|
59
58
|
'png',
|
|
@@ -70,7 +69,7 @@ function isAssetTypeAnImage(type: string): boolean {
|
|
|
70
69
|
);
|
|
71
70
|
}
|
|
72
71
|
|
|
73
|
-
function getAssetSize(
|
|
72
|
+
export function getAssetSize(
|
|
74
73
|
type: string,
|
|
75
74
|
content: Buffer,
|
|
76
75
|
filePath: string,
|
|
@@ -198,7 +197,7 @@ async function getAbsoluteAssetInfo(
|
|
|
198
197
|
return {files, hash: hasher.digest('hex'), name, scales, type};
|
|
199
198
|
}
|
|
200
199
|
|
|
201
|
-
async function getAssetData(
|
|
200
|
+
export async function getAssetData(
|
|
202
201
|
assetPath: string,
|
|
203
202
|
localPath: string,
|
|
204
203
|
assetDataPlugins: $ReadOnlyArray<string>,
|
|
@@ -213,9 +212,7 @@ async function getAssetData(
|
|
|
213
212
|
: path.join(publicPath, path.dirname(localPath));
|
|
214
213
|
|
|
215
214
|
// On Windows, change backslashes to slashes to get proper URL path from file path.
|
|
216
|
-
|
|
217
|
-
assetUrlPath = assetUrlPath.replaceAll('\\', '/');
|
|
218
|
-
}
|
|
215
|
+
assetUrlPath = normalizePathSeparatorsToPosix(assetUrlPath);
|
|
219
216
|
|
|
220
217
|
const isImage = isAssetTypeAnImage(path.extname(assetPath).slice(1));
|
|
221
218
|
const assetInfo = await getAbsoluteAssetInfo(assetPath, platform);
|
|
@@ -250,7 +247,7 @@ async function applyAssetDataPlugins(
|
|
|
250
247
|
}
|
|
251
248
|
|
|
252
249
|
const [currentAssetPlugin, ...remainingAssetPlugins] = assetDataPlugins;
|
|
253
|
-
// $FlowFixMe: impossible to type a dynamic require.
|
|
250
|
+
// $FlowFixMe[unsupported-syntax]: impossible to type a dynamic require.
|
|
254
251
|
const assetPluginFunction: AssetDataPlugin = require(currentAssetPlugin);
|
|
255
252
|
const resultAssetData = await assetPluginFunction(assetData);
|
|
256
253
|
return await applyAssetDataPlugins(remainingAssetPlugins, resultAssetData);
|
|
@@ -259,7 +256,7 @@ async function applyAssetDataPlugins(
|
|
|
259
256
|
/**
|
|
260
257
|
* Returns all the associated files (for different resolutions) of an asset.
|
|
261
258
|
**/
|
|
262
|
-
async function getAssetFiles(
|
|
259
|
+
export async function getAssetFiles(
|
|
263
260
|
assetPath: string,
|
|
264
261
|
platform: ?string = null,
|
|
265
262
|
): Promise<Array<string>> {
|
|
@@ -279,7 +276,7 @@ async function getAssetFiles(
|
|
|
279
276
|
* 3. Then try to pick platform-specific asset records
|
|
280
277
|
* 4. Then pick the closest resolution (rounding up) to the requested one
|
|
281
278
|
*/
|
|
282
|
-
async function getAsset(
|
|
279
|
+
export async function getAsset(
|
|
283
280
|
relativePath: string,
|
|
284
281
|
projectRoot: string,
|
|
285
282
|
watchFolders: $ReadOnlyArray<string>,
|
|
@@ -328,11 +325,3 @@ function pathBelongsToRoots(
|
|
|
328
325
|
|
|
329
326
|
return false;
|
|
330
327
|
}
|
|
331
|
-
|
|
332
|
-
module.exports = {
|
|
333
|
-
getAsset,
|
|
334
|
-
getAssetSize,
|
|
335
|
-
getAssetData,
|
|
336
|
-
getAssetFiles,
|
|
337
|
-
isAssetTypeAnImage,
|
|
338
|
-
};
|
package/src/Bundler/util.js
CHANGED
|
@@ -1,19 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.createRamBundleGroups = createRamBundleGroups;
|
|
7
|
+
exports.generateAssetCodeFileAst = generateAssetCodeFileAst;
|
|
8
|
+
var babylon = _interopRequireWildcard(require("@babel/parser"));
|
|
9
|
+
var _template = _interopRequireDefault(require("@babel/template"));
|
|
10
|
+
var babelTypes = _interopRequireWildcard(require("@babel/types"));
|
|
11
|
+
function _interopRequireDefault(e) {
|
|
12
|
+
return e && e.__esModule ? e : { default: e };
|
|
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
|
+
}
|
|
6
37
|
const assetPropertyBlockList = new Set(["files", "fileSystemLocation", "path"]);
|
|
7
38
|
function generateAssetCodeFileAst(assetRegistryPath, assetDescriptor) {
|
|
8
39
|
const properDescriptor = filterObject(
|
|
9
40
|
assetDescriptor,
|
|
10
|
-
assetPropertyBlockList
|
|
41
|
+
assetPropertyBlockList,
|
|
11
42
|
);
|
|
12
43
|
const descriptorAst = babylon.parseExpression(
|
|
13
|
-
JSON.stringify(properDescriptor)
|
|
44
|
+
JSON.stringify(properDescriptor),
|
|
14
45
|
);
|
|
15
46
|
const t = babelTypes;
|
|
16
|
-
const buildRequire =
|
|
47
|
+
const buildRequire = _template.default.statement(`
|
|
17
48
|
module.exports = require(ASSET_REGISTRY_PATH).registerAsset(DESCRIPTOR_AST)
|
|
18
49
|
`);
|
|
19
50
|
return t.file(
|
|
@@ -22,7 +53,7 @@ function generateAssetCodeFileAst(assetRegistryPath, assetDescriptor) {
|
|
|
22
53
|
ASSET_REGISTRY_PATH: t.stringLiteral(assetRegistryPath),
|
|
23
54
|
DESCRIPTOR_AST: descriptorAst,
|
|
24
55
|
}),
|
|
25
|
-
])
|
|
56
|
+
]),
|
|
26
57
|
);
|
|
27
58
|
}
|
|
28
59
|
function filterObject(object, blockList) {
|
|
@@ -48,7 +79,7 @@ function createRamBundleGroups(ramGroups, groupableModules, subtree) {
|
|
|
48
79
|
throw Error(`Group root ${modulePath} is not part of the bundle`);
|
|
49
80
|
}
|
|
50
81
|
return [root.id, new Set(subtree(root, byPath))];
|
|
51
|
-
})
|
|
82
|
+
}),
|
|
52
83
|
);
|
|
53
84
|
if (ramGroups.length > 1) {
|
|
54
85
|
const all = new ArrayMap();
|
|
@@ -62,11 +93,7 @@ function createRamBundleGroups(ramGroups, groupableModules, subtree) {
|
|
|
62
93
|
const parentNames = parents.map(byId.get, byId);
|
|
63
94
|
const lastName = parentNames.pop();
|
|
64
95
|
throw new Error(
|
|
65
|
-
`Module ${
|
|
66
|
-
byId.get(moduleId) || moduleId
|
|
67
|
-
} belongs to groups ${parentNames.join(", ")}, and ${String(
|
|
68
|
-
lastName
|
|
69
|
-
)}. Ensure that each module is only part of one group.`
|
|
96
|
+
`Module ${byId.get(moduleId) || moduleId} belongs to groups ${parentNames.join(", ")}, and ${String(lastName)}. Ensure that each module is only part of one group.`,
|
|
70
97
|
);
|
|
71
98
|
}
|
|
72
99
|
}
|
|
@@ -89,7 +116,3 @@ class ArrayMap extends Map {
|
|
|
89
116
|
return array;
|
|
90
117
|
}
|
|
91
118
|
}
|
|
92
|
-
module.exports = {
|
|
93
|
-
createRamBundleGroups,
|
|
94
|
-
generateAssetCodeFileAst,
|
|
95
|
-
};
|
package/src/Bundler/util.js.flow
CHANGED
|
@@ -9,15 +9,13 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
import type {AssetDataFiltered, AssetDataWithoutFiles} from '../Assets';
|
|
15
|
-
import type {ModuleTransportLike} from '../shared/types
|
|
13
|
+
import type {ModuleTransportLike} from '../shared/types';
|
|
16
14
|
import type {File} from '@babel/types';
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
import * as babylon from '@babel/parser';
|
|
17
|
+
import template from '@babel/template';
|
|
18
|
+
import * as babelTypes from '@babel/types';
|
|
21
19
|
|
|
22
20
|
type SubTree<T: ModuleTransportLike> = (
|
|
23
21
|
moduleTransport: T,
|
|
@@ -26,7 +24,7 @@ type SubTree<T: ModuleTransportLike> = (
|
|
|
26
24
|
|
|
27
25
|
const assetPropertyBlockList = new Set(['files', 'fileSystemLocation', 'path']);
|
|
28
26
|
|
|
29
|
-
function generateAssetCodeFileAst(
|
|
27
|
+
export function generateAssetCodeFileAst(
|
|
30
28
|
assetRegistryPath: string,
|
|
31
29
|
assetDescriptor: AssetDataWithoutFiles,
|
|
32
30
|
): File {
|
|
@@ -68,7 +66,7 @@ function filterObject(
|
|
|
68
66
|
return copied;
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
function createRamBundleGroups<T: ModuleTransportLike>(
|
|
69
|
+
export function createRamBundleGroups<T: ModuleTransportLike>(
|
|
72
70
|
ramGroups: $ReadOnlyArray<string>,
|
|
73
71
|
groupableModules: $ReadOnlyArray<T>,
|
|
74
72
|
subtree: SubTree<T>,
|
|
@@ -146,8 +144,3 @@ class ArrayMap<K, V> extends Map<K, Array<V>> {
|
|
|
146
144
|
return array;
|
|
147
145
|
}
|
|
148
146
|
}
|
|
149
|
-
|
|
150
|
-
module.exports = {
|
|
151
|
-
createRamBundleGroups,
|
|
152
|
-
generateAssetCodeFileAst,
|
|
153
|
-
};
|
package/src/Bundler.js
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _Transformer = _interopRequireDefault(
|
|
8
|
+
require("./DeltaBundler/Transformer"),
|
|
9
|
+
);
|
|
10
|
+
var _DependencyGraph = _interopRequireDefault(
|
|
11
|
+
require("./node-haste/DependencyGraph"),
|
|
12
|
+
);
|
|
13
|
+
function _interopRequireDefault(e) {
|
|
14
|
+
return e && e.__esModule ? e : { default: e };
|
|
15
|
+
}
|
|
5
16
|
class Bundler {
|
|
6
17
|
constructor(config, options) {
|
|
7
|
-
this._depGraph = new
|
|
18
|
+
this._depGraph = new _DependencyGraph.default(config, options);
|
|
8
19
|
this._initializedPromise = this._depGraph
|
|
9
20
|
.ready()
|
|
10
21
|
.then(() => {
|
|
11
22
|
config.reporter.update({
|
|
12
23
|
type: "transformer_load_started",
|
|
13
24
|
});
|
|
14
|
-
this._transformer = new
|
|
25
|
+
this._transformer = new _Transformer.default(config, {
|
|
15
26
|
getOrComputeSha1: (filePath) =>
|
|
16
27
|
this._depGraph.getOrComputeSha1(filePath),
|
|
17
28
|
});
|
|
@@ -44,11 +55,11 @@ class Bundler {
|
|
|
44
55
|
return this._transformer.transformFile(
|
|
45
56
|
filePath,
|
|
46
57
|
transformOptions,
|
|
47
|
-
fileBuffer
|
|
58
|
+
fileBuffer,
|
|
48
59
|
);
|
|
49
60
|
}
|
|
50
61
|
async ready() {
|
|
51
62
|
await this._initializedPromise;
|
|
52
63
|
}
|
|
53
64
|
}
|
|
54
|
-
|
|
65
|
+
exports.default = Bundler;
|
package/src/Bundler.js.flow
CHANGED
|
@@ -9,22 +9,20 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
import type {TransformResultWithSource} from './DeltaBundler';
|
|
15
13
|
import type {TransformOptions} from './DeltaBundler/Worker';
|
|
16
14
|
import type EventEmitter from 'events';
|
|
17
15
|
import type {ConfigT} from 'metro-config';
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
import Transformer from './DeltaBundler/Transformer';
|
|
18
|
+
import DependencyGraph from './node-haste/DependencyGraph';
|
|
21
19
|
|
|
22
20
|
export type BundlerOptions = $ReadOnly<{
|
|
23
21
|
hasReducedPerformance?: boolean,
|
|
24
22
|
watch?: boolean,
|
|
25
23
|
}>;
|
|
26
24
|
|
|
27
|
-
class Bundler {
|
|
25
|
+
export default class Bundler {
|
|
28
26
|
_depGraph: DependencyGraph;
|
|
29
27
|
_initializedPromise: Promise<void>;
|
|
30
28
|
_transformer: Transformer;
|
|
@@ -90,5 +88,3 @@ class Bundler {
|
|
|
90
88
|
await this._initializedPromise;
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
|
-
|
|
94
|
-
module.exports = Bundler;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
3
7
|
var _Graph = require("./Graph");
|
|
8
|
+
var _events = _interopRequireDefault(require("events"));
|
|
4
9
|
var _path = _interopRequireDefault(require("path"));
|
|
5
10
|
function _interopRequireDefault(e) {
|
|
6
11
|
return e && e.__esModule ? e : { default: e };
|
|
7
12
|
}
|
|
8
13
|
const debug = require("debug")("Metro:DeltaCalculator");
|
|
9
|
-
|
|
10
|
-
class DeltaCalculator extends EventEmitter {
|
|
14
|
+
class DeltaCalculator extends _events.default {
|
|
11
15
|
_deletedFiles = new Set();
|
|
12
16
|
_modifiedFiles = new Set();
|
|
13
17
|
_addedFiles = new Set();
|
|
@@ -25,7 +29,7 @@ class DeltaCalculator extends EventEmitter {
|
|
|
25
29
|
end() {
|
|
26
30
|
this._changeEventSource.removeListener(
|
|
27
31
|
"change",
|
|
28
|
-
this._handleMultipleFileChanges
|
|
32
|
+
this._handleMultipleFileChanges,
|
|
29
33
|
);
|
|
30
34
|
this.removeAllListeners();
|
|
31
35
|
this._graph = new _Graph.Graph({
|
|
@@ -61,7 +65,7 @@ class DeltaCalculator extends EventEmitter {
|
|
|
61
65
|
this._currentBuildPromise = this._getChangedDependencies(
|
|
62
66
|
modifiedFiles,
|
|
63
67
|
deletedFiles,
|
|
64
|
-
addedFiles
|
|
68
|
+
addedFiles,
|
|
65
69
|
);
|
|
66
70
|
let result;
|
|
67
71
|
try {
|
|
@@ -149,7 +153,7 @@ class DeltaCalculator extends EventEmitter {
|
|
|
149
153
|
async _getChangedDependencies(modifiedFiles, deletedFiles, addedFiles) {
|
|
150
154
|
if (!this._graph.dependencies.size) {
|
|
151
155
|
const { added } = await this._graph.initialTraverseDependencies(
|
|
152
|
-
this._options
|
|
156
|
+
this._options,
|
|
153
157
|
);
|
|
154
158
|
return {
|
|
155
159
|
added,
|
|
@@ -160,7 +164,7 @@ class DeltaCalculator extends EventEmitter {
|
|
|
160
164
|
}
|
|
161
165
|
deletedFiles.forEach((filePath) => {
|
|
162
166
|
for (const modifiedModulePath of this._graph.getModifiedModulesForDeletedPath(
|
|
163
|
-
filePath
|
|
167
|
+
filePath,
|
|
164
168
|
)) {
|
|
165
169
|
if (!deletedFiles.has(modifiedModulePath)) {
|
|
166
170
|
modifiedFiles.add(modifiedModulePath);
|
|
@@ -173,7 +177,7 @@ class DeltaCalculator extends EventEmitter {
|
|
|
173
177
|
});
|
|
174
178
|
}
|
|
175
179
|
const modifiedDependencies = Array.from(modifiedFiles).filter((filePath) =>
|
|
176
|
-
this._graph.dependencies.has(filePath)
|
|
180
|
+
this._graph.dependencies.has(filePath),
|
|
177
181
|
);
|
|
178
182
|
if (modifiedDependencies.length === 0) {
|
|
179
183
|
return {
|
|
@@ -186,13 +190,13 @@ class DeltaCalculator extends EventEmitter {
|
|
|
186
190
|
debug("Traversing dependencies for %s paths", modifiedDependencies.length);
|
|
187
191
|
const { added, modified, deleted } = await this._graph.traverseDependencies(
|
|
188
192
|
modifiedDependencies,
|
|
189
|
-
this._options
|
|
193
|
+
this._options,
|
|
190
194
|
);
|
|
191
195
|
debug(
|
|
192
196
|
"Calculated graph delta {added: %s, modified: %d, deleted: %d}",
|
|
193
197
|
added.size,
|
|
194
198
|
modified.size,
|
|
195
|
-
deleted.size
|
|
199
|
+
deleted.size,
|
|
196
200
|
);
|
|
197
201
|
return {
|
|
198
202
|
added,
|
|
@@ -202,4 +206,4 @@ class DeltaCalculator extends EventEmitter {
|
|
|
202
206
|
};
|
|
203
207
|
}
|
|
204
208
|
}
|
|
205
|
-
|
|
209
|
+
exports.default = DeltaCalculator;
|