metro 0.83.4 → 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 +17 -15
- package/src/Assets.d.ts +83 -0
- package/src/Assets.js +2 -9
- package/src/Bundler/util.d.ts +27 -0
- package/src/Bundler/util.js +2 -9
- package/src/Bundler.d.ts +38 -0
- package/src/Bundler.js +1 -5
- package/src/DeltaBundler/DeltaCalculator.d.ts +71 -0
- package/src/DeltaBundler/DeltaCalculator.js +1 -5
- package/src/DeltaBundler/Graph.d.ts +167 -0
- package/src/DeltaBundler/Graph.js +1 -5
- package/src/DeltaBundler/Serializers/baseJSBundle.d.ts +20 -0
- package/src/DeltaBundler/Serializers/baseJSBundle.js +1 -5
- package/src/DeltaBundler/Serializers/getAllFiles.d.ts +22 -0
- package/src/DeltaBundler/Serializers/getAssets.d.ts +25 -0
- package/src/DeltaBundler/Serializers/getAssets.js +1 -5
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +26 -0
- package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +48 -0
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js +1 -5
- 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 +2 -9
- package/src/DeltaBundler/Serializers/helpers/processModules.d.ts +25 -0
- package/src/DeltaBundler/Serializers/hmrJSBundle.d.ts +30 -0
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +2 -9
- package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +29 -0
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +1 -5
- package/src/DeltaBundler/Serializers/sourceMapObject.d.ts +23 -0
- package/src/DeltaBundler/Serializers/sourceMapString.d.ts +22 -0
- package/src/DeltaBundler/Transformer.d.ts +38 -0
- package/src/DeltaBundler/Transformer.js +1 -5
- package/src/DeltaBundler/Worker.d.ts +37 -0
- package/src/DeltaBundler/Worker.flow.js +1 -5
- package/src/DeltaBundler/WorkerFarm.d.ts +70 -0
- package/src/DeltaBundler/buildSubgraph.d.ts +30 -0
- package/src/DeltaBundler/buildSubgraph.js +1 -5
- package/src/DeltaBundler/getTransformCacheKey.d.ts +18 -0
- package/src/DeltaBundler/getTransformCacheKey.js +1 -5
- package/src/DeltaBundler/mergeDeltas.d.ts +17 -0
- package/src/DeltaBundler/types.d.ts +163 -0
- package/src/DeltaBundler/types.js +1 -5
- package/src/DeltaBundler.d.ts +60 -0
- package/src/DeltaBundler.js +1 -5
- package/src/HmrServer.d.ts +79 -0
- package/src/HmrServer.js +2 -9
- 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 +96 -0
- package/src/IncrementalBundler.js +2 -9
- package/src/ModuleGraph/worker/JsFileWrapping.d.ts +29 -0
- package/src/ModuleGraph/worker/JsFileWrapping.js +2 -9
- package/src/ModuleGraph/worker/collectDependencies.d.ts +131 -0
- package/src/ModuleGraph/worker/collectDependencies.js +2 -9
- package/src/ModuleGraph/worker/generateImportNames.d.ts +19 -0
- package/src/ModuleGraph/worker/generateImportNames.js +1 -5
- package/src/ModuleGraph/worker/importLocationsPlugin.d.ts +26 -0
- package/src/Server/MultipartResponse.d.ts +30 -0
- package/src/Server/MultipartResponse.js +1 -5
- package/src/Server/symbolicate.d.ts +31 -0
- package/src/Server.d.ts +271 -0
- package/src/Server.js +47 -15
- package/src/Server.js.flow +57 -10
- package/src/cli/parseKeyValueParamArray.d.ts +14 -0
- package/src/cli-utils.d.ts +19 -0
- package/src/cli-utils.js +1 -5
- package/src/commands/build.d.ts +16 -0
- package/src/commands/build.js +1 -5
- package/src/commands/dependencies.d.ts +16 -0
- package/src/commands/dependencies.js +1 -5
- package/src/commands/serve.d.ts +16 -0
- package/src/index.d.ts +180 -0
- package/src/index.flow.js +26 -19
- package/src/index.flow.js.flow +25 -10
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js +1 -5
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js +1 -5
- package/src/integration_tests/basic_bundle/import-export/index.js +2 -9
- package/src/integration_tests/execBundle.js +1 -5
- package/src/lib/BatchProcessor.d.ts +54 -0
- package/src/lib/BatchProcessor.js +1 -5
- package/src/lib/CountingSet.d.ts +48 -0
- package/src/lib/JsonReporter.d.ts +37 -0
- package/src/lib/RamBundleParser.d.ts +29 -0
- package/src/lib/RamBundleParser.js +1 -5
- package/src/lib/TerminalReporter.d.ts +118 -0
- package/src/lib/TerminalReporter.js +8 -16
- package/src/lib/TerminalReporter.js.flow +6 -15
- 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 +33 -0
- package/src/lib/contextModule.js +1 -5
- package/src/lib/contextModuleTemplates.d.ts +25 -0
- package/src/lib/contextModuleTemplates.js +1 -4
- package/src/lib/countLines.d.ts +12 -0
- package/src/lib/createWebsocketServer.d.ts +43 -0
- package/src/lib/createWebsocketServer.js +1 -5
- package/src/lib/debounceAsyncQueue.d.ts +15 -0
- package/src/lib/formatBundlingError.d.ts +23 -0
- package/src/lib/formatBundlingError.js +1 -5
- package/src/lib/getAppendScripts.d.ts +31 -0
- package/src/lib/getAppendScripts.js +1 -5
- package/src/lib/getGraphId.d.ts +25 -0
- package/src/lib/getGraphId.js +1 -5
- package/src/lib/getPreludeCode.d.ts +18 -0
- package/src/lib/getPrependedScripts.d.ts +24 -0
- package/src/lib/getPrependedScripts.js +2 -9
- package/src/lib/isResolvedDependency.d.ts +15 -0
- package/src/lib/logToConsole.d.ts +19 -0
- package/src/lib/logToConsole.js +1 -5
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.d.ts +17 -0
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +2 -9
- package/src/lib/parseCustomResolverOptions.d.ts +16 -0
- package/src/lib/parseCustomTransformOptions.d.ts +16 -0
- package/src/lib/parseJsonBody.d.ts +27 -0
- package/src/lib/pathUtils.d.ts +14 -0
- package/src/lib/pathUtils.js +1 -4
- package/src/lib/relativizeSourceMap.d.ts +17 -0
- package/src/lib/relativizeSourceMap.js +1 -5
- package/src/lib/reporting.d.ts +128 -0
- package/src/lib/reporting.js +1 -5
- package/src/lib/splitBundleOptions.d.ts +16 -0
- package/src/lib/transformHelpers.d.ts +35 -0
- package/src/lib/transformHelpers.js +1 -5
- package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +126 -0
- package/src/node-haste/DependencyGraph/ModuleResolution.js +2 -9
- package/src/node-haste/DependencyGraph/createFileMap.d.ts +29 -0
- package/src/node-haste/DependencyGraph/createFileMap.js +2 -9
- package/src/node-haste/DependencyGraph.d.ts +86 -0
- package/src/node-haste/DependencyGraph.js +1 -5
- package/src/node-haste/Package.d.ts +21 -0
- package/src/node-haste/Package.js +1 -5
- package/src/node-haste/PackageCache.d.ts +34 -0
- package/src/node-haste/PackageCache.js +1 -5
- package/src/node-haste/lib/AssetPaths.d.ts +29 -0
- package/src/node-haste/lib/AssetPaths.js +1 -5
- package/src/node-haste/lib/parsePlatformFilePath.d.ts +25 -0
- package/src/node-haste/lib/parsePlatformFilePath.js +1 -5
- package/src/shared/output/RamBundle/as-assets.d.ts +25 -0
- package/src/shared/output/RamBundle/as-assets.js +1 -5
- package/src/shared/output/RamBundle/as-indexed-file.d.ts +38 -0
- package/src/shared/output/RamBundle/as-indexed-file.js +1 -5
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.d.ts +23 -0
- 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 +1 -5
- package/src/shared/output/RamBundle/write-sourcemap.d.ts +16 -0
- package/src/shared/output/RamBundle/write-sourcemap.js +1 -5
- package/src/shared/output/RamBundle.d.ts +26 -0
- package/src/shared/output/RamBundle.js +1 -5
- package/src/shared/output/bundle.d.ts +27 -0
- package/src/shared/output/bundle.flow.js +1 -5
- package/src/shared/output/meta.d.ts +15 -0
- package/src/shared/output/meta.js +1 -5
- package/src/shared/output/unbundle.d.ts +11 -0
- package/src/shared/output/writeFile.d.ts +16 -0
- package/src/shared/output/writeFile.js +1 -5
- package/src/shared/types.d.ts +145 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro",
|
|
3
|
-
"version": "0.83.
|
|
3
|
+
"version": "0.83.5",
|
|
4
4
|
"description": "🚇 The JavaScript bundler for React Native.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": "src/cli.js",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "git
|
|
14
|
+
"url": "git+https://github.com/facebook/metro.git",
|
|
15
|
+
"directory": "packages/metro"
|
|
15
16
|
},
|
|
16
17
|
"scripts": {
|
|
17
18
|
"prepare-release": "test -d build && rm -rf src.real && mv src src.real && mv build src",
|
|
@@ -39,18 +40,18 @@
|
|
|
39
40
|
"jest-worker": "^29.7.0",
|
|
40
41
|
"jsc-safe-url": "^0.2.2",
|
|
41
42
|
"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.
|
|
43
|
+
"metro-babel-transformer": "0.83.5",
|
|
44
|
+
"metro-cache": "0.83.5",
|
|
45
|
+
"metro-cache-key": "0.83.5",
|
|
46
|
+
"metro-config": "0.83.5",
|
|
47
|
+
"metro-core": "0.83.5",
|
|
48
|
+
"metro-file-map": "0.83.5",
|
|
49
|
+
"metro-resolver": "0.83.5",
|
|
50
|
+
"metro-runtime": "0.83.5",
|
|
51
|
+
"metro-source-map": "0.83.5",
|
|
52
|
+
"metro-symbolicate": "0.83.5",
|
|
53
|
+
"metro-transform-plugins": "0.83.5",
|
|
54
|
+
"metro-transform-worker": "0.83.5",
|
|
54
55
|
"mime-types": "^3.0.1",
|
|
55
56
|
"nullthrows": "^1.1.1",
|
|
56
57
|
"serialize-error": "^2.1.0",
|
|
@@ -71,10 +72,11 @@
|
|
|
71
72
|
"dedent": "^0.7.0",
|
|
72
73
|
"jest-snapshot": "^29.7.0",
|
|
73
74
|
"jest-snapshot-serializer-raw": "^1.2.0",
|
|
74
|
-
"metro-babel-register": "0.83.
|
|
75
|
+
"metro-babel-register": "0.83.5",
|
|
75
76
|
"metro-memory-fs": "*",
|
|
76
77
|
"mock-req": "^0.2.0",
|
|
77
78
|
"mock-res": "^0.6.0",
|
|
79
|
+
"selfsigned": "^5.5.0",
|
|
78
80
|
"stack-trace": "^0.0.10"
|
|
79
81
|
},
|
|
80
82
|
"license": "MIT",
|
package/src/Assets.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
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 AssetInfo = {
|
|
12
|
+
readonly files: Array<string>;
|
|
13
|
+
readonly hash: string;
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly scales: Array<number>;
|
|
16
|
+
readonly type: string;
|
|
17
|
+
};
|
|
18
|
+
export type AssetDataWithoutFiles = {
|
|
19
|
+
readonly __packager_asset: boolean;
|
|
20
|
+
readonly fileSystemLocation: string;
|
|
21
|
+
readonly hash: string;
|
|
22
|
+
readonly height: null | undefined | number;
|
|
23
|
+
readonly httpServerLocation: string;
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly scales: Array<number>;
|
|
26
|
+
readonly type: string;
|
|
27
|
+
readonly width: null | undefined | number;
|
|
28
|
+
};
|
|
29
|
+
export type AssetDataFiltered = {
|
|
30
|
+
readonly __packager_asset: boolean;
|
|
31
|
+
readonly hash: string;
|
|
32
|
+
readonly height: null | undefined | number;
|
|
33
|
+
readonly httpServerLocation: string;
|
|
34
|
+
readonly name: string;
|
|
35
|
+
readonly scales: Array<number>;
|
|
36
|
+
readonly type: string;
|
|
37
|
+
readonly width: null | undefined | number;
|
|
38
|
+
};
|
|
39
|
+
export declare function isAssetTypeAnImage(type: string): boolean;
|
|
40
|
+
export declare function getAssetSize(
|
|
41
|
+
type: string,
|
|
42
|
+
content: Buffer,
|
|
43
|
+
filePath: string,
|
|
44
|
+
): null | undefined | {readonly width: number; readonly height: number};
|
|
45
|
+
export type AssetData = AssetDataWithoutFiles & {
|
|
46
|
+
readonly files: Array<string>;
|
|
47
|
+
};
|
|
48
|
+
export type AssetDataPlugin = (
|
|
49
|
+
assetData: AssetData,
|
|
50
|
+
) => AssetData | Promise<AssetData>;
|
|
51
|
+
export declare function getAssetData(
|
|
52
|
+
assetPath: string,
|
|
53
|
+
localPath: string,
|
|
54
|
+
assetDataPlugins: ReadonlyArray<string>,
|
|
55
|
+
platform: null | undefined | string,
|
|
56
|
+
publicPath: string,
|
|
57
|
+
): Promise<AssetData>;
|
|
58
|
+
/**
|
|
59
|
+
* Returns all the associated files (for different resolutions) of an asset.
|
|
60
|
+
**/
|
|
61
|
+
export declare function getAssetFiles(
|
|
62
|
+
assetPath: string,
|
|
63
|
+
platform?: null | undefined | string,
|
|
64
|
+
): Promise<Array<string>>;
|
|
65
|
+
/**
|
|
66
|
+
* Return a buffer with the actual image given a request for an image by path.
|
|
67
|
+
* The relativePath can contain a resolution postfix, in this case we need to
|
|
68
|
+
* find that image (or the closest one to it's resolution) in one of the
|
|
69
|
+
* project roots:
|
|
70
|
+
*
|
|
71
|
+
* 1. We first parse the directory of the asset
|
|
72
|
+
* 2. We then build a map of all assets and their scales in this directory
|
|
73
|
+
* 3. Then try to pick platform-specific asset records
|
|
74
|
+
* 4. Then pick the closest resolution (rounding up) to the requested one
|
|
75
|
+
*/
|
|
76
|
+
export declare function getAsset(
|
|
77
|
+
relativePath: string,
|
|
78
|
+
projectRoot: string,
|
|
79
|
+
watchFolders: ReadonlyArray<string>,
|
|
80
|
+
platform: null | undefined | string,
|
|
81
|
+
assetExts: ReadonlyArray<string>,
|
|
82
|
+
fileExistsInFileMap?: (absolutePath: string) => boolean,
|
|
83
|
+
): Promise<Buffer>;
|
package/src/Assets.js
CHANGED
|
@@ -17,11 +17,7 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
|
17
17
|
var _imageSize = _interopRequireDefault(require("image-size"));
|
|
18
18
|
var _path = _interopRequireDefault(require("path"));
|
|
19
19
|
function _interopRequireDefault(e) {
|
|
20
|
-
return e && e.__esModule
|
|
21
|
-
? e
|
|
22
|
-
: {
|
|
23
|
-
default: e,
|
|
24
|
-
};
|
|
20
|
+
return e && e.__esModule ? e : { default: e };
|
|
25
21
|
}
|
|
26
22
|
function _interopRequireWildcard(e, t) {
|
|
27
23
|
if ("function" == typeof WeakMap)
|
|
@@ -31,10 +27,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
31
27
|
if (!t && e && e.__esModule) return e;
|
|
32
28
|
var o,
|
|
33
29
|
i,
|
|
34
|
-
f = {
|
|
35
|
-
__proto__: null,
|
|
36
|
-
default: e,
|
|
37
|
-
};
|
|
30
|
+
f = { __proto__: null, default: e };
|
|
38
31
|
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
39
32
|
return f;
|
|
40
33
|
if ((o = t ? n : r)) {
|
|
@@ -0,0 +1,27 @@
|
|
|
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 {AssetDataWithoutFiles} from '../Assets';
|
|
12
|
+
import type {ModuleTransportLike} from '../shared/types';
|
|
13
|
+
import type {File} from '@babel/types';
|
|
14
|
+
|
|
15
|
+
type SubTree<T extends ModuleTransportLike> = (
|
|
16
|
+
moduleTransport: T,
|
|
17
|
+
moduleTransportsByPath: Map<string, T>,
|
|
18
|
+
) => Iterable<number>;
|
|
19
|
+
export declare function generateAssetCodeFileAst(
|
|
20
|
+
assetRegistryPath: string,
|
|
21
|
+
assetDescriptor: AssetDataWithoutFiles,
|
|
22
|
+
): File;
|
|
23
|
+
export declare function createRamBundleGroups<T extends ModuleTransportLike>(
|
|
24
|
+
ramGroups: ReadonlyArray<string>,
|
|
25
|
+
groupableModules: ReadonlyArray<T>,
|
|
26
|
+
subtree: SubTree<T>,
|
|
27
|
+
): Map<number, Set<number>>;
|
package/src/Bundler/util.js
CHANGED
|
@@ -9,11 +9,7 @@ var babylon = _interopRequireWildcard(require("@babel/parser"));
|
|
|
9
9
|
var _template = _interopRequireDefault(require("@babel/template"));
|
|
10
10
|
var babelTypes = _interopRequireWildcard(require("@babel/types"));
|
|
11
11
|
function _interopRequireDefault(e) {
|
|
12
|
-
return e && e.__esModule
|
|
13
|
-
? e
|
|
14
|
-
: {
|
|
15
|
-
default: e,
|
|
16
|
-
};
|
|
12
|
+
return e && e.__esModule ? e : { default: e };
|
|
17
13
|
}
|
|
18
14
|
function _interopRequireWildcard(e, t) {
|
|
19
15
|
if ("function" == typeof WeakMap)
|
|
@@ -23,10 +19,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
23
19
|
if (!t && e && e.__esModule) return e;
|
|
24
20
|
var o,
|
|
25
21
|
i,
|
|
26
|
-
f = {
|
|
27
|
-
__proto__: null,
|
|
28
|
-
default: e,
|
|
29
|
-
};
|
|
22
|
+
f = { __proto__: null, default: e };
|
|
30
23
|
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
31
24
|
return f;
|
|
32
25
|
if ((o = t ? n : r)) {
|
package/src/Bundler.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
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 {TransformResultWithSource} from './DeltaBundler';
|
|
12
|
+
import type {TransformOptions} from './DeltaBundler/Worker';
|
|
13
|
+
import type EventEmitter from 'events';
|
|
14
|
+
import type {ConfigT} from 'metro-config';
|
|
15
|
+
|
|
16
|
+
import Transformer from './DeltaBundler/Transformer';
|
|
17
|
+
import DependencyGraph from './node-haste/DependencyGraph';
|
|
18
|
+
|
|
19
|
+
export type BundlerOptions = Readonly<{
|
|
20
|
+
hasReducedPerformance?: boolean;
|
|
21
|
+
watch?: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
declare class Bundler {
|
|
24
|
+
_depGraph: DependencyGraph;
|
|
25
|
+
_initializedPromise: Promise<void>;
|
|
26
|
+
_transformer: Transformer;
|
|
27
|
+
constructor(config: ConfigT, options?: BundlerOptions);
|
|
28
|
+
getWatcher(): EventEmitter;
|
|
29
|
+
end(): Promise<void>;
|
|
30
|
+
getDependencyGraph(): Promise<DependencyGraph>;
|
|
31
|
+
transformFile(
|
|
32
|
+
filePath: string,
|
|
33
|
+
transformOptions: TransformOptions,
|
|
34
|
+
fileBuffer?: Buffer,
|
|
35
|
+
): Promise<TransformResultWithSource>;
|
|
36
|
+
ready(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export default Bundler;
|
package/src/Bundler.js
CHANGED
|
@@ -11,11 +11,7 @@ var _DependencyGraph = _interopRequireDefault(
|
|
|
11
11
|
require("./node-haste/DependencyGraph"),
|
|
12
12
|
);
|
|
13
13
|
function _interopRequireDefault(e) {
|
|
14
|
-
return e && e.__esModule
|
|
15
|
-
? e
|
|
16
|
-
: {
|
|
17
|
-
default: e,
|
|
18
|
-
};
|
|
14
|
+
return e && e.__esModule ? e : { default: e };
|
|
19
15
|
}
|
|
20
16
|
class Bundler {
|
|
21
17
|
constructor(config, options) {
|
|
@@ -0,0 +1,71 @@
|
|
|
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 {DeltaResult, Options} from './types';
|
|
12
|
+
import type {RootPerfLogger} from 'metro-config';
|
|
13
|
+
import type {ChangeEvent} from 'metro-file-map';
|
|
14
|
+
|
|
15
|
+
import {Graph} from './Graph';
|
|
16
|
+
import EventEmitter from 'events';
|
|
17
|
+
/**
|
|
18
|
+
* This class is in charge of calculating the delta of changed modules that
|
|
19
|
+
* happen between calls. To do so, it subscribes to file changes, so it can
|
|
20
|
+
* traverse the files that have been changed between calls and avoid having to
|
|
21
|
+
* traverse the whole dependency tree for trivial small changes.
|
|
22
|
+
*/
|
|
23
|
+
declare class DeltaCalculator<T> extends EventEmitter {
|
|
24
|
+
_changeEventSource: EventEmitter;
|
|
25
|
+
_options: Options<T>;
|
|
26
|
+
_currentBuildPromise: null | undefined | Promise<DeltaResult<T>>;
|
|
27
|
+
_deletedFiles: Set<string>;
|
|
28
|
+
_modifiedFiles: Set<string>;
|
|
29
|
+
_addedFiles: Set<string>;
|
|
30
|
+
_requiresReset: boolean;
|
|
31
|
+
_graph: Graph<T>;
|
|
32
|
+
constructor(
|
|
33
|
+
entryPoints: ReadonlySet<string>,
|
|
34
|
+
changeEventSource: EventEmitter,
|
|
35
|
+
options: Options<T>,
|
|
36
|
+
);
|
|
37
|
+
/**
|
|
38
|
+
* Stops listening for file changes and clears all the caches.
|
|
39
|
+
*/
|
|
40
|
+
end(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Main method to calculate the delta of modules. It returns a DeltaResult,
|
|
43
|
+
* which contain the modified/added modules and the removed modules.
|
|
44
|
+
*/
|
|
45
|
+
getDelta($$PARAM_0$$: {
|
|
46
|
+
reset: boolean;
|
|
47
|
+
shallow: boolean;
|
|
48
|
+
}): Promise<DeltaResult<T>>;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the graph with all the dependencies. Each module contains the
|
|
51
|
+
* needed information to do the traversing (dependencies, inverseDependencies)
|
|
52
|
+
* plus some metadata.
|
|
53
|
+
*/
|
|
54
|
+
getGraph(): Graph<T>;
|
|
55
|
+
_handleMultipleFileChanges: (changeEvent: ChangeEvent) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Handles a single file change. To avoid doing any work before it's needed,
|
|
58
|
+
* the listener only stores the modified file, which will then be used later
|
|
59
|
+
* when the delta needs to be calculated.
|
|
60
|
+
*/
|
|
61
|
+
_handleFileChange: (
|
|
62
|
+
$$PARAM_0$$: ChangeEvent['eventsQueue'][number],
|
|
63
|
+
logger: null | undefined | RootPerfLogger,
|
|
64
|
+
) => unknown;
|
|
65
|
+
_getChangedDependencies(
|
|
66
|
+
modifiedFiles: Set<string>,
|
|
67
|
+
deletedFiles: Set<string>,
|
|
68
|
+
addedFiles: Set<string>,
|
|
69
|
+
): Promise<DeltaResult<T>>;
|
|
70
|
+
}
|
|
71
|
+
export default DeltaCalculator;
|
|
@@ -8,11 +8,7 @@ var _Graph = require("./Graph");
|
|
|
8
8
|
var _events = _interopRequireDefault(require("events"));
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
|
10
10
|
function _interopRequireDefault(e) {
|
|
11
|
-
return e && e.__esModule
|
|
12
|
-
? e
|
|
13
|
-
: {
|
|
14
|
-
default: e,
|
|
15
|
-
};
|
|
11
|
+
return e && e.__esModule ? e : { default: e };
|
|
16
12
|
}
|
|
17
13
|
const debug = require("debug")("Metro:DeltaCalculator");
|
|
18
14
|
class DeltaCalculator extends _events.default {
|
|
@@ -0,0 +1,167 @@
|
|
|
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
|
+
/**
|
|
12
|
+
* Portions of this code are based on the Synchronous Cycle Collection
|
|
13
|
+
* algorithm described in:
|
|
14
|
+
*
|
|
15
|
+
* David F. Bacon and V. T. Rajan. 2001. Concurrent Cycle Collection in
|
|
16
|
+
* Reference Counted Systems. In Proceedings of the 15th European Conference on
|
|
17
|
+
* Object-Oriented Programming (ECOOP '01). Springer-Verlag, Berlin,
|
|
18
|
+
* Heidelberg, 207–235.
|
|
19
|
+
*
|
|
20
|
+
* Notable differences from the algorithm in the paper:
|
|
21
|
+
* 1. Our implementation uses the inverseDependencies set (which we already
|
|
22
|
+
* have to maintain) instead of a separate refcount variable. A module's
|
|
23
|
+
* reference count is equal to the size of its inverseDependencies set, plus
|
|
24
|
+
* 1 if it's an entry point of the graph.
|
|
25
|
+
* 2. We keep the "root buffer" (possibleCycleRoots) free of duplicates by
|
|
26
|
+
* making it a Set, instead of storing a "buffered" flag on each node.
|
|
27
|
+
* 3. On top of tracking edges between nodes, we also count references between
|
|
28
|
+
* nodes and entries in the importBundleNodes set.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import type {RequireContext} from '../lib/contextModule';
|
|
32
|
+
import type {
|
|
33
|
+
Dependencies,
|
|
34
|
+
Dependency,
|
|
35
|
+
GraphInputOptions,
|
|
36
|
+
MixedOutput,
|
|
37
|
+
Module,
|
|
38
|
+
ModuleData,
|
|
39
|
+
Options,
|
|
40
|
+
ResolvedDependency,
|
|
41
|
+
TransformInputOptions,
|
|
42
|
+
} from './types';
|
|
43
|
+
|
|
44
|
+
import CountingSet from '../lib/CountingSet';
|
|
45
|
+
|
|
46
|
+
export type Result<T> = {
|
|
47
|
+
added: Map<string, Module<T>>;
|
|
48
|
+
modified: Map<string, Module<T>>;
|
|
49
|
+
deleted: Set<string>;
|
|
50
|
+
};
|
|
51
|
+
type Delta<T> = Readonly<{
|
|
52
|
+
added: Set<string>;
|
|
53
|
+
touched: Set<string>;
|
|
54
|
+
deleted: Set<string>;
|
|
55
|
+
updatedModuleData: ReadonlyMap<string, ModuleData<T>>;
|
|
56
|
+
baseModuleData: Map<string, ModuleData<T>>;
|
|
57
|
+
errors: ReadonlyMap<string, Error>;
|
|
58
|
+
}>;
|
|
59
|
+
type InternalOptions<T> = Readonly<{
|
|
60
|
+
lazy: boolean;
|
|
61
|
+
onDependencyAdd: () => unknown;
|
|
62
|
+
onDependencyAdded: () => unknown;
|
|
63
|
+
resolve: Options<T>['resolve'];
|
|
64
|
+
transform: Options<T>['transform'];
|
|
65
|
+
shallow: boolean;
|
|
66
|
+
}>;
|
|
67
|
+
export declare class Graph<T = MixedOutput> {
|
|
68
|
+
readonly entryPoints: ReadonlySet<string>;
|
|
69
|
+
readonly transformOptions: TransformInputOptions;
|
|
70
|
+
readonly dependencies: Dependencies<T>;
|
|
71
|
+
constructor(options: GraphInputOptions);
|
|
72
|
+
/**
|
|
73
|
+
* Dependency Traversal logic for the Delta Bundler. This method calculates
|
|
74
|
+
* the modules that should be included in the bundle by traversing the
|
|
75
|
+
* dependency graph.
|
|
76
|
+
* Instead of traversing the whole graph each time, it just calculates the
|
|
77
|
+
* difference between runs by only traversing the added/removed dependencies.
|
|
78
|
+
* To do so, it uses the passed graph dependencies and it mutates it.
|
|
79
|
+
* The paths parameter contains the absolute paths of the root files that the
|
|
80
|
+
* method should traverse. Normally, these paths should be the modified files
|
|
81
|
+
* since the last traversal.
|
|
82
|
+
*/
|
|
83
|
+
traverseDependencies(
|
|
84
|
+
paths: ReadonlyArray<string>,
|
|
85
|
+
options: Options<T>,
|
|
86
|
+
): Promise<Result<T>>;
|
|
87
|
+
initialTraverseDependencies(options: Options<T>): Promise<Result<T>>;
|
|
88
|
+
_buildDelta(
|
|
89
|
+
pathsToVisit: ReadonlySet<string>,
|
|
90
|
+
options: InternalOptions<T>,
|
|
91
|
+
moduleFilter?: (path: string) => boolean,
|
|
92
|
+
): Promise<Delta<T>>;
|
|
93
|
+
_recursivelyCommitModule(
|
|
94
|
+
path: string,
|
|
95
|
+
delta: Delta<T>,
|
|
96
|
+
options: InternalOptions<T>,
|
|
97
|
+
commitOptions?: Readonly<{onlyRemove: boolean}>,
|
|
98
|
+
): Module<T>;
|
|
99
|
+
_addDependency(
|
|
100
|
+
parentModule: Module<T>,
|
|
101
|
+
key: string,
|
|
102
|
+
dependency: Dependency,
|
|
103
|
+
requireContext: null | undefined | RequireContext,
|
|
104
|
+
delta: Delta<T>,
|
|
105
|
+
options: InternalOptions<T>,
|
|
106
|
+
): void;
|
|
107
|
+
_removeDependency(
|
|
108
|
+
parentModule: Module<T>,
|
|
109
|
+
key: string,
|
|
110
|
+
dependency: Dependency,
|
|
111
|
+
delta: Delta<T>,
|
|
112
|
+
options: InternalOptions<T>,
|
|
113
|
+
): void;
|
|
114
|
+
/**
|
|
115
|
+
* Collect a list of context modules which include a given file.
|
|
116
|
+
*/
|
|
117
|
+
markModifiedContextModules(
|
|
118
|
+
filePath: string,
|
|
119
|
+
modifiedPaths: Set<string> | CountingSet<string>,
|
|
120
|
+
): void;
|
|
121
|
+
/**
|
|
122
|
+
* Gets the list of modules affected by the deletion of a given file. The
|
|
123
|
+
* caller is expected to mark these modules as modified in the next call to
|
|
124
|
+
* traverseDependencies. Note that the list may contain duplicates.
|
|
125
|
+
*/
|
|
126
|
+
getModifiedModulesForDeletedPath(filePath: string): Iterable<string>;
|
|
127
|
+
/**
|
|
128
|
+
* Re-traverse the dependency graph in DFS order to reorder the modules and
|
|
129
|
+
* guarantee the same order between runs. This method mutates the passed graph.
|
|
130
|
+
*/
|
|
131
|
+
reorderGraph(options: {shallow: boolean}): void;
|
|
132
|
+
_reorderDependencies(
|
|
133
|
+
module: Module<T>,
|
|
134
|
+
orderedDependencies: Map<string, Module<T>>,
|
|
135
|
+
options: {shallow: boolean},
|
|
136
|
+
): void;
|
|
137
|
+
/** Garbage collection functions */
|
|
138
|
+
|
|
139
|
+
_incrementImportBundleReference(
|
|
140
|
+
dependency: ResolvedDependency,
|
|
141
|
+
parentModule: Module<T>,
|
|
142
|
+
): void;
|
|
143
|
+
_decrementImportBundleReference(
|
|
144
|
+
dependency: ResolvedDependency,
|
|
145
|
+
parentModule: Module<T>,
|
|
146
|
+
): void;
|
|
147
|
+
_markModuleInUse(module: Module<T>): void;
|
|
148
|
+
_children(
|
|
149
|
+
module: Module<T>,
|
|
150
|
+
options: InternalOptions<T>,
|
|
151
|
+
): Iterator<Module<T>>;
|
|
152
|
+
_moduleSnapshot(module: Module<T>): ModuleData<T>;
|
|
153
|
+
_releaseModule(
|
|
154
|
+
module: Module<T>,
|
|
155
|
+
delta: Delta<T>,
|
|
156
|
+
options: InternalOptions<T>,
|
|
157
|
+
): void;
|
|
158
|
+
_freeModule(module: Module<T>, delta: Delta<T>): void;
|
|
159
|
+
_markAsPossibleCycleRoot(module: Module<T>): void;
|
|
160
|
+
_collectCycles(delta: Delta<T>, options: InternalOptions<T>): void;
|
|
161
|
+
_markGray(module: Module<T>, options: InternalOptions<T>): void;
|
|
162
|
+
_scan(module: Module<T>, options: InternalOptions<T>): void;
|
|
163
|
+
_scanBlack(module: Module<T>, options: InternalOptions<T>): void;
|
|
164
|
+
_collectWhite(module: Module<T>, delta: Delta<T>): void;
|
|
165
|
+
|
|
166
|
+
/** End of garbage collection functions */
|
|
167
|
+
}
|
|
@@ -11,11 +11,7 @@ var _buildSubgraph = require("./buildSubgraph");
|
|
|
11
11
|
var _invariant = _interopRequireDefault(require("invariant"));
|
|
12
12
|
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
13
13
|
function _interopRequireDefault(e) {
|
|
14
|
-
return e && e.__esModule
|
|
15
|
-
? e
|
|
16
|
-
: {
|
|
17
|
-
default: e,
|
|
18
|
-
};
|
|
14
|
+
return e && e.__esModule ? e : { default: e };
|
|
19
15
|
}
|
|
20
16
|
function getInternalOptions({ transform, resolve, onProgress, lazy, shallow }) {
|
|
21
17
|
let numProcessed = 0;
|
|
@@ -0,0 +1,20 @@
|
|
|
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 {Module, ReadOnlyGraph, SerializerOptions} from '../types';
|
|
12
|
+
import type {Bundle} from 'metro-runtime/src/modules/types';
|
|
13
|
+
|
|
14
|
+
declare function baseJSBundle(
|
|
15
|
+
entryPoint: string,
|
|
16
|
+
preModules: ReadonlyArray<Module>,
|
|
17
|
+
graph: ReadOnlyGraph,
|
|
18
|
+
options: SerializerOptions,
|
|
19
|
+
): Bundle;
|
|
20
|
+
export default baseJSBundle;
|
|
@@ -11,11 +11,7 @@ var _processModules = _interopRequireDefault(
|
|
|
11
11
|
require("./helpers/processModules"),
|
|
12
12
|
);
|
|
13
13
|
function _interopRequireDefault(e) {
|
|
14
|
-
return e && e.__esModule
|
|
15
|
-
? e
|
|
16
|
-
: {
|
|
17
|
-
default: e,
|
|
18
|
-
};
|
|
14
|
+
return e && e.__esModule ? e : { default: e };
|
|
19
15
|
}
|
|
20
16
|
function baseJSBundle(entryPoint, preModules, graph, options) {
|
|
21
17
|
for (const module of graph.dependencies.values()) {
|
|
@@ -0,0 +1,22 @@
|
|
|
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 {Module, ReadOnlyGraph} from '../types';
|
|
12
|
+
|
|
13
|
+
type Options = {
|
|
14
|
+
platform: null | undefined | string;
|
|
15
|
+
readonly processModuleFilter: (module: Module) => boolean;
|
|
16
|
+
};
|
|
17
|
+
declare function getAllFiles(
|
|
18
|
+
pre: ReadonlyArray<Module>,
|
|
19
|
+
graph: ReadOnlyGraph,
|
|
20
|
+
options: Options,
|
|
21
|
+
): Promise<ReadonlyArray<string>>;
|
|
22
|
+
export default getAllFiles;
|
|
@@ -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 {AssetData} from '../../Assets';
|
|
12
|
+
import type {Module, ReadOnlyDependencies} from '../types';
|
|
13
|
+
|
|
14
|
+
type Options = {
|
|
15
|
+
readonly processModuleFilter: (module: Module) => boolean;
|
|
16
|
+
assetPlugins: ReadonlyArray<string>;
|
|
17
|
+
platform: null | undefined | string;
|
|
18
|
+
projectRoot: string;
|
|
19
|
+
publicPath: string;
|
|
20
|
+
};
|
|
21
|
+
declare function getAssets(
|
|
22
|
+
dependencies: ReadOnlyDependencies,
|
|
23
|
+
options: Options,
|
|
24
|
+
): Promise<ReadonlyArray<AssetData>>;
|
|
25
|
+
export default getAssets;
|
|
@@ -8,11 +8,7 @@ var _Assets = require("../../Assets");
|
|
|
8
8
|
var _js = require("./helpers/js");
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
|
10
10
|
function _interopRequireDefault(e) {
|
|
11
|
-
return e && e.__esModule
|
|
12
|
-
? e
|
|
13
|
-
: {
|
|
14
|
-
default: e,
|
|
15
|
-
};
|
|
11
|
+
return e && e.__esModule ? e : { default: e };
|
|
16
12
|
}
|
|
17
13
|
async function getAssets(dependencies, options) {
|
|
18
14
|
const promises = [];
|
|
@@ -0,0 +1,26 @@
|
|
|
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 {Module} from '../types';
|
|
12
|
+
import type {
|
|
13
|
+
FBSourceFunctionMap,
|
|
14
|
+
MetroSourceMapSegmentTuple,
|
|
15
|
+
} from 'metro-source-map';
|
|
16
|
+
|
|
17
|
+
export type ExplodedSourceMap = ReadonlyArray<{
|
|
18
|
+
readonly map: Array<MetroSourceMapSegmentTuple>;
|
|
19
|
+
readonly firstLine1Based: number;
|
|
20
|
+
readonly functionMap: null | undefined | FBSourceFunctionMap;
|
|
21
|
+
readonly path: string;
|
|
22
|
+
}>;
|
|
23
|
+
export declare function getExplodedSourceMap(
|
|
24
|
+
modules: ReadonlyArray<Module>,
|
|
25
|
+
options: {readonly processModuleFilter: (module: Module) => boolean},
|
|
26
|
+
): ExplodedSourceMap;
|