metro 0.83.3 → 0.83.5
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 +28 -24
- package/src/Assets.d.ts +83 -0
- package/src/Assets.js +42 -29
- package/src/Assets.js.flow +26 -15
- package/src/Bundler/util.d.ts +27 -0
- package/src/Bundler/util.js +25 -21
- package/src/Bundler/util.js.flow +2 -2
- package/src/Bundler.d.ts +14 -15
- package/src/Bundler.js.flow +1 -1
- package/src/DeltaBundler/DeltaCalculator.d.ts +71 -0
- package/src/DeltaBundler/DeltaCalculator.js +4 -4
- package/src/DeltaBundler/DeltaCalculator.js.flow +8 -8
- package/src/DeltaBundler/Graph.d.ts +135 -8
- package/src/DeltaBundler/Graph.js +16 -16
- package/src/DeltaBundler/Graph.js.flow +30 -30
- package/src/DeltaBundler/Serializers/baseJSBundle.d.ts +20 -0
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +1 -1
- package/src/DeltaBundler/Serializers/getAllFiles.d.ts +22 -0
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getAssets.d.ts +25 -0
- package/src/DeltaBundler/Serializers/getAssets.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +36 -6
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +8 -8
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.d.ts +12 -0
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.d.ts +33 -0
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.d.ts +17 -0
- package/src/DeltaBundler/Serializers/helpers/js.d.ts +30 -0
- package/src/DeltaBundler/Serializers/helpers/js.js +25 -21
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +6 -6
- package/src/DeltaBundler/Serializers/helpers/processModules.d.ts +25 -0
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/hmrJSBundle.d.ts +30 -0
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +25 -21
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +5 -5
- package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +29 -0
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -6
- package/src/DeltaBundler/Serializers/sourceMapObject.d.ts +23 -0
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +2 -2
- package/src/DeltaBundler/Serializers/sourceMapString.d.ts +22 -0
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -2
- package/src/DeltaBundler/Transformer.d.ts +38 -0
- package/src/DeltaBundler/Transformer.js.flow +3 -3
- package/src/DeltaBundler/Worker.d.ts +19 -27
- package/src/DeltaBundler/Worker.flow.js.flow +1 -1
- package/src/DeltaBundler/WorkerFarm.d.ts +70 -0
- package/src/DeltaBundler/WorkerFarm.js +1 -1
- package/src/DeltaBundler/WorkerFarm.js.flow +26 -13
- package/src/DeltaBundler/buildSubgraph.d.ts +30 -0
- package/src/DeltaBundler/buildSubgraph.js +4 -4
- package/src/DeltaBundler/buildSubgraph.js.flow +8 -8
- package/src/DeltaBundler/getTransformCacheKey.d.ts +18 -0
- package/src/DeltaBundler/mergeDeltas.d.ts +17 -0
- package/src/DeltaBundler/types.d.ts +97 -100
- package/src/DeltaBundler/types.js.flow +36 -34
- package/src/DeltaBundler.d.ts +14 -12
- package/src/DeltaBundler.js.flow +2 -2
- package/src/HmrServer.d.ts +79 -0
- package/src/HmrServer.js +34 -29
- package/src/HmrServer.js.flow +17 -12
- package/src/IncrementalBundler/GraphNotFoundError.d.ts +17 -0
- package/src/IncrementalBundler/ResourceNotFoundError.d.ts +15 -0
- package/src/IncrementalBundler/RevisionNotFoundError.d.ts +17 -0
- package/src/IncrementalBundler.d.ts +43 -45
- package/src/IncrementalBundler.js +29 -21
- package/src/IncrementalBundler.js.flow +13 -9
- package/src/ModuleGraph/worker/JsFileWrapping.d.ts +29 -0
- package/src/ModuleGraph/worker/JsFileWrapping.js +25 -21
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +10 -5
- package/src/ModuleGraph/worker/collectDependencies.d.ts +118 -14
- package/src/ModuleGraph/worker/collectDependencies.js +25 -21
- package/src/ModuleGraph/worker/collectDependencies.js.flow +27 -21
- package/src/ModuleGraph/worker/generateImportNames.d.ts +19 -0
- package/src/ModuleGraph/worker/generateImportNames.js.flow +4 -2
- package/src/ModuleGraph/worker/importLocationsPlugin.d.ts +26 -0
- package/src/ModuleGraph/worker/importLocationsPlugin.js.flow +7 -3
- package/src/Server/MultipartResponse.d.ts +5 -6
- package/src/Server/MultipartResponse.js.flow +1 -1
- package/src/Server/symbolicate.js.flow +4 -4
- package/src/Server.d.ts +220 -67
- package/src/Server.js +149 -45
- package/src/Server.js.flow +167 -57
- package/src/cli/parseKeyValueParamArray.d.ts +14 -0
- package/src/cli/parseKeyValueParamArray.js.flow +1 -1
- package/src/cli-utils.d.ts +19 -0
- package/src/cli-utils.js.flow +2 -2
- package/src/commands/build.d.ts +16 -0
- package/src/commands/build.js.flow +11 -10
- package/src/commands/dependencies.d.ts +16 -0
- package/src/commands/dependencies.js.flow +8 -4
- package/src/commands/serve.d.ts +16 -0
- package/src/commands/serve.js +2 -0
- package/src/commands/serve.js.flow +14 -9
- package/src/index.d.ts +97 -110
- package/src/index.flow.js +53 -35
- package/src/index.flow.js.flow +49 -29
- package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +1 -1
- package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import-with-escapes.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require-with-embedded-comment.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-specifier-with-escapes.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-require.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/index.js +25 -21
- package/src/integration_tests/basic_bundle/import-export/index.js.flow +3 -3
- package/src/integration_tests/basic_bundle/import-export/utils.js.flow +2 -2
- package/src/integration_tests/basic_bundle/loadBundleAsyncForTest.js.flow +1 -1
- package/src/integration_tests/basic_bundle/optional-dependencies/index.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/conflict.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/empty.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/matching.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-eager.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-lazy.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-sync.js.flow +2 -2
- package/src/integration_tests/basic_bundle/require-context/utils.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js.flow +1 -1
- package/src/integration_tests/execBundle.js.flow +1 -1
- package/src/lib/BatchProcessor.d.ts +54 -0
- package/src/lib/BatchProcessor.js +5 -2
- package/src/lib/BatchProcessor.js.flow +10 -7
- package/src/lib/CountingSet.d.ts +10 -10
- package/src/lib/CountingSet.js.flow +4 -4
- package/src/lib/JsonReporter.d.ts +37 -0
- package/src/lib/JsonReporter.js +5 -3
- package/src/lib/JsonReporter.js.flow +19 -17
- package/src/lib/RamBundleParser.d.ts +29 -0
- package/src/lib/RamBundleParser.js.flow +1 -1
- package/src/lib/TerminalReporter.d.ts +97 -6
- package/src/lib/TerminalReporter.js +37 -34
- package/src/lib/TerminalReporter.js.flow +21 -30
- package/src/lib/bundleProgressUtils.d.ts +26 -0
- package/src/lib/bundleProgressUtils.js +19 -0
- package/src/lib/bundleProgressUtils.js.flow +35 -0
- package/src/lib/bundleToString.d.ts +19 -0
- package/src/lib/contextModule.d.ts +20 -9
- package/src/lib/contextModule.js.flow +1 -1
- package/src/lib/contextModuleTemplates.d.ts +25 -0
- package/src/lib/contextModuleTemplates.js +25 -21
- package/src/lib/countLines.d.ts +12 -0
- package/src/lib/countLines.js +4 -3
- package/src/lib/countLines.js.flow +3 -4
- package/src/lib/createWebsocketServer.d.ts +43 -0
- package/src/lib/createWebsocketServer.js +9 -2
- package/src/lib/createWebsocketServer.js.flow +16 -9
- package/src/lib/debounceAsyncQueue.d.ts +15 -0
- package/src/lib/debounceAsyncQueue.js.flow +1 -1
- package/src/lib/formatBundlingError.d.ts +23 -0
- package/src/lib/formatBundlingError.js.flow +1 -1
- package/src/lib/getAppendScripts.d.ts +31 -0
- package/src/lib/getAppendScripts.js.flow +4 -4
- package/src/lib/getGraphId.d.ts +15 -1
- package/src/lib/getGraphId.js.flow +1 -1
- package/src/lib/getPreludeCode.d.ts +18 -0
- package/src/lib/getPreludeCode.js +4 -0
- package/src/lib/getPreludeCode.js.flow +10 -3
- package/src/lib/getPrependedScripts.d.ts +24 -0
- package/src/lib/getPrependedScripts.js +36 -22
- package/src/lib/getPrependedScripts.js.flow +10 -3
- package/src/lib/isResolvedDependency.d.ts +15 -0
- package/src/lib/logToConsole.d.ts +19 -0
- package/src/lib/logToConsole.js.flow +2 -2
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.d.ts +17 -0
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +25 -21
- package/src/lib/parseCustomResolverOptions.d.ts +16 -0
- package/src/lib/parseCustomResolverOptions.js.flow +2 -2
- package/src/lib/parseCustomTransformOptions.d.ts +16 -0
- package/src/lib/parseCustomTransformOptions.js.flow +1 -1
- package/src/lib/parseJsonBody.d.ts +27 -0
- package/src/lib/parseJsonBody.js.flow +11 -1
- package/src/lib/pathUtils.d.ts +14 -0
- package/src/lib/pathUtils.js +25 -21
- package/src/lib/pathUtils.js.flow +1 -1
- package/src/lib/relativizeSourceMap.d.ts +17 -0
- package/src/lib/reporting.d.ts +65 -81
- package/src/lib/reporting.js.flow +4 -4
- package/src/lib/splitBundleOptions.d.ts +16 -0
- package/src/lib/transformHelpers.d.ts +35 -0
- package/src/lib/transformHelpers.js +11 -9
- package/src/lib/transformHelpers.js.flow +17 -15
- package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +126 -0
- package/src/node-haste/DependencyGraph/ModuleResolution.js +48 -42
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +35 -32
- package/src/node-haste/DependencyGraph/createFileMap.d.ts +29 -0
- package/src/node-haste/DependencyGraph/createFileMap.js +56 -38
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +44 -18
- package/src/node-haste/DependencyGraph.d.ts +57 -33
- package/src/node-haste/DependencyGraph.js +40 -31
- package/src/node-haste/DependencyGraph.js.flow +35 -37
- package/src/node-haste/Package.d.ts +21 -0
- package/src/node-haste/PackageCache.d.ts +34 -0
- package/src/node-haste/lib/AssetPaths.d.ts +29 -0
- package/src/node-haste/lib/AssetPaths.js +2 -2
- package/src/node-haste/lib/AssetPaths.js.flow +4 -4
- package/src/node-haste/lib/parsePlatformFilePath.d.ts +25 -0
- package/src/node-haste/lib/parsePlatformFilePath.js +6 -6
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +4 -4
- package/src/shared/output/RamBundle/as-assets.d.ts +25 -0
- package/src/shared/output/RamBundle/as-assets.js.flow +6 -6
- package/src/shared/output/RamBundle/as-indexed-file.d.ts +38 -0
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +5 -5
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.d.ts +23 -0
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +5 -5
- package/src/shared/output/RamBundle/magic-number.d.ts +14 -0
- package/src/shared/output/RamBundle/util.d.ts +41 -0
- package/src/shared/output/RamBundle/util.js.flow +5 -5
- package/src/shared/output/RamBundle/write-sourcemap.d.ts +16 -0
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
- package/src/shared/output/RamBundle.d.ts +26 -0
- package/src/shared/output/RamBundle.js.flow +1 -1
- package/src/shared/output/bundle.d.ts +9 -17
- package/src/shared/output/bundle.flow.js.flow +3 -3
- package/src/shared/output/meta.d.ts +15 -0
- package/src/shared/output/meta.js +2 -2
- package/src/shared/output/meta.js.flow +1 -1
- package/src/shared/output/unbundle.d.ts +11 -0
- package/src/shared/output/writeFile.d.ts +16 -0
- package/src/shared/output/writeFile.js +8 -3
- package/src/shared/output/writeFile.js.flow +8 -2
- package/src/shared/types.d.ts +81 -66
- package/src/shared/types.js.flow +20 -5
- package/src/Asset.d.ts +0 -25
- package/src/ModuleGraph/test-helpers.js +0 -75
|
@@ -8,55 +8,79 @@
|
|
|
8
8
|
* @oncall react_native
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import type {
|
|
12
12
|
BundlerResolution,
|
|
13
13
|
TransformResultDependency,
|
|
14
14
|
} from '../DeltaBundler/types';
|
|
15
|
-
import {ResolverInputOptions} from '../shared/types';
|
|
16
|
-
import
|
|
17
|
-
import {ConfigT} from 'metro-config';
|
|
15
|
+
import type {ResolverInputOptions} from '../shared/types';
|
|
16
|
+
import type Package from './Package';
|
|
17
|
+
import type {ConfigT} from 'metro-config';
|
|
18
|
+
import type {
|
|
19
|
+
ChangeEvent,
|
|
20
|
+
FileSystem,
|
|
21
|
+
HasteMap,
|
|
22
|
+
HealthCheckResult,
|
|
23
|
+
WatcherStatus,
|
|
24
|
+
default as MetroFileMap,
|
|
25
|
+
} from 'metro-file-map';
|
|
18
26
|
|
|
19
|
-
|
|
27
|
+
import {ModuleResolver} from './DependencyGraph/ModuleResolution';
|
|
28
|
+
import {PackageCache} from './PackageCache';
|
|
29
|
+
import EventEmitter from 'events';
|
|
30
|
+
|
|
31
|
+
declare class DependencyGraph extends EventEmitter {
|
|
32
|
+
_config: ConfigT;
|
|
33
|
+
_haste: MetroFileMap;
|
|
34
|
+
_fileSystem: FileSystem;
|
|
35
|
+
_hasteMap: HasteMap;
|
|
36
|
+
_moduleResolver: ModuleResolver<Package>;
|
|
37
|
+
_resolutionCache: Map<
|
|
38
|
+
string | symbol,
|
|
39
|
+
Map<
|
|
40
|
+
string | symbol,
|
|
41
|
+
Map<string | symbol, Map<string | symbol, BundlerResolution>>
|
|
42
|
+
>
|
|
43
|
+
>;
|
|
44
|
+
_initializedPromise: Promise<void>;
|
|
20
45
|
constructor(
|
|
21
46
|
config: ConfigT,
|
|
22
|
-
options?:
|
|
23
|
-
hasReducedPerformance?: boolean;
|
|
24
|
-
watch?: boolean;
|
|
25
|
-
}
|
|
47
|
+
options?: {
|
|
48
|
+
readonly hasReducedPerformance?: boolean;
|
|
49
|
+
readonly watch?: boolean;
|
|
50
|
+
},
|
|
26
51
|
);
|
|
27
|
-
|
|
52
|
+
_onWatcherHealthCheck(result: HealthCheckResult): void;
|
|
53
|
+
_onWatcherStatus(status: WatcherStatus): void;
|
|
28
54
|
ready(): Promise<void>;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
):
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
55
|
+
_onHasteChange($$PARAM_0$$: ChangeEvent): void;
|
|
56
|
+
_createModuleResolver(): void;
|
|
57
|
+
_getClosestPackage(
|
|
58
|
+
absoluteModulePath: string,
|
|
59
|
+
): null | undefined | {packageJsonPath: string; packageRelativePath: string};
|
|
60
|
+
_createPackageCache(): PackageCache;
|
|
61
|
+
getAllFiles(): Array<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Used when watcher.unstable_lazySha1 is true
|
|
64
|
+
*/
|
|
65
|
+
getOrComputeSha1(
|
|
66
|
+
mixedPath: string,
|
|
67
|
+
): Promise<{content?: Buffer; sha1: string}>;
|
|
38
68
|
getWatcher(): EventEmitter;
|
|
39
69
|
end(): void;
|
|
40
|
-
|
|
41
70
|
/** Given a search context, return a list of file paths matching the query. */
|
|
42
71
|
matchFilesWithContext(
|
|
43
72
|
from: string,
|
|
44
|
-
context: Readonly<{
|
|
45
|
-
|
|
46
|
-
recursive: boolean;
|
|
47
|
-
/* Filter relative paths against a pattern. */
|
|
48
|
-
filter: RegExp;
|
|
49
|
-
}>,
|
|
50
|
-
): string[];
|
|
51
|
-
|
|
73
|
+
context: Readonly<{recursive: boolean; filter: RegExp}>,
|
|
74
|
+
): Iterable<string>;
|
|
52
75
|
resolveDependency(
|
|
53
|
-
|
|
54
|
-
|
|
76
|
+
originModulePath: string,
|
|
77
|
+
dependency: TransformResultDependency,
|
|
55
78
|
platform: string | null,
|
|
56
79
|
resolverOptions: ResolverInputOptions,
|
|
57
|
-
|
|
80
|
+
$$PARAM_4$$?: {assumeFlatNodeModules: boolean},
|
|
58
81
|
): BundlerResolution;
|
|
59
|
-
|
|
82
|
+
doesFileExist: (filePath: string) => boolean;
|
|
60
83
|
getHasteName(filePath: string): string;
|
|
61
|
-
getDependencies(filePath: string): string
|
|
84
|
+
getDependencies(filePath: string): Array<string>;
|
|
62
85
|
}
|
|
86
|
+
export default DependencyGraph;
|
|
@@ -34,6 +34,7 @@ function getOrCreateMap(map, field) {
|
|
|
34
34
|
}
|
|
35
35
|
class DependencyGraph extends _events.default {
|
|
36
36
|
#packageCache;
|
|
37
|
+
#dependencyPlugin;
|
|
37
38
|
constructor(config, options) {
|
|
38
39
|
super();
|
|
39
40
|
this._config = config;
|
|
@@ -45,32 +46,34 @@ class DependencyGraph extends _events.default {
|
|
|
45
46
|
type: "dep_graph_loading",
|
|
46
47
|
hasReducedPerformance: !!hasReducedPerformance,
|
|
47
48
|
});
|
|
48
|
-
const fileMap = (0, _createFileMap.default)(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
const { fileMap, hasteMap, dependencyPlugin } = (0, _createFileMap.default)(
|
|
50
|
+
config,
|
|
51
|
+
{
|
|
52
|
+
throwOnModuleCollision: false,
|
|
53
|
+
watch,
|
|
54
|
+
},
|
|
55
|
+
);
|
|
52
56
|
fileMap.setMaxListeners(1000);
|
|
53
57
|
this._haste = fileMap;
|
|
54
58
|
this._haste.on("status", (status) => this._onWatcherStatus(status));
|
|
55
|
-
this._initializedPromise = fileMap
|
|
56
|
-
|
|
57
|
-
.
|
|
58
|
-
|
|
59
|
-
config.reporter.update({
|
|
60
|
-
type: "dep_graph_loaded",
|
|
61
|
-
});
|
|
62
|
-
this._fileSystem = fileSystem;
|
|
63
|
-
this._hasteMap = hasteMap;
|
|
64
|
-
this._haste.on("change", (changeEvent) =>
|
|
65
|
-
this._onHasteChange(changeEvent),
|
|
66
|
-
);
|
|
67
|
-
this._haste.on("healthCheck", (result) =>
|
|
68
|
-
this._onWatcherHealthCheck(result),
|
|
69
|
-
);
|
|
70
|
-
this._resolutionCache = new Map();
|
|
71
|
-
this.#packageCache = this._createPackageCache();
|
|
72
|
-
this._createModuleResolver();
|
|
59
|
+
this._initializedPromise = fileMap.build().then(({ fileSystem }) => {
|
|
60
|
+
log(createActionEndEntry(initializingMetroLogEntry));
|
|
61
|
+
config.reporter.update({
|
|
62
|
+
type: "dep_graph_loaded",
|
|
73
63
|
});
|
|
64
|
+
this._fileSystem = fileSystem;
|
|
65
|
+
this._hasteMap = hasteMap;
|
|
66
|
+
this.#dependencyPlugin = dependencyPlugin;
|
|
67
|
+
this._haste.on("change", (changeEvent) =>
|
|
68
|
+
this._onHasteChange(changeEvent),
|
|
69
|
+
);
|
|
70
|
+
this._haste.on("healthCheck", (result) =>
|
|
71
|
+
this._onWatcherHealthCheck(result),
|
|
72
|
+
);
|
|
73
|
+
this._resolutionCache = new Map();
|
|
74
|
+
this.#packageCache = this._createPackageCache();
|
|
75
|
+
this._createModuleResolver();
|
|
76
|
+
});
|
|
74
77
|
}
|
|
75
78
|
_onWatcherHealthCheck(result) {
|
|
76
79
|
this._config.reporter.update({
|
|
@@ -87,11 +90,6 @@ class DependencyGraph extends _events.default {
|
|
|
87
90
|
async ready() {
|
|
88
91
|
await this._initializedPromise;
|
|
89
92
|
}
|
|
90
|
-
static async load(config, options) {
|
|
91
|
-
const self = new DependencyGraph(config, options);
|
|
92
|
-
await self.ready();
|
|
93
|
-
return self;
|
|
94
|
-
}
|
|
95
93
|
_onHasteChange({ eventsQueue }) {
|
|
96
94
|
this._resolutionCache = new Map();
|
|
97
95
|
eventsQueue.forEach(({ filePath }) =>
|
|
@@ -124,7 +122,7 @@ class DependencyGraph extends _events.default {
|
|
|
124
122
|
},
|
|
125
123
|
disableHierarchicalLookup:
|
|
126
124
|
this._config.resolver.disableHierarchicalLookup,
|
|
127
|
-
doesFileExist: this.
|
|
125
|
+
doesFileExist: this.doesFileExist,
|
|
128
126
|
emptyModulePath: this._config.resolver.emptyModulePath,
|
|
129
127
|
extraNodeModules: this._config.resolver.extraNodeModules,
|
|
130
128
|
fileSystemLookup,
|
|
@@ -157,6 +155,8 @@ class DependencyGraph extends _events.default {
|
|
|
157
155
|
this._config.resolver.unstable_conditionsByPlatform,
|
|
158
156
|
unstable_enablePackageExports:
|
|
159
157
|
this._config.resolver.unstable_enablePackageExports,
|
|
158
|
+
unstable_incrementalResolution:
|
|
159
|
+
this._config.resolver.unstable_incrementalResolution,
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
162
|
_getClosestPackage(absoluteModulePath) {
|
|
@@ -276,18 +276,27 @@ class DependencyGraph extends _events.default {
|
|
|
276
276
|
mapByPlatform.set(platformKey, resolution);
|
|
277
277
|
return resolution;
|
|
278
278
|
}
|
|
279
|
-
|
|
279
|
+
doesFileExist = (filePath) => {
|
|
280
280
|
return this._fileSystem.exists(filePath);
|
|
281
281
|
};
|
|
282
282
|
getHasteName(filePath) {
|
|
283
|
-
const hasteName = this.
|
|
283
|
+
const hasteName = this._hasteMap.getModuleNameByPath(filePath);
|
|
284
284
|
if (hasteName) {
|
|
285
285
|
return hasteName;
|
|
286
286
|
}
|
|
287
287
|
return _path.default.relative(this._config.projectRoot, filePath);
|
|
288
288
|
}
|
|
289
289
|
getDependencies(filePath) {
|
|
290
|
-
|
|
290
|
+
if (!this.#dependencyPlugin) {
|
|
291
|
+
throw new Error(
|
|
292
|
+
"getDependencies called but extractDependencies is false",
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
return Array.from(
|
|
296
|
+
(0, _nullthrows.default)(
|
|
297
|
+
this.#dependencyPlugin.getDependencies(filePath),
|
|
298
|
+
),
|
|
299
|
+
);
|
|
291
300
|
}
|
|
292
301
|
}
|
|
293
302
|
exports.default = DependencyGraph;
|
|
@@ -16,12 +16,14 @@ import type {
|
|
|
16
16
|
import type {ResolverInputOptions} from '../shared/types';
|
|
17
17
|
import type Package from './Package';
|
|
18
18
|
import type {ConfigT} from 'metro-config';
|
|
19
|
-
import type
|
|
19
|
+
import type {
|
|
20
20
|
ChangeEvent,
|
|
21
|
+
DependencyPlugin,
|
|
21
22
|
FileSystem,
|
|
22
23
|
HasteMap,
|
|
23
24
|
HealthCheckResult,
|
|
24
25
|
WatcherStatus,
|
|
26
|
+
default as MetroFileMap,
|
|
25
27
|
} from 'metro-file-map';
|
|
26
28
|
import type {FileSystemLookup} from 'metro-resolver';
|
|
27
29
|
|
|
@@ -63,6 +65,7 @@ export default class DependencyGraph extends EventEmitter {
|
|
|
63
65
|
_fileSystem: FileSystem;
|
|
64
66
|
#packageCache: PackageCache;
|
|
65
67
|
_hasteMap: HasteMap;
|
|
68
|
+
#dependencyPlugin: ?DependencyPlugin;
|
|
66
69
|
_moduleResolver: ModuleResolver<Package>;
|
|
67
70
|
_resolutionCache: Map<
|
|
68
71
|
// Custom resolver options
|
|
@@ -103,7 +106,7 @@ export default class DependencyGraph extends EventEmitter {
|
|
|
103
106
|
type: 'dep_graph_loading',
|
|
104
107
|
hasReducedPerformance: !!hasReducedPerformance,
|
|
105
108
|
});
|
|
106
|
-
const fileMap = createFileMap(config, {
|
|
109
|
+
const {fileMap, hasteMap, dependencyPlugin} = createFileMap(config, {
|
|
107
110
|
throwOnModuleCollision: false,
|
|
108
111
|
watch,
|
|
109
112
|
});
|
|
@@ -115,25 +118,22 @@ export default class DependencyGraph extends EventEmitter {
|
|
|
115
118
|
this._haste = fileMap;
|
|
116
119
|
this._haste.on('status', status => this._onWatcherStatus(status));
|
|
117
120
|
|
|
118
|
-
this._initializedPromise = fileMap
|
|
119
|
-
|
|
120
|
-
.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
this.#packageCache = this._createPackageCache();
|
|
135
|
-
this._createModuleResolver();
|
|
136
|
-
});
|
|
121
|
+
this._initializedPromise = fileMap.build().then(({fileSystem}) => {
|
|
122
|
+
log(createActionEndEntry(initializingMetroLogEntry));
|
|
123
|
+
config.reporter.update({type: 'dep_graph_loaded'});
|
|
124
|
+
|
|
125
|
+
this._fileSystem = fileSystem;
|
|
126
|
+
this._hasteMap = hasteMap;
|
|
127
|
+
this.#dependencyPlugin = dependencyPlugin;
|
|
128
|
+
|
|
129
|
+
this._haste.on('change', changeEvent => this._onHasteChange(changeEvent));
|
|
130
|
+
this._haste.on('healthCheck', result =>
|
|
131
|
+
this._onWatcherHealthCheck(result),
|
|
132
|
+
);
|
|
133
|
+
this._resolutionCache = new Map();
|
|
134
|
+
this.#packageCache = this._createPackageCache();
|
|
135
|
+
this._createModuleResolver();
|
|
136
|
+
});
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
_onWatcherHealthCheck(result: HealthCheckResult) {
|
|
@@ -150,17 +150,6 @@ export default class DependencyGraph extends EventEmitter {
|
|
|
150
150
|
await this._initializedPromise;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
// Creates the dependency graph and waits for it to become ready.
|
|
154
|
-
// @deprecated Use the constructor + ready() directly.
|
|
155
|
-
static async load(
|
|
156
|
-
config: ConfigT,
|
|
157
|
-
options?: {+hasReducedPerformance?: boolean, +watch?: boolean},
|
|
158
|
-
): Promise<DependencyGraph> {
|
|
159
|
-
const self = new DependencyGraph(config, options);
|
|
160
|
-
await self.ready();
|
|
161
|
-
return self;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
153
|
_onHasteChange({eventsQueue}: ChangeEvent) {
|
|
165
154
|
this._resolutionCache = new Map();
|
|
166
155
|
eventsQueue.forEach(({filePath}) =>
|
|
@@ -193,7 +182,7 @@ export default class DependencyGraph extends EventEmitter {
|
|
|
193
182
|
},
|
|
194
183
|
disableHierarchicalLookup:
|
|
195
184
|
this._config.resolver.disableHierarchicalLookup,
|
|
196
|
-
doesFileExist: this.
|
|
185
|
+
doesFileExist: this.doesFileExist,
|
|
197
186
|
emptyModulePath: this._config.resolver.emptyModulePath,
|
|
198
187
|
extraNodeModules: this._config.resolver.extraNodeModules,
|
|
199
188
|
fileSystemLookup,
|
|
@@ -227,6 +216,8 @@ export default class DependencyGraph extends EventEmitter {
|
|
|
227
216
|
this._config.resolver.unstable_conditionsByPlatform,
|
|
228
217
|
unstable_enablePackageExports:
|
|
229
218
|
this._config.resolver.unstable_enablePackageExports,
|
|
219
|
+
unstable_incrementalResolution:
|
|
220
|
+
this._config.resolver.unstable_incrementalResolution,
|
|
230
221
|
});
|
|
231
222
|
}
|
|
232
223
|
|
|
@@ -290,7 +281,7 @@ export default class DependencyGraph extends EventEmitter {
|
|
|
290
281
|
/** Given a search context, return a list of file paths matching the query. */
|
|
291
282
|
matchFilesWithContext(
|
|
292
283
|
from: string,
|
|
293
|
-
context:
|
|
284
|
+
context: Readonly<{
|
|
294
285
|
/* Should search for files recursively. */
|
|
295
286
|
recursive: boolean,
|
|
296
287
|
/* Filter relative paths against a pattern. */
|
|
@@ -376,12 +367,12 @@ export default class DependencyGraph extends EventEmitter {
|
|
|
376
367
|
return resolution;
|
|
377
368
|
}
|
|
378
369
|
|
|
379
|
-
|
|
370
|
+
doesFileExist = (filePath: string): boolean => {
|
|
380
371
|
return this._fileSystem.exists(filePath);
|
|
381
372
|
};
|
|
382
373
|
|
|
383
374
|
getHasteName(filePath: string): string {
|
|
384
|
-
const hasteName = this.
|
|
375
|
+
const hasteName = this._hasteMap.getModuleNameByPath(filePath);
|
|
385
376
|
|
|
386
377
|
if (hasteName) {
|
|
387
378
|
return hasteName;
|
|
@@ -391,6 +382,13 @@ export default class DependencyGraph extends EventEmitter {
|
|
|
391
382
|
}
|
|
392
383
|
|
|
393
384
|
getDependencies(filePath: string): Array<string> {
|
|
394
|
-
|
|
385
|
+
if (!this.#dependencyPlugin) {
|
|
386
|
+
throw new Error(
|
|
387
|
+
'getDependencies called but extractDependencies is false',
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
return Array.from(
|
|
391
|
+
nullthrows(this.#dependencyPlugin.getDependencies(filePath)),
|
|
392
|
+
);
|
|
395
393
|
}
|
|
396
394
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {PackageJson} from 'metro-resolver/private/types';
|
|
12
|
+
|
|
13
|
+
declare class Package {
|
|
14
|
+
path: string;
|
|
15
|
+
_root: string;
|
|
16
|
+
_content: null | undefined | PackageJson;
|
|
17
|
+
constructor($$PARAM_0$$: {file: string});
|
|
18
|
+
invalidate(): void;
|
|
19
|
+
read(): PackageJson;
|
|
20
|
+
}
|
|
21
|
+
export default Package;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import Package from './Package';
|
|
12
|
+
|
|
13
|
+
type GetClosestPackageFn = (
|
|
14
|
+
absoluteFilePath: string,
|
|
15
|
+
) => null | undefined | {packageJsonPath: string; packageRelativePath: string};
|
|
16
|
+
export declare class PackageCache {
|
|
17
|
+
_getClosestPackage: GetClosestPackageFn;
|
|
18
|
+
_packageCache: {[filePath: string]: Package};
|
|
19
|
+
_packagePathAndSubpathByModulePath: {
|
|
20
|
+
[filePath: string]:
|
|
21
|
+
| null
|
|
22
|
+
| undefined
|
|
23
|
+
| {packageJsonPath: string; packageRelativePath: string};
|
|
24
|
+
};
|
|
25
|
+
_modulePathsByPackagePath: {
|
|
26
|
+
[filePath: string]: Set<string>;
|
|
27
|
+
};
|
|
28
|
+
constructor(options: {getClosestPackage: GetClosestPackageFn});
|
|
29
|
+
getPackage(filePath: string): Package;
|
|
30
|
+
getPackageOf(
|
|
31
|
+
absoluteModulePath: string,
|
|
32
|
+
): null | undefined | {pkg: Package; packageRelativePath: string};
|
|
33
|
+
invalidate(filePath: string): void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export type AssetPath = {
|
|
12
|
+
assetName: string;
|
|
13
|
+
name: string;
|
|
14
|
+
platform: null | undefined | string;
|
|
15
|
+
resolution: number;
|
|
16
|
+
type: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Return `null` if the `filePath` doesn't have a valid extension, required
|
|
20
|
+
* to describe the type of an asset.
|
|
21
|
+
*/
|
|
22
|
+
export declare function tryParse(
|
|
23
|
+
filePath: string,
|
|
24
|
+
platforms: ReadonlySet<string>,
|
|
25
|
+
): null | undefined | AssetPath;
|
|
26
|
+
export declare function parse(
|
|
27
|
+
filePath: string,
|
|
28
|
+
platforms: ReadonlySet<string>,
|
|
29
|
+
): AssetPath;
|
|
@@ -23,14 +23,14 @@ function parseBaseName(baseName) {
|
|
|
23
23
|
const resolution = parseFloat(match[3]);
|
|
24
24
|
if (!Number.isNaN(resolution)) {
|
|
25
25
|
return {
|
|
26
|
-
rootName,
|
|
27
26
|
resolution,
|
|
27
|
+
rootName,
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
return {
|
|
32
|
-
rootName,
|
|
33
32
|
resolution: 1,
|
|
33
|
+
rootName,
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
function tryParse(filePath, platforms) {
|
|
@@ -35,10 +35,10 @@ function parseBaseName(baseName: string): {
|
|
|
35
35
|
if (match[3] != null) {
|
|
36
36
|
const resolution = parseFloat(match[3]);
|
|
37
37
|
if (!Number.isNaN(resolution)) {
|
|
38
|
-
return {
|
|
38
|
+
return {resolution, rootName};
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
return {
|
|
41
|
+
return {resolution: 1, rootName};
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -47,7 +47,7 @@ function parseBaseName(baseName: string): {
|
|
|
47
47
|
*/
|
|
48
48
|
export function tryParse(
|
|
49
49
|
filePath: string,
|
|
50
|
-
platforms:
|
|
50
|
+
platforms: ReadonlySet<string>,
|
|
51
51
|
): ?AssetPath {
|
|
52
52
|
const result = parsePlatformFilePath(filePath, platforms);
|
|
53
53
|
const {dirPath, baseName, platform, extension} = result;
|
|
@@ -66,7 +66,7 @@ export function tryParse(
|
|
|
66
66
|
|
|
67
67
|
export function parse(
|
|
68
68
|
filePath: string,
|
|
69
|
-
platforms:
|
|
69
|
+
platforms: ReadonlySet<string>,
|
|
70
70
|
): AssetPath {
|
|
71
71
|
const result = tryParse(filePath, platforms);
|
|
72
72
|
if (result == null) {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
type PlatformFilePathParts = {
|
|
12
|
+
dirPath: string;
|
|
13
|
+
baseName: string;
|
|
14
|
+
platform: null | undefined | string;
|
|
15
|
+
extension: null | undefined | string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Extract the components of a file path that can have a platform specifier: Ex.
|
|
19
|
+
* `index.ios.js` is specific to the `ios` platform and has the extension `js`.
|
|
20
|
+
*/
|
|
21
|
+
declare function parsePlatformFilePath(
|
|
22
|
+
filePath: string,
|
|
23
|
+
platforms: ReadonlySet<string>,
|
|
24
|
+
): PlatformFilePathParts;
|
|
25
|
+
export default parsePlatformFilePath;
|
|
@@ -15,27 +15,27 @@ function parsePlatformFilePath(filePath, platforms) {
|
|
|
15
15
|
const match = fileName.match(PATH_RE);
|
|
16
16
|
if (!match) {
|
|
17
17
|
return {
|
|
18
|
-
dirPath,
|
|
19
18
|
baseName: fileName,
|
|
20
|
-
|
|
19
|
+
dirPath,
|
|
21
20
|
extension: null,
|
|
21
|
+
platform: null,
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
const extension = match[4] || null;
|
|
25
25
|
const platform = match[3] || null;
|
|
26
26
|
if (platform == null || platforms.has(platform)) {
|
|
27
27
|
return {
|
|
28
|
-
dirPath,
|
|
29
28
|
baseName: match[1],
|
|
30
|
-
|
|
29
|
+
dirPath,
|
|
31
30
|
extension,
|
|
31
|
+
platform,
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
const baseName = `${match[1]}.${platform}`;
|
|
35
35
|
return {
|
|
36
|
-
dirPath,
|
|
37
36
|
baseName,
|
|
38
|
-
|
|
37
|
+
dirPath,
|
|
39
38
|
extension,
|
|
39
|
+
platform: null,
|
|
40
40
|
};
|
|
41
41
|
}
|
|
@@ -26,19 +26,19 @@ const PATH_RE = /^(.+?)(\.([^.]+))?\.([^.]+)$/;
|
|
|
26
26
|
*/
|
|
27
27
|
export default function parsePlatformFilePath(
|
|
28
28
|
filePath: string,
|
|
29
|
-
platforms:
|
|
29
|
+
platforms: ReadonlySet<string>,
|
|
30
30
|
): PlatformFilePathParts {
|
|
31
31
|
const dirPath = path.dirname(filePath);
|
|
32
32
|
const fileName = path.basename(filePath);
|
|
33
33
|
const match = fileName.match(PATH_RE);
|
|
34
34
|
if (!match) {
|
|
35
|
-
return {
|
|
35
|
+
return {baseName: fileName, dirPath, extension: null, platform: null};
|
|
36
36
|
}
|
|
37
37
|
const extension = match[4] || null;
|
|
38
38
|
const platform = match[3] || null;
|
|
39
39
|
if (platform == null || platforms.has(platform)) {
|
|
40
|
-
return {
|
|
40
|
+
return {baseName: match[1], dirPath, extension, platform};
|
|
41
41
|
}
|
|
42
42
|
const baseName = `${match[1]}.${platform}`;
|
|
43
|
-
return {dirPath,
|
|
43
|
+
return {baseName, dirPath, extension, platform: null};
|
|
44
44
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {RamBundleInfo} from '../../../DeltaBundler/Serializers/getRamBundleInfo';
|
|
12
|
+
import type {OutputOptions} from '../../types';
|
|
13
|
+
/**
|
|
14
|
+
* Saves all JS modules of an app as single files
|
|
15
|
+
* The startup code (prelude, polyfills etc.) are written to the file
|
|
16
|
+
* designated by the `bundleOuput` option.
|
|
17
|
+
* All other modules go into a 'js-modules' folder that in the same parent
|
|
18
|
+
* directory as the startup file.
|
|
19
|
+
*/
|
|
20
|
+
declare function saveAsAssets(
|
|
21
|
+
bundle: RamBundleInfo,
|
|
22
|
+
options: OutputOptions,
|
|
23
|
+
log: (...args: Array<string>) => void,
|
|
24
|
+
): Promise<unknown>;
|
|
25
|
+
export default saveAsAssets;
|
|
@@ -37,7 +37,7 @@ export default function saveAsAssets(
|
|
|
37
37
|
bundle: RamBundleInfo,
|
|
38
38
|
options: OutputOptions,
|
|
39
39
|
log: (...args: Array<string>) => void,
|
|
40
|
-
): Promise<
|
|
40
|
+
): Promise<unknown> {
|
|
41
41
|
const {
|
|
42
42
|
bundleOutput,
|
|
43
43
|
bundleEncoding: encoding,
|
|
@@ -100,24 +100,24 @@ function writeModuleFile(
|
|
|
100
100
|
module: ModuleTransportLike,
|
|
101
101
|
modulesDir: string,
|
|
102
102
|
encoding: void | 'ascii' | 'utf16le' | 'utf8',
|
|
103
|
-
): Promise<
|
|
103
|
+
): Promise<unknown> {
|
|
104
104
|
const {code, id} = module;
|
|
105
105
|
return writeFile(path.join(modulesDir, id + '.js'), code, encoding);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
function writeModules(
|
|
109
|
-
modules:
|
|
109
|
+
modules: ReadonlyArray<ModuleTransportLike>,
|
|
110
110
|
modulesDir: string,
|
|
111
111
|
encoding: void | 'ascii' | 'utf16le' | 'utf8',
|
|
112
|
-
): Promise<Array<
|
|
112
|
+
): Promise<Array<unknown>> {
|
|
113
113
|
const writeFiles = modules.map(
|
|
114
|
-
(module: ModuleTransportLike): Promise<
|
|
114
|
+
(module: ModuleTransportLike): Promise<unknown> =>
|
|
115
115
|
writeModuleFile(module, modulesDir, encoding),
|
|
116
116
|
);
|
|
117
117
|
return Promise.all(writeFiles);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
function writeMagicFlagFile(outputDir: string): Promise<
|
|
120
|
+
function writeMagicFlagFile(outputDir: string): Promise<unknown> {
|
|
121
121
|
const buffer = Buffer.alloc(4);
|
|
122
122
|
buffer.writeUInt32LE(MAGIC_RAM_BUNDLE_NUMBER, 0);
|
|
123
123
|
return writeFile(path.join(outputDir, MAGIC_RAM_BUNDLE_FILENAME), buffer);
|