metro 0.83.2 → 0.83.4
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 +25 -23
- package/src/Assets.js +50 -30
- package/src/Assets.js.flow +26 -15
- package/src/Bundler/util.js +33 -22
- package/src/Bundler/util.js.flow +2 -2
- package/src/Bundler.js +5 -1
- package/src/Bundler.js.flow +1 -1
- package/src/DeltaBundler/DeltaCalculator.js +9 -5
- package/src/DeltaBundler/DeltaCalculator.js.flow +8 -8
- package/src/DeltaBundler/Graph.js +21 -17
- package/src/DeltaBundler/Graph.js.flow +30 -30
- package/src/DeltaBundler/Serializers/baseJSBundle.js +5 -1
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +1 -1
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getAssets.js +5 -1
- package/src/DeltaBundler/Serializers/getAssets.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js +5 -1
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +8 -8
- package/src/DeltaBundler/Serializers/helpers/js.js +33 -22
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +6 -6
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +33 -22
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +5 -5
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +5 -1
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -6
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +2 -2
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -2
- package/src/DeltaBundler/Transformer.js +5 -1
- package/src/DeltaBundler/Transformer.js.flow +3 -3
- package/src/DeltaBundler/Worker.flow.js +5 -1
- package/src/DeltaBundler/Worker.flow.js.flow +1 -1
- package/src/DeltaBundler/WorkerFarm.js +1 -1
- package/src/DeltaBundler/WorkerFarm.js.flow +26 -13
- package/src/DeltaBundler/buildSubgraph.js +9 -5
- package/src/DeltaBundler/buildSubgraph.js.flow +8 -8
- package/src/DeltaBundler/getTransformCacheKey.js +5 -1
- package/src/DeltaBundler/types.js +5 -1
- package/src/DeltaBundler/types.js.flow +36 -34
- package/src/DeltaBundler.js +5 -1
- package/src/DeltaBundler.js.flow +2 -2
- package/src/HmrServer.js +42 -30
- package/src/HmrServer.js.flow +17 -12
- package/src/IncrementalBundler.js +37 -22
- package/src/IncrementalBundler.js.flow +13 -9
- package/src/ModuleGraph/worker/JsFileWrapping.js +33 -22
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +10 -5
- package/src/ModuleGraph/worker/collectDependencies.js +33 -22
- package/src/ModuleGraph/worker/collectDependencies.js.flow +27 -21
- package/src/ModuleGraph/worker/generateImportNames.js +5 -1
- package/src/ModuleGraph/worker/generateImportNames.js.flow +4 -2
- package/src/ModuleGraph/worker/importLocationsPlugin.js.flow +7 -3
- package/src/Server/MultipartResponse.js +5 -1
- package/src/Server/MultipartResponse.js.flow +1 -1
- package/src/Server/symbolicate.js.flow +4 -4
- package/src/Server.js +112 -40
- package/src/Server.js.flow +110 -47
- package/src/cli/parseKeyValueParamArray.js.flow +1 -1
- package/src/cli-utils.js +5 -1
- package/src/cli-utils.js.flow +2 -2
- package/src/commands/build.js +5 -1
- package/src/commands/build.js.flow +11 -10
- package/src/commands/dependencies.js +5 -1
- package/src/commands/dependencies.js.flow +8 -4
- package/src/commands/serve.js +2 -0
- package/src/commands/serve.js.flow +14 -9
- package/src/index.flow.js +38 -27
- package/src/index.flow.js.flow +25 -20
- 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 +5 -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 +5 -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 +33 -22
- 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 +5 -1
- package/src/integration_tests/execBundle.js.flow +1 -1
- package/src/lib/BatchProcessor.js +10 -3
- package/src/lib/BatchProcessor.js.flow +10 -7
- package/src/lib/CountingSet.js.flow +4 -4
- package/src/lib/JsonReporter.js +5 -3
- package/src/lib/JsonReporter.js.flow +19 -17
- package/src/lib/RamBundleParser.js +5 -1
- package/src/lib/RamBundleParser.js.flow +1 -1
- package/src/lib/TerminalReporter.js +39 -28
- package/src/lib/TerminalReporter.js.flow +15 -15
- package/src/lib/contextModule.js +5 -1
- package/src/lib/contextModule.js.flow +1 -1
- package/src/lib/contextModuleTemplates.js +28 -21
- package/src/lib/countLines.js +4 -3
- package/src/lib/countLines.js.flow +3 -4
- package/src/lib/createWebsocketServer.js +14 -3
- package/src/lib/createWebsocketServer.js.flow +16 -9
- package/src/lib/debounceAsyncQueue.js.flow +1 -1
- package/src/lib/formatBundlingError.js +5 -1
- package/src/lib/formatBundlingError.js.flow +1 -1
- package/src/lib/getAppendScripts.js +5 -1
- package/src/lib/getAppendScripts.js.flow +4 -4
- package/src/lib/getGraphId.js +5 -1
- package/src/lib/getGraphId.js.flow +1 -1
- package/src/lib/getPreludeCode.js +4 -0
- package/src/lib/getPreludeCode.js.flow +10 -3
- package/src/lib/getPrependedScripts.js +44 -23
- package/src/lib/getPrependedScripts.js.flow +10 -3
- package/src/lib/logToConsole.js +5 -1
- package/src/lib/logToConsole.js.flow +2 -2
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +33 -22
- package/src/lib/parseCustomResolverOptions.js.flow +2 -2
- package/src/lib/parseCustomTransformOptions.js.flow +1 -1
- package/src/lib/parseJsonBody.js.flow +11 -1
- package/src/lib/pathUtils.js +28 -21
- package/src/lib/pathUtils.js.flow +1 -1
- package/src/lib/relativizeSourceMap.js +5 -1
- package/src/lib/reporting.js +5 -1
- package/src/lib/reporting.js.flow +4 -4
- package/src/lib/transformHelpers.js +16 -10
- package/src/lib/transformHelpers.js.flow +17 -15
- package/src/node-haste/DependencyGraph/ModuleResolution.js +56 -43
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +35 -32
- package/src/node-haste/DependencyGraph/createFileMap.js +64 -39
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +44 -18
- package/src/node-haste/DependencyGraph.js +45 -32
- package/src/node-haste/DependencyGraph.js.flow +35 -37
- package/src/node-haste/Package.js +5 -1
- package/src/node-haste/PackageCache.js +5 -1
- package/src/node-haste/lib/AssetPaths.js +7 -3
- package/src/node-haste/lib/AssetPaths.js.flow +4 -4
- package/src/node-haste/lib/parsePlatformFilePath.js +11 -7
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +4 -4
- package/src/shared/output/RamBundle/as-assets.js +5 -1
- package/src/shared/output/RamBundle/as-assets.js.flow +6 -6
- package/src/shared/output/RamBundle/as-indexed-file.js +5 -1
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +5 -5
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +5 -5
- package/src/shared/output/RamBundle/util.js +5 -1
- package/src/shared/output/RamBundle/util.js.flow +5 -5
- package/src/shared/output/RamBundle/write-sourcemap.js +5 -1
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
- package/src/shared/output/RamBundle.js +5 -1
- package/src/shared/output/RamBundle.js.flow +1 -1
- package/src/shared/output/bundle.flow.js +5 -1
- package/src/shared/output/bundle.flow.js.flow +3 -3
- package/src/shared/output/meta.js +7 -3
- package/src/shared/output/meta.js.flow +1 -1
- package/src/shared/output/writeFile.js +13 -4
- package/src/shared/output/writeFile.js.flow +8 -2
- package/src/shared/types.js.flow +20 -5
- package/src/Asset.d.ts +0 -25
- package/src/Bundler.d.ts +0 -39
- package/src/DeltaBundler/Graph.d.ts +0 -40
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +0 -26
- package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +0 -18
- package/src/DeltaBundler/Worker.d.ts +0 -45
- package/src/DeltaBundler/types.d.ts +0 -166
- package/src/DeltaBundler.d.ts +0 -58
- package/src/IncrementalBundler.d.ts +0 -98
- package/src/ModuleGraph/test-helpers.js +0 -75
- package/src/ModuleGraph/worker/collectDependencies.d.ts +0 -27
- package/src/Server/MultipartResponse.d.ts +0 -31
- package/src/Server/symbolicate.d.ts +0 -31
- package/src/Server.d.ts +0 -118
- package/src/index.d.ts +0 -193
- package/src/lib/CountingSet.d.ts +0 -48
- package/src/lib/TerminalReporter.d.ts +0 -27
- package/src/lib/contextModule.d.ts +0 -22
- package/src/lib/getGraphId.d.ts +0 -11
- package/src/lib/reporting.d.ts +0 -144
- package/src/node-haste/DependencyGraph.d.ts +0 -62
- package/src/shared/output/bundle.d.ts +0 -35
- package/src/shared/types.d.ts +0 -130
|
@@ -12,9 +12,15 @@
|
|
|
12
12
|
import fs from 'fs';
|
|
13
13
|
import throat from 'throat';
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const writeFileWithThroat: typeof fs.promises.writeFile = throat(
|
|
16
16
|
128,
|
|
17
17
|
fs.promises.writeFile,
|
|
18
18
|
);
|
|
19
19
|
|
|
20
|
-
export default writeFile
|
|
20
|
+
export default function writeFile(
|
|
21
|
+
filePath: string,
|
|
22
|
+
data: string | Buffer | Uint8Array,
|
|
23
|
+
encoding?: string,
|
|
24
|
+
): Promise<void> {
|
|
25
|
+
return writeFileWithThroat(filePath, data, encoding);
|
|
26
|
+
}
|
package/src/shared/types.js.flow
CHANGED
|
@@ -35,6 +35,17 @@ export enum SourcePathsMode {
|
|
|
35
35
|
ServerUrl = 'url-server',
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
export type ReadonlySourceLocation = Readonly<{
|
|
39
|
+
start: Readonly<{
|
|
40
|
+
line: number,
|
|
41
|
+
column: number,
|
|
42
|
+
}>,
|
|
43
|
+
end: Readonly<{
|
|
44
|
+
line: number,
|
|
45
|
+
column: number,
|
|
46
|
+
}>,
|
|
47
|
+
}>;
|
|
48
|
+
|
|
38
49
|
export type BundleOptions = {
|
|
39
50
|
+customResolverOptions: CustomResolverOptions,
|
|
40
51
|
customTransformOptions: CustomTransformOptions,
|
|
@@ -45,7 +56,7 @@ export type BundleOptions = {
|
|
|
45
56
|
+lazy: boolean,
|
|
46
57
|
minify: boolean,
|
|
47
58
|
+modulesOnly: boolean,
|
|
48
|
-
onProgress: ?(doneCont: number, totalCount: number) =>
|
|
59
|
+
onProgress: ?(doneCont: number, totalCount: number) => unknown,
|
|
49
60
|
+platform: ?string,
|
|
50
61
|
+runModule: boolean,
|
|
51
62
|
+shallow: boolean,
|
|
@@ -56,11 +67,11 @@ export type BundleOptions = {
|
|
|
56
67
|
+sourcePaths: SourcePathsMode,
|
|
57
68
|
};
|
|
58
69
|
|
|
59
|
-
export type BuildOptions =
|
|
70
|
+
export type BuildOptions = Readonly<{
|
|
60
71
|
withAssets?: boolean,
|
|
61
72
|
}>;
|
|
62
73
|
|
|
63
|
-
export type ResolverInputOptions =
|
|
74
|
+
export type ResolverInputOptions = Readonly<{
|
|
64
75
|
customResolverOptions?: CustomResolverOptions,
|
|
65
76
|
dev: boolean,
|
|
66
77
|
}>;
|
|
@@ -81,7 +92,7 @@ export type GraphOptions = {
|
|
|
81
92
|
};
|
|
82
93
|
|
|
83
94
|
// Stricter representation of BundleOptions.
|
|
84
|
-
export type SplitBundleOptions =
|
|
95
|
+
export type SplitBundleOptions = Readonly<{
|
|
85
96
|
entryFile: string,
|
|
86
97
|
resolverOptions: ResolverInputOptions,
|
|
87
98
|
transformOptions: TransformInputOptions,
|
|
@@ -129,7 +140,11 @@ export type OutputOptions = {
|
|
|
129
140
|
...
|
|
130
141
|
};
|
|
131
142
|
|
|
132
|
-
|
|
143
|
+
type SafeOptionalProps<T> = {
|
|
144
|
+
[K in keyof T]: T[K] extends void ? void | T[K] : T[K],
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export type RequestOptions = Readonly<
|
|
133
148
|
SafeOptionalProps<{
|
|
134
149
|
entryFile: string,
|
|
135
150
|
inlineSourceMap?: boolean,
|
package/src/Asset.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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 interface AssetDataWithoutFiles {
|
|
12
|
-
readonly __packager_asset: boolean;
|
|
13
|
-
readonly fileSystemLocation: string;
|
|
14
|
-
readonly hash: string;
|
|
15
|
-
readonly height?: number;
|
|
16
|
-
readonly httpServerLocation: string;
|
|
17
|
-
readonly name: string;
|
|
18
|
-
readonly scales: number[];
|
|
19
|
-
readonly type: string;
|
|
20
|
-
readonly width?: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface AssetData extends AssetDataWithoutFiles {
|
|
24
|
-
readonly files: string[];
|
|
25
|
-
}
|
package/src/Bundler.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
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 DependencyGraph from './node-haste/DependencyGraph';
|
|
14
|
-
import type {EventEmitter} from 'events';
|
|
15
|
-
import type {ConfigT} from 'metro-config';
|
|
16
|
-
|
|
17
|
-
export interface BundlerOptions {
|
|
18
|
-
readonly hasReducedPerformance?: boolean;
|
|
19
|
-
readonly watch?: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default class Bundler {
|
|
23
|
-
constructor(config: ConfigT, options?: BundlerOptions);
|
|
24
|
-
|
|
25
|
-
getWatcher(): EventEmitter;
|
|
26
|
-
|
|
27
|
-
end(): Promise<void>;
|
|
28
|
-
|
|
29
|
-
getDependencyGraph(): Promise<DependencyGraph>;
|
|
30
|
-
|
|
31
|
-
transformFile(
|
|
32
|
-
filePath: string,
|
|
33
|
-
transformOptions: TransformOptions,
|
|
34
|
-
/** Optionally provide the file contents, this can be used to provide virtual contents for a file. */
|
|
35
|
-
fileBuffer?: Buffer,
|
|
36
|
-
): Promise<TransformResultWithSource<void>>;
|
|
37
|
-
|
|
38
|
-
ready(): Promise<void>;
|
|
39
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
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 {
|
|
12
|
-
Dependencies,
|
|
13
|
-
GraphInputOptions,
|
|
14
|
-
MixedOutput,
|
|
15
|
-
Module,
|
|
16
|
-
Options,
|
|
17
|
-
TransformInputOptions,
|
|
18
|
-
} from './types';
|
|
19
|
-
|
|
20
|
-
export interface Result<T> {
|
|
21
|
-
added: Map<string, Module<T>>;
|
|
22
|
-
modified: Map<string, Module<T>>;
|
|
23
|
-
deleted: Set<string>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export class Graph<T = MixedOutput> {
|
|
27
|
-
entryPoints: ReadonlySet<string>;
|
|
28
|
-
transformOptions: TransformInputOptions;
|
|
29
|
-
dependencies: Dependencies<T>;
|
|
30
|
-
constructor(options: GraphInputOptions);
|
|
31
|
-
traverseDependencies(
|
|
32
|
-
paths: ReadonlyArray<string>,
|
|
33
|
-
options: Options<T>,
|
|
34
|
-
): Promise<Result<T>>;
|
|
35
|
-
initialTraverseDependencies(options: Options<T>): Promise<Result<T>>;
|
|
36
|
-
markModifiedContextModules(
|
|
37
|
-
filePath: string,
|
|
38
|
-
modifiedPaths: Set<string>,
|
|
39
|
-
): void;
|
|
40
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
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;
|
|
@@ -1,18 +0,0 @@
|
|
|
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 {ModuleTransportLike} from '../../shared/types';
|
|
12
|
-
|
|
13
|
-
export interface RamBundleInfo {
|
|
14
|
-
getDependencies: (filePath: string) => Set<string>;
|
|
15
|
-
startupModules: Readonly<ModuleTransportLike>;
|
|
16
|
-
lazyModules: Readonly<ModuleTransportLike>;
|
|
17
|
-
groups: Map<number, Set<number>>;
|
|
18
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
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 {TransformResult} from './types';
|
|
12
|
-
import type {
|
|
13
|
-
JsTransformerConfig,
|
|
14
|
-
JsTransformOptions,
|
|
15
|
-
} from 'metro-transform-worker';
|
|
16
|
-
|
|
17
|
-
type LogEntry = unknown;
|
|
18
|
-
|
|
19
|
-
export type TransformOptions = JsTransformOptions;
|
|
20
|
-
|
|
21
|
-
export interface Worker {
|
|
22
|
-
readonly transform: (
|
|
23
|
-
filename: string,
|
|
24
|
-
transformOptions: JsTransformOptions,
|
|
25
|
-
projectRoot: string,
|
|
26
|
-
transformerConfig: TransformerConfig,
|
|
27
|
-
fileBuffer?: Buffer,
|
|
28
|
-
) => Promise<Data>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface TransformerConfig {
|
|
32
|
-
transformerPath: string;
|
|
33
|
-
transformerConfig: JsTransformerConfig;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface Data {
|
|
37
|
-
readonly result: TransformResult<void>;
|
|
38
|
-
readonly sha1: string;
|
|
39
|
-
readonly transformFileStartLogEntry: LogEntry;
|
|
40
|
-
readonly transformFileEndLogEntry: LogEntry;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
declare const worker: Worker;
|
|
44
|
-
|
|
45
|
-
export default worker;
|
|
@@ -1,166 +0,0 @@
|
|
|
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 {RequireContext} from '../lib/contextModule';
|
|
12
|
-
import type CountingSet from '../lib/CountingSet';
|
|
13
|
-
import type {RequireContextParams} from '../ModuleGraph/worker/collectDependencies';
|
|
14
|
-
import type {Graph} from './Graph';
|
|
15
|
-
import type {JsTransformOptions} from 'metro-transform-worker';
|
|
16
|
-
|
|
17
|
-
export interface MixedOutput {
|
|
18
|
-
readonly data: {code: string};
|
|
19
|
-
readonly type: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type AsyncDependencyType = 'async' | 'prefetch' | 'weak';
|
|
23
|
-
|
|
24
|
-
export interface TransformResultDependency {
|
|
25
|
-
/**
|
|
26
|
-
* The literal name provided to a require or import call. For example 'foo' in
|
|
27
|
-
* case of `require('foo')`.
|
|
28
|
-
*/
|
|
29
|
-
readonly name: string;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Extra data returned by the dependency extractor.
|
|
33
|
-
*/
|
|
34
|
-
readonly data: {
|
|
35
|
-
/**
|
|
36
|
-
* A locally unique key for this dependency within the current module.
|
|
37
|
-
*/
|
|
38
|
-
readonly key: string;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* If not null, this dependency is due to a dynamic `import()` or `__prefetchImport()` call.
|
|
42
|
-
*/
|
|
43
|
-
readonly asyncType: AsyncDependencyType | null;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* The dependency is enclosed in a try/catch block.
|
|
47
|
-
*/
|
|
48
|
-
readonly isOptional?: boolean;
|
|
49
|
-
|
|
50
|
-
readonly locs: ReadonlyArray<{
|
|
51
|
-
readonly start: {readonly line: number; readonly column: number};
|
|
52
|
-
readonly end: {readonly line: number; readonly column: number};
|
|
53
|
-
}>;
|
|
54
|
-
|
|
55
|
-
/** Context for requiring a collection of modules. */
|
|
56
|
-
readonly contextParams?: RequireContextParams;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface Dependency {
|
|
61
|
-
readonly absolutePath: string;
|
|
62
|
-
readonly data: TransformResultDependency;
|
|
63
|
-
[key: string]: unknown;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface Module<T = MixedOutput> {
|
|
67
|
-
readonly dependencies: Map<string, Dependency>;
|
|
68
|
-
readonly inverseDependencies: CountingSet<string>;
|
|
69
|
-
readonly output: ReadonlyArray<T>;
|
|
70
|
-
readonly path: string;
|
|
71
|
-
readonly getSource: () => Buffer;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export type Dependencies<T = MixedOutput> = Map<string, Module<T>>;
|
|
75
|
-
export type ReadOnlyDependencies<T = MixedOutput> = ReadonlyMap<
|
|
76
|
-
string,
|
|
77
|
-
Module<T>
|
|
78
|
-
>;
|
|
79
|
-
|
|
80
|
-
export type TransformInputOptions = Omit<
|
|
81
|
-
JsTransformOptions,
|
|
82
|
-
'inlinePlatform' | 'inlineRequires'
|
|
83
|
-
>;
|
|
84
|
-
|
|
85
|
-
export type GraphInputOptions = Readonly<{
|
|
86
|
-
entryPoints: ReadonlySet<string>;
|
|
87
|
-
// Unused in core but useful for custom serializers / experimentalSerializerHook
|
|
88
|
-
transformOptions: TransformInputOptions;
|
|
89
|
-
}>;
|
|
90
|
-
|
|
91
|
-
export interface ReadOnlyGraph<T = MixedOutput> {
|
|
92
|
-
readonly entryPoints: ReadonlySet<string>;
|
|
93
|
-
// Unused in core but useful for custom serializers / experimentalSerializerHook
|
|
94
|
-
readonly transformOptions: Readonly<TransformInputOptions>;
|
|
95
|
-
readonly dependencies: ReadOnlyDependencies<T>;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export type {Graph};
|
|
99
|
-
|
|
100
|
-
export interface TransformResult<T = MixedOutput> {
|
|
101
|
-
dependencies: ReadonlyArray<TransformResultDependency>;
|
|
102
|
-
output: ReadonlyArray<T>;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export interface TransformResultWithSource<T = MixedOutput>
|
|
106
|
-
extends TransformResult<T> {
|
|
107
|
-
getSource: () => Buffer;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export type TransformFn<T = MixedOutput> = (
|
|
111
|
-
modulePath: string,
|
|
112
|
-
requireContext: RequireContext | null,
|
|
113
|
-
) => Promise<TransformResultWithSource<T>>;
|
|
114
|
-
|
|
115
|
-
export interface AllowOptionalDependenciesWithOptions {
|
|
116
|
-
readonly exclude: string[];
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export type AllowOptionalDependencies =
|
|
120
|
-
| boolean
|
|
121
|
-
| AllowOptionalDependenciesWithOptions;
|
|
122
|
-
|
|
123
|
-
export interface BundlerResolution {
|
|
124
|
-
readonly type: 'sourceFile';
|
|
125
|
-
readonly filePath: string;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export interface Options<T = MixedOutput> {
|
|
129
|
-
readonly resolve: (from: string, to: TransformResultDependency) => string;
|
|
130
|
-
readonly transform: TransformFn<T>;
|
|
131
|
-
readonly transformOptions: TransformInputOptions;
|
|
132
|
-
readonly onProgress:
|
|
133
|
-
| ((numProcessed: number, total: number) => unknown)
|
|
134
|
-
| null;
|
|
135
|
-
readonly lazy: boolean;
|
|
136
|
-
readonly unstable_allowRequireContext: boolean;
|
|
137
|
-
readonly shallow: boolean;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export interface DeltaResult<T = MixedOutput> {
|
|
141
|
-
readonly added: Map<string, Module<T>>;
|
|
142
|
-
readonly modified: Map<string, Module<T>>;
|
|
143
|
-
readonly deleted: Set<string>;
|
|
144
|
-
readonly reset: boolean;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export interface SerializerOptions<T = MixedOutput> {
|
|
148
|
-
readonly asyncRequireModulePath: string;
|
|
149
|
-
readonly createModuleId: (filePath: string) => number;
|
|
150
|
-
readonly dev: boolean;
|
|
151
|
-
readonly getRunModuleStatement: (
|
|
152
|
-
moduleId: number | string,
|
|
153
|
-
globalPrefix: string,
|
|
154
|
-
) => string;
|
|
155
|
-
readonly includeAsyncPaths: boolean;
|
|
156
|
-
readonly inlineSourceMap?: boolean;
|
|
157
|
-
readonly modulesOnly: boolean;
|
|
158
|
-
readonly processModuleFilter: (module: Module<T>) => boolean;
|
|
159
|
-
readonly projectRoot: string;
|
|
160
|
-
readonly runBeforeMainModule: ReadonlyArray<string>;
|
|
161
|
-
readonly runModule: boolean;
|
|
162
|
-
readonly serverRoot: string;
|
|
163
|
-
readonly shouldAddToIgnoreList: (module: Module<T>) => boolean;
|
|
164
|
-
readonly sourceMapUrl?: string;
|
|
165
|
-
readonly sourceUrl?: string;
|
|
166
|
-
}
|
package/src/DeltaBundler.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
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 {
|
|
12
|
-
DeltaResult,
|
|
13
|
-
Graph,
|
|
14
|
-
MixedOutput,
|
|
15
|
-
Options,
|
|
16
|
-
ReadOnlyGraph,
|
|
17
|
-
} from './DeltaBundler/types';
|
|
18
|
-
import type {EventEmitter} from 'events';
|
|
19
|
-
|
|
20
|
-
export type {
|
|
21
|
-
DeltaResult,
|
|
22
|
-
Graph,
|
|
23
|
-
Dependencies,
|
|
24
|
-
MixedOutput,
|
|
25
|
-
Module,
|
|
26
|
-
ReadOnlyGraph,
|
|
27
|
-
TransformFn,
|
|
28
|
-
TransformResult,
|
|
29
|
-
TransformResultDependency,
|
|
30
|
-
TransformResultWithSource,
|
|
31
|
-
} from './DeltaBundler/types';
|
|
32
|
-
|
|
33
|
-
export default class DeltaBundler<T = MixedOutput> {
|
|
34
|
-
constructor(changeEventSource: EventEmitter);
|
|
35
|
-
end(): void;
|
|
36
|
-
getDependencies(
|
|
37
|
-
entryPoints: ReadonlyArray<string>,
|
|
38
|
-
options: Options<T>,
|
|
39
|
-
): Promise<ReadOnlyGraph<T>['dependencies']>;
|
|
40
|
-
buildGraph(
|
|
41
|
-
entryPoints: ReadonlyArray<string>,
|
|
42
|
-
options: Options<T>,
|
|
43
|
-
): Promise<Graph<T>>;
|
|
44
|
-
|
|
45
|
-
getDelta(
|
|
46
|
-
graph: Graph<T>,
|
|
47
|
-
{
|
|
48
|
-
reset,
|
|
49
|
-
shallow,
|
|
50
|
-
}: {
|
|
51
|
-
reset: boolean;
|
|
52
|
-
shallow: boolean;
|
|
53
|
-
},
|
|
54
|
-
): Promise<DeltaResult<T>>;
|
|
55
|
-
|
|
56
|
-
listen(graph: Graph<T>, callback: () => Promise<void>): () => void;
|
|
57
|
-
endGraph(graph: Graph<T>): void;
|
|
58
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
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 Bundler from './Bundler';
|
|
12
|
-
import type {
|
|
13
|
-
Options as DeltaBundlerOptions,
|
|
14
|
-
ReadOnlyDependencies,
|
|
15
|
-
TransformInputOptions,
|
|
16
|
-
} from './DeltaBundler/types';
|
|
17
|
-
import type {GraphId} from './lib/getGraphId';
|
|
18
|
-
import type {ConfigT} from 'metro-config';
|
|
19
|
-
|
|
20
|
-
import DeltaBundler, {DeltaResult, Graph, Module} from './DeltaBundler';
|
|
21
|
-
import {ResolverInputOptions} from './shared/types';
|
|
22
|
-
|
|
23
|
-
export type RevisionId = string;
|
|
24
|
-
|
|
25
|
-
export type OutputGraph = Graph<void>;
|
|
26
|
-
|
|
27
|
-
export interface OtherOptions {
|
|
28
|
-
readonly onProgress: DeltaBundlerOptions<void>['onProgress'];
|
|
29
|
-
readonly shallow: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface GraphRevision {
|
|
33
|
-
readonly id: RevisionId;
|
|
34
|
-
readonly date: Date;
|
|
35
|
-
readonly graphId: GraphId;
|
|
36
|
-
readonly graph: OutputGraph;
|
|
37
|
-
readonly prepend: ReadonlyArray<Module<void>>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface IncrementalBundlerOptions {
|
|
41
|
-
readonly hasReducedPerformance?: boolean;
|
|
42
|
-
readonly watch?: boolean;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export default class IncrementalBundler {
|
|
46
|
-
static revisionIdFromString: (str: string) => RevisionId;
|
|
47
|
-
constructor(config: ConfigT, options?: IncrementalBundlerOptions);
|
|
48
|
-
|
|
49
|
-
end(): void;
|
|
50
|
-
getBundler(): Bundler;
|
|
51
|
-
getDeltaBundler(): DeltaBundler<void>;
|
|
52
|
-
getRevision(revisionId: RevisionId): Promise<GraphRevision> | null;
|
|
53
|
-
getRevisionByGraphId(graphId: GraphId): Promise<GraphRevision> | null;
|
|
54
|
-
|
|
55
|
-
buildGraphForEntries(
|
|
56
|
-
entryFiles: ReadonlyArray<string>,
|
|
57
|
-
transformOptions: TransformInputOptions,
|
|
58
|
-
resolverOptions: ResolverInputOptions,
|
|
59
|
-
otherOptions?: OtherOptions,
|
|
60
|
-
): Promise<OutputGraph>;
|
|
61
|
-
|
|
62
|
-
getDependencies(
|
|
63
|
-
entryFiles: ReadonlyArray<string>,
|
|
64
|
-
transformOptions: TransformInputOptions,
|
|
65
|
-
resolverOptions: ResolverInputOptions,
|
|
66
|
-
otherOptions?: OtherOptions,
|
|
67
|
-
): Promise<ReadOnlyDependencies<void>>;
|
|
68
|
-
|
|
69
|
-
buildGraph(
|
|
70
|
-
entryFile: string,
|
|
71
|
-
transformOptions: TransformInputOptions,
|
|
72
|
-
resolverOptions: ResolverInputOptions,
|
|
73
|
-
otherOptions?: OtherOptions,
|
|
74
|
-
): Promise<
|
|
75
|
-
Readonly<{graph: OutputGraph; prepend: ReadonlyArray<Module<void>>}>
|
|
76
|
-
>;
|
|
77
|
-
|
|
78
|
-
initializeGraph(
|
|
79
|
-
entryFile: string,
|
|
80
|
-
transformOptions: TransformInputOptions,
|
|
81
|
-
resolverOptions: ResolverInputOptions,
|
|
82
|
-
otherOptions?: OtherOptions,
|
|
83
|
-
): Promise<{
|
|
84
|
-
delta: DeltaResult<void>;
|
|
85
|
-
revision: GraphRevision;
|
|
86
|
-
}>;
|
|
87
|
-
|
|
88
|
-
updateGraph(
|
|
89
|
-
revision: GraphRevision,
|
|
90
|
-
reset: boolean,
|
|
91
|
-
): Promise<{
|
|
92
|
-
delta: DeltaResult<void>;
|
|
93
|
-
revision: GraphRevision;
|
|
94
|
-
}>;
|
|
95
|
-
|
|
96
|
-
endGraph(graphId: GraphId): Promise<void>;
|
|
97
|
-
ready(): Promise<void>;
|
|
98
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true,
|
|
5
|
-
});
|
|
6
|
-
exports.comparableCode = exports.codeFromAst = void 0;
|
|
7
|
-
exports.toEqualComparableCode = toEqualComparableCode;
|
|
8
|
-
exports.toMatchCodeFrameSnapshot = toMatchCodeFrameSnapshot;
|
|
9
|
-
var _generator = _interopRequireDefault(require("@babel/generator"));
|
|
10
|
-
var _jestSnapshot = require("jest-snapshot");
|
|
11
|
-
function _interopRequireDefault(e) {
|
|
12
|
-
return e && e.__esModule ? e : { default: e };
|
|
13
|
-
}
|
|
14
|
-
const generateOptions = {
|
|
15
|
-
concise: true,
|
|
16
|
-
sourceType: "module",
|
|
17
|
-
};
|
|
18
|
-
const codeFromAst = (ast) => (0, _generator.default)(ast, generateOptions).code;
|
|
19
|
-
exports.codeFromAst = codeFromAst;
|
|
20
|
-
const comparableCode = (code) => code.trim().replace(/\s+/g, " ");
|
|
21
|
-
exports.comparableCode = comparableCode;
|
|
22
|
-
function toEqualComparableCode(received, expected) {
|
|
23
|
-
const comparableExpected = comparableCode(expected);
|
|
24
|
-
const pass = received === comparableExpected;
|
|
25
|
-
const options = {
|
|
26
|
-
isNot: this.isNot,
|
|
27
|
-
promise: this.promise,
|
|
28
|
-
};
|
|
29
|
-
const message = pass
|
|
30
|
-
? () =>
|
|
31
|
-
this.utils.matcherHint(
|
|
32
|
-
"toEqualComparableCode",
|
|
33
|
-
undefined,
|
|
34
|
-
undefined,
|
|
35
|
-
options,
|
|
36
|
-
) +
|
|
37
|
-
"\n\n" +
|
|
38
|
-
`Expected: not ${this.utils.printExpected(comparableExpected)}\n` +
|
|
39
|
-
`Received: ${this.utils.printReceived(received)}`
|
|
40
|
-
: () => {
|
|
41
|
-
const diffString = this.utils.printDiffOrStringify(
|
|
42
|
-
comparableExpected,
|
|
43
|
-
received,
|
|
44
|
-
"expected",
|
|
45
|
-
"received",
|
|
46
|
-
this.expand,
|
|
47
|
-
);
|
|
48
|
-
return (
|
|
49
|
-
this.utils.matcherHint(
|
|
50
|
-
"toEqualComparableCode",
|
|
51
|
-
undefined,
|
|
52
|
-
undefined,
|
|
53
|
-
options,
|
|
54
|
-
) +
|
|
55
|
-
"\n\n" +
|
|
56
|
-
diffString
|
|
57
|
-
);
|
|
58
|
-
};
|
|
59
|
-
return {
|
|
60
|
-
actual: received,
|
|
61
|
-
message,
|
|
62
|
-
pass,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
const ANSI_PATTERN = /\x1b\[[0-9;]*m/g;
|
|
66
|
-
function trimANSICodes(input) {
|
|
67
|
-
return input.replace(ANSI_PATTERN, "");
|
|
68
|
-
}
|
|
69
|
-
function toMatchCodeFrameSnapshot(received) {
|
|
70
|
-
return _jestSnapshot.toMatchSnapshot.call(
|
|
71
|
-
this,
|
|
72
|
-
trimANSICodes(received),
|
|
73
|
-
"toMatchCodeFrameSnapshot",
|
|
74
|
-
);
|
|
75
|
-
}
|