metro 0.65.2 → 0.67.0
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 +27 -27
- package/src/Assets.js +9 -9
- package/src/Assets.js.flow +5 -7
- package/src/Bundler/util.js +17 -15
- package/src/Bundler/util.js.flow +12 -10
- package/src/Bundler.js +22 -9
- package/src/Bundler.js.flow +20 -7
- package/src/DeltaBundler/DeltaCalculator.js +17 -15
- package/src/DeltaBundler/DeltaCalculator.js.flow +9 -7
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js +13 -13
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js.flow +6 -7
- package/src/DeltaBundler/Serializers/baseJSBundle.js +4 -4
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +4 -4
- package/src/DeltaBundler/Serializers/getAllFiles.js +1 -1
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +3 -3
- package/src/DeltaBundler/Serializers/getAssets.js +3 -3
- package/src/DeltaBundler/Serializers/getAssets.js.flow +4 -5
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js +4 -4
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +4 -4
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js +20 -20
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +9 -10
- package/src/DeltaBundler/Serializers/helpers/bytecode.js +11 -11
- package/src/DeltaBundler/Serializers/helpers/bytecode.js.flow +5 -6
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js +1 -1
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js.flow +1 -1
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js +2 -2
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +4 -4
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js +1 -1
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js.flow +1 -1
- package/src/DeltaBundler/Serializers/helpers/js.js +18 -8
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +19 -10
- package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js +4 -4
- package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/helpers/processModules.js +4 -4
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +9 -9
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +9 -8
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +6 -6
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +3 -4
- package/src/DeltaBundler/Serializers/sourceMapObject.js +5 -5
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +4 -4
- package/src/DeltaBundler/Serializers/sourceMapString.js +2 -2
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +3 -3
- package/src/DeltaBundler/Transformer.js +16 -14
- package/src/DeltaBundler/Transformer.js.flow +15 -15
- package/src/DeltaBundler/Worker.js +8 -11
- package/src/DeltaBundler/Worker.js.flow +8 -11
- package/src/DeltaBundler/WorkerFarm.js +15 -18
- package/src/DeltaBundler/WorkerFarm.js.flow +9 -11
- package/src/DeltaBundler/__fixtures__/hasteImpl.js +2 -2
- package/src/DeltaBundler/computeDelta.js +2 -2
- package/src/DeltaBundler/computeDelta.js.flow +2 -2
- package/src/DeltaBundler/getTransformCacheKey.js +4 -4
- package/src/DeltaBundler/getTransformCacheKey.js.flow +5 -6
- package/src/DeltaBundler/mergeDeltas.js +2 -2
- package/src/DeltaBundler/mergeDeltas.js.flow +1 -1
- package/src/DeltaBundler/traverseDependencies.js +22 -22
- package/src/DeltaBundler/traverseDependencies.js.flow +3 -3
- package/src/DeltaBundler/types.flow.js +1 -1
- package/src/DeltaBundler/types.flow.js.flow +15 -1
- package/src/DeltaBundler.js +5 -5
- package/src/DeltaBundler.js.flow +4 -4
- package/src/HmrServer.js +73 -55
- package/src/HmrServer.js.flow +42 -37
- package/src/IncrementalBundler/GraphNotFoundError.js +1 -1
- package/src/IncrementalBundler/GraphNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler/ResourceNotFoundError.js +1 -1
- package/src/IncrementalBundler/ResourceNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler/RevisionNotFoundError.js +1 -1
- package/src/IncrementalBundler/RevisionNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler.js +46 -32
- package/src/IncrementalBundler.js.flow +32 -24
- package/src/ModuleGraph/module.js +3 -3
- package/src/ModuleGraph/module.js.flow +1 -1
- package/src/ModuleGraph/node-haste/HasteFS.js +5 -3
- package/src/ModuleGraph/node-haste/HasteFS.js.flow +3 -1
- package/src/ModuleGraph/node-haste/Module.js +1 -1
- package/src/ModuleGraph/node-haste/Module.js.flow +1 -1
- package/src/ModuleGraph/node-haste/ModuleCache.js +1 -1
- package/src/ModuleGraph/node-haste/ModuleCache.js.flow +3 -3
- package/src/ModuleGraph/node-haste/Package.js +3 -3
- package/src/ModuleGraph/node-haste/Package.js.flow +3 -3
- package/src/ModuleGraph/node-haste/node-haste.flow.js +1 -1
- package/src/ModuleGraph/node-haste/node-haste.flow.js.flow +1 -1
- package/src/ModuleGraph/node-haste/node-haste.js +41 -31
- package/src/ModuleGraph/node-haste/node-haste.js.flow +28 -22
- package/src/ModuleGraph/output/indexed-ram-bundle.js +17 -17
- package/src/ModuleGraph/output/indexed-ram-bundle.js.flow +41 -9
- package/src/ModuleGraph/output/multiple-files-ram-bundle.js +18 -18
- package/src/ModuleGraph/output/multiple-files-ram-bundle.js.flow +21 -9
- package/src/ModuleGraph/output/plain-bundle.js +6 -6
- package/src/ModuleGraph/output/plain-bundle.js.flow +7 -7
- package/src/ModuleGraph/output/reverse-dependency-map-references.js +3 -3
- package/src/ModuleGraph/output/reverse-dependency-map-references.js.flow +4 -8
- package/src/ModuleGraph/output/util.js +61 -40
- package/src/ModuleGraph/output/util.js.flow +51 -28
- package/src/ModuleGraph/silent-console.js +2 -2
- package/src/ModuleGraph/silent-console.js.flow +1 -1
- package/src/ModuleGraph/test-helpers.js +7 -7
- package/src/ModuleGraph/types.flow.js +1 -1
- package/src/ModuleGraph/types.flow.js.flow +47 -31
- package/src/ModuleGraph/worker/JsFileWrapping.js +16 -16
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +3 -2
- package/src/ModuleGraph/worker/Platforms.js +2 -2
- package/src/ModuleGraph/worker/Platforms.js.flow +1 -1
- package/src/ModuleGraph/worker/collectDependencies.js +24 -25
- package/src/ModuleGraph/worker/collectDependencies.js.flow +16 -18
- package/src/ModuleGraph/worker/generate.js +2 -2
- package/src/ModuleGraph/worker/generate.js.flow +3 -3
- package/src/ModuleGraph/worker/generateImportNames.js +5 -5
- package/src/ModuleGraph/worker/generateImportNames.js.flow +3 -5
- package/src/ModuleGraph/worker/mergeSourceMaps.js +8 -7
- package/src/ModuleGraph/worker/mergeSourceMaps.js.flow +3 -3
- package/src/Server/MultipartResponse.js +4 -8
- package/src/Server/symbolicate.js +8 -8
- package/src/Server/symbolicate.js.flow +17 -5
- package/src/Server.js +204 -150
- package/src/Server.js.flow +131 -87
- package/src/cli-utils.js +4 -4
- package/src/cli-utils.js.flow +15 -13
- package/src/cli.js +4 -4
- package/src/cli.js.flow +2 -4
- package/src/commands/build.js +23 -24
- package/src/commands/build.js.flow +6 -9
- package/src/commands/dependencies.js +25 -19
- package/src/commands/serve.js +19 -19
- package/src/commands/serve.js.flow +7 -9
- package/src/index.js +117 -50
- package/src/index.js.flow +108 -40
- package/src/integration_tests/basic_bundle/AssetRegistry.js +2 -2
- package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +1 -1
- package/src/integration_tests/basic_bundle/Bar.js +2 -2
- package/src/integration_tests/basic_bundle/Bar.js.flow +1 -1
- package/src/integration_tests/basic_bundle/ErrorBundle.js +2 -2
- package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +1 -1
- package/src/integration_tests/basic_bundle/Foo.js +2 -2
- package/src/integration_tests/basic_bundle/Foo.js.flow +1 -1
- package/src/integration_tests/basic_bundle/TestBundle.js +2 -2
- package/src/integration_tests/basic_bundle/TestBundle.js.flow +1 -1
- package/src/integration_tests/basic_bundle/TestPolyfill.js +1 -1
- package/src/integration_tests/basic_bundle/TestPolyfill.js.flow +1 -1
- package/src/integration_tests/basic_bundle/TypeScript.ts +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-1.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-1.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-2.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-2.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-3.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-3.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-4.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-4.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-5.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-5.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-6.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-6.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-null.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-null.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/index.js +17 -17
- package/src/integration_tests/basic_bundle/import-export/index.js.flow +1 -1
- package/src/integration_tests/basic_bundle/polyfill.js +1 -1
- package/src/integration_tests/execBundle.js +2 -2
- package/src/integration_tests/execBundle.js.flow +1 -1
- package/src/integration_tests/metro.config.js +8 -8
- package/src/lib/BatchProcessor.js +10 -6
- package/src/lib/BatchProcessor.js.flow +6 -1
- package/src/lib/JsonReporter.js +3 -2
- package/src/lib/JsonReporter.js.flow +2 -1
- package/src/lib/RamBundleParser.js +1 -1
- package/src/lib/RamBundleParser.js.flow +1 -1
- package/src/lib/TerminalReporter.js +15 -15
- package/src/lib/TerminalReporter.js.flow +15 -16
- package/src/lib/bundleToBytecode.js +6 -7
- package/src/lib/bundleToBytecode.js.flow +8 -7
- package/src/lib/bundleToString.js +3 -3
- package/src/lib/bundleToString.js.flow +5 -4
- package/src/lib/countLines.js +3 -7
- package/src/lib/countLines.js.flow +4 -7
- package/src/lib/createModuleIdFactory.js +2 -2
- package/src/lib/createModuleIdFactory.js.flow +1 -1
- package/src/lib/{attachWebsocketServer.js → createWebsocketServer.js} +18 -17
- package/src/lib/{attachWebsocketServer.js.flow → createWebsocketServer.js.flow} +13 -23
- package/src/lib/debounceAsyncQueue.js +2 -2
- package/src/lib/debounceAsyncQueue.js.flow +1 -1
- package/src/lib/formatBundlingError.js +21 -21
- package/src/lib/formatBundlingError.js.flow +18 -20
- package/src/lib/getAppendScripts.js +26 -27
- package/src/lib/getAppendScripts.js.flow +7 -8
- package/src/lib/getGraphId.js +3 -3
- package/src/lib/getGraphId.js.flow +3 -3
- package/src/lib/getMaxWorkers.js +2 -2
- package/src/lib/getMaxWorkers.js.flow +1 -1
- package/src/lib/getPreludeCode.js +2 -2
- package/src/lib/getPreludeCode.js.flow +1 -1
- package/src/lib/getPrependedScripts.js +16 -15
- package/src/lib/getPrependedScripts.js.flow +8 -8
- package/src/lib/logToConsole.js +12 -5
- package/src/lib/logToConsole.js.flow +19 -6
- package/src/lib/parseCustomTransformOptions.js +2 -2
- package/src/lib/parseCustomTransformOptions.js.flow +3 -3
- package/src/lib/parseOptionsFromUrl.js +7 -7
- package/src/lib/parseOptionsFromUrl.js.flow +29 -9
- package/src/lib/relativizeSourceMap.js +1 -1
- package/src/lib/relativizeSourceMap.js.flow +3 -3
- package/src/lib/reporting.js +5 -5
- package/src/lib/reporting.js.flow +18 -4
- package/src/lib/splitBundleOptions.js +5 -5
- package/src/lib/splitBundleOptions.js.flow +1 -1
- package/src/lib/transformHelpers.js +11 -10
- package/src/lib/transformHelpers.js.flow +6 -13
- package/src/node-haste/DependencyGraph/ModuleResolution.js +51 -30
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +49 -48
- package/src/node-haste/DependencyGraph/createHasteMap.js +99 -0
- package/src/node-haste/DependencyGraph/createHasteMap.js.flow +88 -0
- package/src/node-haste/DependencyGraph/{assets/empty-module.js → types.js} +2 -2
- package/src/node-haste/DependencyGraph/types.js.flow +88 -0
- package/src/node-haste/DependencyGraph.js +51 -118
- package/src/node-haste/DependencyGraph.js.flow +38 -111
- package/src/node-haste/Module.js +1 -1
- package/src/node-haste/Module.js.flow +3 -3
- package/src/node-haste/ModuleCache.js +54 -13
- package/src/node-haste/ModuleCache.js.flow +53 -12
- package/src/node-haste/Package.js +2 -2
- package/src/node-haste/Package.js.flow +1 -1
- package/src/node-haste/lib/AssetPaths.js +5 -5
- package/src/node-haste/lib/AssetPaths.js.flow +7 -6
- package/src/node-haste/lib/parsePlatformFilePath.js +4 -4
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +2 -2
- package/src/shared/output/RamBundle/as-assets.js +14 -15
- package/src/shared/output/RamBundle/as-assets.js.flow +9 -11
- package/src/shared/output/RamBundle/as-indexed-file.js +14 -15
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +8 -12
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js +7 -7
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +4 -4
- package/src/shared/output/RamBundle/magic-number.js +1 -1
- package/src/shared/output/RamBundle/magic-number.js.flow +1 -1
- package/src/shared/output/RamBundle/util.js +21 -19
- package/src/shared/output/RamBundle/util.js.flow +5 -8
- package/src/shared/output/RamBundle/write-sourcemap.js +1 -1
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
- package/src/shared/output/RamBundle.js +2 -2
- package/src/shared/output/RamBundle.js.flow +4 -5
- package/src/shared/output/bundle.js +6 -6
- package/src/shared/output/bundle.js.flow +4 -5
- package/src/shared/output/meta.js +4 -5
- package/src/shared/output/meta.js.flow +2 -4
- package/src/shared/output/unbundle.js +1 -1
- package/src/shared/output/unbundle.js.flow +1 -1
- package/src/shared/output/writeFile.js +1 -1
- package/src/shared/output/writeFile.js.flow +1 -1
- package/src/shared/types.flow.js +1 -1
- package/src/shared/types.flow.js.flow +6 -4
- package/src/node-haste/DependencyGraph/assets/empty-module.js.flow +0 -9
- package/src/node-haste/types.js +0 -10
- package/src/node-haste/types.js.flow +0 -23
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -8,40 +8,39 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
import type {Moduleish} from '../../node-haste/DependencyGraph/ModuleResolution';
|
|
12
|
+
import type {ResolveFn, TransformedCodeFile} from '../types.flow';
|
|
13
|
+
import type {Extensions, Path} from './node-haste.flow';
|
|
14
|
+
import type {CustomResolver} from 'metro-resolver';
|
|
12
15
|
|
|
16
|
+
import {ModuleMap} from 'jest-haste-map';
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
ModuleResolver,
|
|
20
|
+
} = require('../../node-haste/DependencyGraph/ModuleResolution');
|
|
21
|
+
const parsePlatformFilePath = require('../../node-haste/lib/parsePlatformFilePath');
|
|
13
22
|
const HasteFS = require('./HasteFS');
|
|
14
23
|
const Module = require('./Module');
|
|
15
24
|
const ModuleCache = require('./ModuleCache');
|
|
16
|
-
|
|
17
25
|
const defaults = require('metro-config/src/defaults/defaults');
|
|
18
|
-
const parsePlatformFilePath = require('../../node-haste/lib/parsePlatformFilePath');
|
|
19
26
|
const path = require('path');
|
|
20
27
|
|
|
21
|
-
const {
|
|
22
|
-
ModuleResolver,
|
|
23
|
-
} = require('../../node-haste/DependencyGraph/ModuleResolution');
|
|
24
|
-
const {ModuleMap} = require('jest-haste-map');
|
|
25
|
-
|
|
26
|
-
import type {Moduleish} from '../../node-haste/DependencyGraph/ModuleResolution';
|
|
27
|
-
import type {ResolveFn, TransformedCodeFile} from '../types.flow';
|
|
28
|
-
import type {Extensions, Path} from './node-haste.flow';
|
|
29
|
-
import type {CustomResolver} from 'metro-resolver';
|
|
30
|
-
|
|
31
28
|
type ResolveOptions = {|
|
|
32
|
-
+platform: string,
|
|
33
|
-
+sourceExts: Extensions,
|
|
34
29
|
assetExts: Extensions,
|
|
35
30
|
assetResolutions: $ReadOnlyArray<string>,
|
|
31
|
+
+disableHierarchicalLookup: boolean,
|
|
32
|
+
+emptyModulePath: string,
|
|
36
33
|
extraNodeModules: {[id: string]: string, ...},
|
|
37
34
|
mainFields: $ReadOnlyArray<string>,
|
|
38
35
|
nodeModulesPaths: $ReadOnlyArray<string>,
|
|
36
|
+
+platform: string,
|
|
37
|
+
platforms?: $ReadOnlyArray<string>,
|
|
39
38
|
resolveRequest?: ?CustomResolver,
|
|
39
|
+
+sourceExts: Extensions,
|
|
40
40
|
transformedFiles: {[path: Path]: TransformedCodeFile, ...},
|
|
41
41
|
|};
|
|
42
42
|
|
|
43
|
-
const
|
|
44
|
-
|
|
43
|
+
const NATIVE_PLATFORM = 'native';
|
|
45
44
|
const GENERIC_PLATFORM = 'g';
|
|
46
45
|
const PACKAGE_JSON = path.sep + 'package.json';
|
|
47
46
|
const NULL_MODULE: Moduleish = {
|
|
@@ -59,7 +58,11 @@ const NODE_MODULES = path.sep + 'node_modules' + path.sep;
|
|
|
59
58
|
const isNodeModules = file => file.includes(NODE_MODULES);
|
|
60
59
|
|
|
61
60
|
// This function maps the ModuleGraph data structure to jest-haste-map's ModuleMap
|
|
62
|
-
const createModuleMap = ({files, moduleCache, sourceExts}) => {
|
|
61
|
+
const createModuleMap = ({files, moduleCache, sourceExts, platforms}) => {
|
|
62
|
+
const platformSet = new Set(
|
|
63
|
+
(platforms ?? defaults.platforms).concat([NATIVE_PLATFORM]),
|
|
64
|
+
);
|
|
65
|
+
|
|
63
66
|
const map = new Map();
|
|
64
67
|
|
|
65
68
|
files.forEach((filePath: string) => {
|
|
@@ -83,7 +86,7 @@ const createModuleMap = ({files, moduleCache, sourceExts}) => {
|
|
|
83
86
|
const mapModule = map.get(id) || Object.create(null);
|
|
84
87
|
|
|
85
88
|
const platform =
|
|
86
|
-
parsePlatformFilePath(filePath,
|
|
89
|
+
parsePlatformFilePath(filePath, platformSet).platform || GENERIC_PLATFORM;
|
|
87
90
|
|
|
88
91
|
const existingModule = mapModule[platform];
|
|
89
92
|
// 0 = Module, 1 = Package in jest-haste-map
|
|
@@ -107,7 +110,7 @@ const createModuleMap = ({files, moduleCache, sourceExts}) => {
|
|
|
107
110
|
return map;
|
|
108
111
|
};
|
|
109
112
|
|
|
110
|
-
exports.createResolveFn = function(options: ResolveOptions): ResolveFn {
|
|
113
|
+
exports.createResolveFn = function (options: ResolveOptions): ResolveFn {
|
|
111
114
|
const {
|
|
112
115
|
assetExts,
|
|
113
116
|
assetResolutions,
|
|
@@ -115,6 +118,7 @@ exports.createResolveFn = function(options: ResolveOptions): ResolveFn {
|
|
|
115
118
|
transformedFiles,
|
|
116
119
|
sourceExts,
|
|
117
120
|
platform,
|
|
121
|
+
platforms,
|
|
118
122
|
} = options;
|
|
119
123
|
const files = Object.keys(transformedFiles);
|
|
120
124
|
function getTransformedFile(path: string): TransformedCodeFile {
|
|
@@ -136,7 +140,9 @@ exports.createResolveFn = function(options: ResolveOptions): ResolveFn {
|
|
|
136
140
|
|
|
137
141
|
const moduleResolver = new ModuleResolver({
|
|
138
142
|
dirExists: (filePath: string): boolean => hasteFS.dirExists(filePath),
|
|
143
|
+
disableHierarchicalLookup: options.disableHierarchicalLookup,
|
|
139
144
|
doesFileExist: (filePath: string): boolean => hasteFS.exists(filePath),
|
|
145
|
+
emptyModulePath: options.emptyModulePath,
|
|
140
146
|
extraNodeModules,
|
|
141
147
|
isAssetFile,
|
|
142
148
|
mainFields: options.mainFields,
|
|
@@ -144,7 +150,7 @@ exports.createResolveFn = function(options: ResolveOptions): ResolveFn {
|
|
|
144
150
|
moduleCache,
|
|
145
151
|
moduleMap: new ModuleMap({
|
|
146
152
|
duplicates: new Map(),
|
|
147
|
-
map: createModuleMap({files, moduleCache, sourceExts}),
|
|
153
|
+
map: createModuleMap({files, moduleCache, sourceExts, platforms}),
|
|
148
154
|
mocks: new Map(),
|
|
149
155
|
rootDir: '',
|
|
150
156
|
}),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -9,19 +9,19 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
-
const buildSourcemapWithMetadata = require("../../shared/output/RamBundle/buildSourcemapWithMetadata.js");
|
|
13
|
-
|
|
14
|
-
const invariant = require("invariant");
|
|
15
|
-
|
|
16
12
|
const { createRamBundleGroups } = require("../../Bundler/util");
|
|
17
13
|
|
|
18
14
|
const {
|
|
19
15
|
buildTableAndContents,
|
|
20
|
-
createModuleGroups
|
|
16
|
+
createModuleGroups,
|
|
21
17
|
} = require("../../shared/output/RamBundle/as-indexed-file");
|
|
22
18
|
|
|
19
|
+
const buildSourcemapWithMetadata = require("../../shared/output/RamBundle/buildSourcemapWithMetadata.js");
|
|
20
|
+
|
|
23
21
|
const { getModuleCodeAndMap, partition, toModuleTransport } = require("./util");
|
|
24
22
|
|
|
23
|
+
const invariant = require("invariant");
|
|
24
|
+
|
|
25
25
|
function asIndexedRamBundle({
|
|
26
26
|
dependencyMapReservedName,
|
|
27
27
|
filename,
|
|
@@ -30,16 +30,16 @@ function asIndexedRamBundle({
|
|
|
30
30
|
modules,
|
|
31
31
|
preloadedModules,
|
|
32
32
|
ramGroupHeads,
|
|
33
|
-
requireCalls
|
|
33
|
+
requireCalls,
|
|
34
34
|
}) {
|
|
35
|
-
const idForPath = x => idsForPath(x).moduleId;
|
|
35
|
+
const idForPath = (x) => idsForPath(x).moduleId;
|
|
36
36
|
|
|
37
37
|
const [startup, deferred] = partition(modules, preloadedModules);
|
|
38
38
|
const startupModules = [...startup, ...requireCalls];
|
|
39
|
-
const deferredModules = deferred.map(m =>
|
|
39
|
+
const deferredModules = deferred.map((m) =>
|
|
40
40
|
toModuleTransport(m, idsForPath, {
|
|
41
41
|
dependencyMapReservedName,
|
|
42
|
-
globalPrefix
|
|
42
|
+
globalPrefix,
|
|
43
43
|
})
|
|
44
44
|
);
|
|
45
45
|
|
|
@@ -60,11 +60,11 @@ function asIndexedRamBundle({
|
|
|
60
60
|
const tableAndContents = buildTableAndContents(
|
|
61
61
|
startupModules
|
|
62
62
|
.map(
|
|
63
|
-
m =>
|
|
63
|
+
(m) =>
|
|
64
64
|
getModuleCodeAndMap(m, idForPath, {
|
|
65
65
|
dependencyMapReservedName,
|
|
66
66
|
enableIDInlining: true,
|
|
67
|
-
globalPrefix
|
|
67
|
+
globalPrefix,
|
|
68
68
|
}).moduleCode
|
|
69
69
|
)
|
|
70
70
|
.join("\n"),
|
|
@@ -78,13 +78,13 @@ function asIndexedRamBundle({
|
|
|
78
78
|
fixWrapperOffset: false,
|
|
79
79
|
lazyModules: deferredModules,
|
|
80
80
|
moduleGroups,
|
|
81
|
-
startupModules: startupModules.map(m =>
|
|
81
|
+
startupModules: startupModules.map((m) =>
|
|
82
82
|
toModuleTransport(m, idsForPath, {
|
|
83
83
|
dependencyMapReservedName,
|
|
84
|
-
globalPrefix
|
|
84
|
+
globalPrefix,
|
|
85
85
|
})
|
|
86
|
-
)
|
|
87
|
-
})
|
|
86
|
+
),
|
|
87
|
+
}),
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -102,7 +102,7 @@ function* subtree(moduleTransport, moduleTransportsByPath, seen = new Set()) {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
function createBuilder(preloadedModules, ramGroupHeads) {
|
|
105
|
-
return x => asIndexedRamBundle({ ...x, preloadedModules, ramGroupHeads });
|
|
105
|
+
return (x) => asIndexedRamBundle({ ...x, preloadedModules, ramGroupHeads });
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
exports.createBuilder = createBuilder;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -9,19 +9,20 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
|
+
import type {IdsForPathFn, Dependency} from '../types.flow';
|
|
13
|
+
import type {BasicSourceMap} from '../../../../metro-source-map/src/source-map';
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
import type {Module, OutputFn, OutputFnArg} from '../types.flow';
|
|
16
|
+
import type {IndexMap} from 'metro-source-map';
|
|
15
17
|
|
|
16
18
|
const {createRamBundleGroups} = require('../../Bundler/util');
|
|
17
19
|
const {
|
|
18
20
|
buildTableAndContents,
|
|
19
21
|
createModuleGroups,
|
|
20
22
|
} = require('../../shared/output/RamBundle/as-indexed-file');
|
|
23
|
+
const buildSourcemapWithMetadata = require('../../shared/output/RamBundle/buildSourcemapWithMetadata.js');
|
|
21
24
|
const {getModuleCodeAndMap, partition, toModuleTransport} = require('./util');
|
|
22
|
-
|
|
23
|
-
import type {Module, OutputFn, OutputFnArg} from '../types.flow';
|
|
24
|
-
import type {IndexMap} from 'metro-source-map';
|
|
25
|
+
const invariant = require('invariant');
|
|
25
26
|
|
|
26
27
|
function asIndexedRamBundle({
|
|
27
28
|
dependencyMapReservedName,
|
|
@@ -32,7 +33,19 @@ function asIndexedRamBundle({
|
|
|
32
33
|
preloadedModules,
|
|
33
34
|
ramGroupHeads,
|
|
34
35
|
requireCalls,
|
|
35
|
-
}
|
|
36
|
+
}: $TEMPORARY$object<{
|
|
37
|
+
dependencyMapReservedName?: ?string,
|
|
38
|
+
enableIDInlining: boolean,
|
|
39
|
+
filename: string,
|
|
40
|
+
globalPrefix: string,
|
|
41
|
+
idsForPath: IdsForPathFn,
|
|
42
|
+
modules: Iterable<Module>,
|
|
43
|
+
preloadedModules: Set<string>,
|
|
44
|
+
ramGroupHeads: ?$ReadOnlyArray<string>,
|
|
45
|
+
requireCalls: Iterable<Module>,
|
|
46
|
+
segmentID: number,
|
|
47
|
+
sourceMapPath?: ?string,
|
|
48
|
+
}>): {|
|
|
36
49
|
code: string | Buffer,
|
|
37
50
|
extraFiles?: Iterable<[string, string | Buffer]>,
|
|
38
51
|
map: IndexMap,
|
|
@@ -90,8 +103,27 @@ function asIndexedRamBundle({
|
|
|
90
103
|
}
|
|
91
104
|
|
|
92
105
|
function* subtree(
|
|
93
|
-
moduleTransport
|
|
94
|
-
|
|
106
|
+
moduleTransport: {
|
|
107
|
+
code: string,
|
|
108
|
+
dependencies: Array<Dependency>,
|
|
109
|
+
id: number,
|
|
110
|
+
map: ?BasicSourceMap,
|
|
111
|
+
name: string,
|
|
112
|
+
sourcePath: string,
|
|
113
|
+
...
|
|
114
|
+
},
|
|
115
|
+
moduleTransportsByPath: Map<
|
|
116
|
+
string,
|
|
117
|
+
{
|
|
118
|
+
code: string,
|
|
119
|
+
dependencies: Array<Dependency>,
|
|
120
|
+
id: number,
|
|
121
|
+
map: ?BasicSourceMap,
|
|
122
|
+
name: string,
|
|
123
|
+
sourcePath: string,
|
|
124
|
+
...
|
|
125
|
+
},
|
|
126
|
+
>,
|
|
95
127
|
seen: Set<number> = new Set(),
|
|
96
128
|
): Generator<number, void, void> {
|
|
97
129
|
seen.add(moduleTransport.id);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -9,16 +9,16 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const buildSourcemapWithMetadata = require("../../shared/output/RamBundle/buildSourcemapWithMetadata.js");
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
const JS_MODULES = "js-modules";
|
|
14
|
+
const MAGIC_UNBUNDLE_NUMBER = require("../../shared/output/RamBundle/magic-number");
|
|
16
15
|
|
|
17
|
-
const
|
|
16
|
+
const { getModuleCodeAndMap, partition, toModuleTransport } = require("./util");
|
|
18
17
|
|
|
19
18
|
const path = require("path");
|
|
20
19
|
|
|
21
|
-
const
|
|
20
|
+
const MAGIC_UNBUNDLE_FILENAME = "UNBUNDLE";
|
|
21
|
+
const JS_MODULES = "js-modules";
|
|
22
22
|
|
|
23
23
|
function asMultipleFilesRamBundle({
|
|
24
24
|
dependencyMapReservedName,
|
|
@@ -27,33 +27,33 @@ function asMultipleFilesRamBundle({
|
|
|
27
27
|
idsForPath,
|
|
28
28
|
modules,
|
|
29
29
|
requireCalls,
|
|
30
|
-
preloadedModules
|
|
30
|
+
preloadedModules,
|
|
31
31
|
}) {
|
|
32
|
-
const idForPath = x => idsForPath(x).moduleId;
|
|
32
|
+
const idForPath = (x) => idsForPath(x).moduleId;
|
|
33
33
|
|
|
34
34
|
const [startup, deferred] = partition(modules, preloadedModules);
|
|
35
35
|
const startupModules = [...startup, ...requireCalls];
|
|
36
|
-
const deferredModules = deferred.map(m =>
|
|
36
|
+
const deferredModules = deferred.map((m) =>
|
|
37
37
|
toModuleTransport(m, idsForPath, {
|
|
38
38
|
dependencyMapReservedName,
|
|
39
|
-
globalPrefix
|
|
39
|
+
globalPrefix,
|
|
40
40
|
})
|
|
41
41
|
);
|
|
42
42
|
const magicFileContents = Buffer.alloc(4); // Just concatenate all startup modules, one after the other.
|
|
43
43
|
|
|
44
44
|
const code = startupModules
|
|
45
45
|
.map(
|
|
46
|
-
m =>
|
|
46
|
+
(m) =>
|
|
47
47
|
getModuleCodeAndMap(m, idForPath, {
|
|
48
48
|
dependencyMapReservedName,
|
|
49
49
|
enableIDInlining: true,
|
|
50
|
-
globalPrefix
|
|
50
|
+
globalPrefix,
|
|
51
51
|
}).moduleCode
|
|
52
52
|
)
|
|
53
53
|
.join("\n"); // Write one file per module, wrapped with __d() call if it proceeds.
|
|
54
54
|
|
|
55
55
|
const extraFiles = new Map();
|
|
56
|
-
deferredModules.forEach(deferredModule => {
|
|
56
|
+
deferredModules.forEach((deferredModule) => {
|
|
57
57
|
extraFiles.set(
|
|
58
58
|
path.join(JS_MODULES, deferredModule.id + ".js"),
|
|
59
59
|
deferredModule.code
|
|
@@ -70,22 +70,22 @@ function asMultipleFilesRamBundle({
|
|
|
70
70
|
fixWrapperOffset: false,
|
|
71
71
|
lazyModules: deferredModules,
|
|
72
72
|
moduleGroups: null,
|
|
73
|
-
startupModules: startupModules.map(m =>
|
|
73
|
+
startupModules: startupModules.map((m) =>
|
|
74
74
|
toModuleTransport(m, idsForPath, {
|
|
75
75
|
dependencyMapReservedName,
|
|
76
|
-
globalPrefix
|
|
76
|
+
globalPrefix,
|
|
77
77
|
})
|
|
78
|
-
)
|
|
78
|
+
),
|
|
79
79
|
});
|
|
80
80
|
return {
|
|
81
81
|
code,
|
|
82
82
|
extraFiles,
|
|
83
|
-
map
|
|
83
|
+
map,
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
function createBuilder(preloadedModules, ramGroupHeads) {
|
|
88
|
-
return x =>
|
|
88
|
+
return (x) =>
|
|
89
89
|
asMultipleFilesRamBundle({ ...x, preloadedModules, ramGroupHeads });
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -9,18 +9,18 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
|
+
import type {IdsForPathFn} from '../types.flow';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const JS_MODULES = 'js-modules';
|
|
14
|
+
import type {Module, OutputFn, OutputFnArg, OutputResult} from '../types.flow';
|
|
15
|
+
import type {IndexMap} from 'metro-source-map';
|
|
16
16
|
|
|
17
17
|
const buildSourcemapWithMetadata = require('../../shared/output/RamBundle/buildSourcemapWithMetadata.js');
|
|
18
|
-
const
|
|
19
|
-
|
|
18
|
+
const MAGIC_UNBUNDLE_NUMBER = require('../../shared/output/RamBundle/magic-number');
|
|
20
19
|
const {getModuleCodeAndMap, partition, toModuleTransport} = require('./util');
|
|
20
|
+
const path = require('path');
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const MAGIC_UNBUNDLE_FILENAME = 'UNBUNDLE';
|
|
23
|
+
const JS_MODULES = 'js-modules';
|
|
24
24
|
|
|
25
25
|
function asMultipleFilesRamBundle({
|
|
26
26
|
dependencyMapReservedName,
|
|
@@ -30,7 +30,19 @@ function asMultipleFilesRamBundle({
|
|
|
30
30
|
modules,
|
|
31
31
|
requireCalls,
|
|
32
32
|
preloadedModules,
|
|
33
|
-
}
|
|
33
|
+
}: $TEMPORARY$object<{
|
|
34
|
+
dependencyMapReservedName?: ?string,
|
|
35
|
+
enableIDInlining: boolean,
|
|
36
|
+
filename: string,
|
|
37
|
+
globalPrefix: string,
|
|
38
|
+
idsForPath: IdsForPathFn,
|
|
39
|
+
modules: Iterable<Module>,
|
|
40
|
+
preloadedModules: Set<string>,
|
|
41
|
+
ramGroupHeads: ?$ReadOnlyArray<string>,
|
|
42
|
+
requireCalls: Iterable<Module>,
|
|
43
|
+
segmentID: number,
|
|
44
|
+
sourceMapPath?: ?string,
|
|
45
|
+
}>): OutputResult<IndexMap> {
|
|
34
46
|
const idForPath = (x: {path: string, ...}) => idsForPath(x).moduleId;
|
|
35
47
|
const [startup, deferred] = partition(modules, preloadedModules);
|
|
36
48
|
const startupModules = [...startup, ...requireCalls];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
const meta = require("../../shared/output/meta");
|
|
13
13
|
|
|
14
|
-
const {
|
|
14
|
+
const { concat, getModuleCodeAndMap } = require("./util");
|
|
15
15
|
|
|
16
16
|
const { BundleBuilder } = require("metro-source-map");
|
|
17
17
|
|
|
@@ -23,11 +23,11 @@ function asPlainBundle({
|
|
|
23
23
|
modules,
|
|
24
24
|
requireCalls,
|
|
25
25
|
sourceMapPath,
|
|
26
|
-
enableIDInlining
|
|
26
|
+
enableIDInlining,
|
|
27
27
|
}) {
|
|
28
28
|
const builder = new BundleBuilder(filename);
|
|
29
29
|
|
|
30
|
-
const modIdForPath = x => idsForPath(x).moduleId;
|
|
30
|
+
const modIdForPath = (x) => idsForPath(x).moduleId;
|
|
31
31
|
|
|
32
32
|
for (const module of concat(modules, requireCalls)) {
|
|
33
33
|
const { moduleCode, moduleMap } = getModuleCodeAndMap(
|
|
@@ -36,7 +36,7 @@ function asPlainBundle({
|
|
|
36
36
|
{
|
|
37
37
|
dependencyMapReservedName,
|
|
38
38
|
enableIDInlining,
|
|
39
|
-
globalPrefix
|
|
39
|
+
globalPrefix,
|
|
40
40
|
}
|
|
41
41
|
);
|
|
42
42
|
builder.append(moduleCode + "\n", moduleMap);
|
|
@@ -51,7 +51,7 @@ function asPlainBundle({
|
|
|
51
51
|
return {
|
|
52
52
|
code,
|
|
53
53
|
extraFiles: [[`${filename}.meta`, meta(code)]],
|
|
54
|
-
map
|
|
54
|
+
map,
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
|
-
|
|
13
|
-
const meta = require('../../shared/output/meta');
|
|
14
|
-
|
|
15
|
-
const {getModuleCodeAndMap, concat} = require('./util');
|
|
16
|
-
const {BundleBuilder} = require('metro-source-map');
|
|
12
|
+
import type {OutputFnArg} from '../types.flow';
|
|
17
13
|
|
|
18
14
|
import type {OutputFn} from '../types.flow';
|
|
19
15
|
import type {MixedSourceMap} from 'metro-source-map';
|
|
20
16
|
|
|
17
|
+
const meta = require('../../shared/output/meta');
|
|
18
|
+
const {concat, getModuleCodeAndMap} = require('./util');
|
|
19
|
+
const {BundleBuilder} = require('metro-source-map');
|
|
20
|
+
|
|
21
21
|
function asPlainBundle({
|
|
22
22
|
dependencyMapReservedName,
|
|
23
23
|
filename,
|
|
@@ -27,7 +27,7 @@ function asPlainBundle({
|
|
|
27
27
|
requireCalls,
|
|
28
28
|
sourceMapPath,
|
|
29
29
|
enableIDInlining,
|
|
30
|
-
}): {|
|
|
30
|
+
}: OutputFnArg): {|
|
|
31
31
|
code: string | Buffer,
|
|
32
32
|
extraFiles?: Iterable<[string, string | Buffer]>,
|
|
33
33
|
map: MixedSourceMap,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -60,8 +60,8 @@ function reverseDependencyMapReferences({ types: t }) {
|
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
13
|
import type {NodePath} from '@babel/traverse';
|
|
14
|
-
import typeof * as Types from '@babel/types';
|
|
15
14
|
import type {CallExpression} from '@babel/types';
|
|
15
|
+
import typeof * as Types from '@babel/types';
|
|
16
|
+
|
|
16
17
|
import invariant from 'invariant';
|
|
17
18
|
import nullthrows from 'nullthrows';
|
|
18
19
|
|
|
@@ -23,12 +24,7 @@ type State = {|
|
|
|
23
24
|
|},
|
|
24
25
|
|};
|
|
25
26
|
|
|
26
|
-
function reverseDependencyMapReferences({
|
|
27
|
-
types: t,
|
|
28
|
-
}: {
|
|
29
|
-
types: Types,
|
|
30
|
-
...
|
|
31
|
-
}): {|
|
|
27
|
+
function reverseDependencyMapReferences({types: t}: {types: Types, ...}): {|
|
|
32
28
|
visitor: {|
|
|
33
29
|
CallExpression: (path: NodePath<CallExpression>, state: State) => void,
|
|
34
30
|
|},
|