metro 0.83.3 → 0.83.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +28 -24
- package/src/Assets.d.ts +83 -0
- package/src/Assets.js +42 -29
- package/src/Assets.js.flow +26 -15
- package/src/Bundler/util.d.ts +27 -0
- package/src/Bundler/util.js +25 -21
- package/src/Bundler/util.js.flow +2 -2
- package/src/Bundler.d.ts +14 -15
- package/src/Bundler.js.flow +1 -1
- package/src/DeltaBundler/DeltaCalculator.d.ts +71 -0
- package/src/DeltaBundler/DeltaCalculator.js +4 -4
- package/src/DeltaBundler/DeltaCalculator.js.flow +8 -8
- package/src/DeltaBundler/Graph.d.ts +135 -8
- package/src/DeltaBundler/Graph.js +16 -16
- package/src/DeltaBundler/Graph.js.flow +30 -30
- package/src/DeltaBundler/Serializers/baseJSBundle.d.ts +20 -0
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +1 -1
- package/src/DeltaBundler/Serializers/getAllFiles.d.ts +22 -0
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getAssets.d.ts +25 -0
- package/src/DeltaBundler/Serializers/getAssets.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +36 -6
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +8 -8
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.d.ts +12 -0
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.d.ts +33 -0
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.d.ts +17 -0
- package/src/DeltaBundler/Serializers/helpers/js.d.ts +30 -0
- package/src/DeltaBundler/Serializers/helpers/js.js +25 -21
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +6 -6
- package/src/DeltaBundler/Serializers/helpers/processModules.d.ts +25 -0
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/hmrJSBundle.d.ts +30 -0
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +25 -21
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +5 -5
- package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +29 -0
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -6
- package/src/DeltaBundler/Serializers/sourceMapObject.d.ts +23 -0
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +2 -2
- package/src/DeltaBundler/Serializers/sourceMapString.d.ts +22 -0
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -2
- package/src/DeltaBundler/Transformer.d.ts +38 -0
- package/src/DeltaBundler/Transformer.js.flow +3 -3
- package/src/DeltaBundler/Worker.d.ts +19 -27
- package/src/DeltaBundler/Worker.flow.js.flow +1 -1
- package/src/DeltaBundler/WorkerFarm.d.ts +70 -0
- package/src/DeltaBundler/WorkerFarm.js +1 -1
- package/src/DeltaBundler/WorkerFarm.js.flow +26 -13
- package/src/DeltaBundler/buildSubgraph.d.ts +30 -0
- package/src/DeltaBundler/buildSubgraph.js +4 -4
- package/src/DeltaBundler/buildSubgraph.js.flow +8 -8
- package/src/DeltaBundler/getTransformCacheKey.d.ts +18 -0
- package/src/DeltaBundler/mergeDeltas.d.ts +17 -0
- package/src/DeltaBundler/types.d.ts +97 -100
- package/src/DeltaBundler/types.js.flow +36 -34
- package/src/DeltaBundler.d.ts +14 -12
- package/src/DeltaBundler.js.flow +2 -2
- package/src/HmrServer.d.ts +79 -0
- package/src/HmrServer.js +34 -29
- package/src/HmrServer.js.flow +17 -12
- package/src/IncrementalBundler/GraphNotFoundError.d.ts +17 -0
- package/src/IncrementalBundler/ResourceNotFoundError.d.ts +15 -0
- package/src/IncrementalBundler/RevisionNotFoundError.d.ts +17 -0
- package/src/IncrementalBundler.d.ts +43 -45
- package/src/IncrementalBundler.js +29 -21
- package/src/IncrementalBundler.js.flow +13 -9
- package/src/ModuleGraph/worker/JsFileWrapping.d.ts +29 -0
- package/src/ModuleGraph/worker/JsFileWrapping.js +25 -21
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +10 -5
- package/src/ModuleGraph/worker/collectDependencies.d.ts +118 -14
- package/src/ModuleGraph/worker/collectDependencies.js +25 -21
- package/src/ModuleGraph/worker/collectDependencies.js.flow +27 -21
- package/src/ModuleGraph/worker/generateImportNames.d.ts +19 -0
- package/src/ModuleGraph/worker/generateImportNames.js.flow +4 -2
- package/src/ModuleGraph/worker/importLocationsPlugin.d.ts +26 -0
- package/src/ModuleGraph/worker/importLocationsPlugin.js.flow +7 -3
- package/src/Server/MultipartResponse.d.ts +5 -6
- package/src/Server/MultipartResponse.js.flow +1 -1
- package/src/Server/symbolicate.js.flow +4 -4
- package/src/Server.d.ts +220 -67
- package/src/Server.js +149 -45
- package/src/Server.js.flow +167 -57
- package/src/cli/parseKeyValueParamArray.d.ts +14 -0
- package/src/cli/parseKeyValueParamArray.js.flow +1 -1
- package/src/cli-utils.d.ts +19 -0
- package/src/cli-utils.js.flow +2 -2
- package/src/commands/build.d.ts +16 -0
- package/src/commands/build.js.flow +11 -10
- package/src/commands/dependencies.d.ts +16 -0
- package/src/commands/dependencies.js.flow +8 -4
- package/src/commands/serve.d.ts +16 -0
- package/src/commands/serve.js +2 -0
- package/src/commands/serve.js.flow +14 -9
- package/src/index.d.ts +97 -110
- package/src/index.flow.js +53 -35
- package/src/index.flow.js.flow +49 -29
- package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +1 -1
- package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import-with-escapes.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require-with-embedded-comment.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-specifier-with-escapes.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-require.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/index.js +25 -21
- package/src/integration_tests/basic_bundle/import-export/index.js.flow +3 -3
- package/src/integration_tests/basic_bundle/import-export/utils.js.flow +2 -2
- package/src/integration_tests/basic_bundle/loadBundleAsyncForTest.js.flow +1 -1
- package/src/integration_tests/basic_bundle/optional-dependencies/index.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/conflict.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/empty.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/matching.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-eager.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-lazy.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-sync.js.flow +2 -2
- package/src/integration_tests/basic_bundle/require-context/utils.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js.flow +1 -1
- package/src/integration_tests/execBundle.js.flow +1 -1
- package/src/lib/BatchProcessor.d.ts +54 -0
- package/src/lib/BatchProcessor.js +5 -2
- package/src/lib/BatchProcessor.js.flow +10 -7
- package/src/lib/CountingSet.d.ts +10 -10
- package/src/lib/CountingSet.js.flow +4 -4
- package/src/lib/JsonReporter.d.ts +37 -0
- package/src/lib/JsonReporter.js +5 -3
- package/src/lib/JsonReporter.js.flow +19 -17
- package/src/lib/RamBundleParser.d.ts +29 -0
- package/src/lib/RamBundleParser.js.flow +1 -1
- package/src/lib/TerminalReporter.d.ts +97 -6
- package/src/lib/TerminalReporter.js +37 -34
- package/src/lib/TerminalReporter.js.flow +21 -30
- package/src/lib/bundleProgressUtils.d.ts +26 -0
- package/src/lib/bundleProgressUtils.js +19 -0
- package/src/lib/bundleProgressUtils.js.flow +35 -0
- package/src/lib/bundleToString.d.ts +19 -0
- package/src/lib/contextModule.d.ts +20 -9
- package/src/lib/contextModule.js.flow +1 -1
- package/src/lib/contextModuleTemplates.d.ts +25 -0
- package/src/lib/contextModuleTemplates.js +25 -21
- package/src/lib/countLines.d.ts +12 -0
- package/src/lib/countLines.js +4 -3
- package/src/lib/countLines.js.flow +3 -4
- package/src/lib/createWebsocketServer.d.ts +43 -0
- package/src/lib/createWebsocketServer.js +9 -2
- package/src/lib/createWebsocketServer.js.flow +16 -9
- package/src/lib/debounceAsyncQueue.d.ts +15 -0
- package/src/lib/debounceAsyncQueue.js.flow +1 -1
- package/src/lib/formatBundlingError.d.ts +23 -0
- package/src/lib/formatBundlingError.js.flow +1 -1
- package/src/lib/getAppendScripts.d.ts +31 -0
- package/src/lib/getAppendScripts.js.flow +4 -4
- package/src/lib/getGraphId.d.ts +15 -1
- package/src/lib/getGraphId.js.flow +1 -1
- package/src/lib/getPreludeCode.d.ts +18 -0
- package/src/lib/getPreludeCode.js +4 -0
- package/src/lib/getPreludeCode.js.flow +10 -3
- package/src/lib/getPrependedScripts.d.ts +24 -0
- package/src/lib/getPrependedScripts.js +36 -22
- package/src/lib/getPrependedScripts.js.flow +10 -3
- package/src/lib/isResolvedDependency.d.ts +15 -0
- package/src/lib/logToConsole.d.ts +19 -0
- package/src/lib/logToConsole.js.flow +2 -2
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.d.ts +17 -0
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +25 -21
- package/src/lib/parseCustomResolverOptions.d.ts +16 -0
- package/src/lib/parseCustomResolverOptions.js.flow +2 -2
- package/src/lib/parseCustomTransformOptions.d.ts +16 -0
- package/src/lib/parseCustomTransformOptions.js.flow +1 -1
- package/src/lib/parseJsonBody.d.ts +27 -0
- package/src/lib/parseJsonBody.js.flow +11 -1
- package/src/lib/pathUtils.d.ts +14 -0
- package/src/lib/pathUtils.js +25 -21
- package/src/lib/pathUtils.js.flow +1 -1
- package/src/lib/relativizeSourceMap.d.ts +17 -0
- package/src/lib/reporting.d.ts +65 -81
- package/src/lib/reporting.js.flow +4 -4
- package/src/lib/splitBundleOptions.d.ts +16 -0
- package/src/lib/transformHelpers.d.ts +35 -0
- package/src/lib/transformHelpers.js +11 -9
- package/src/lib/transformHelpers.js.flow +17 -15
- package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +126 -0
- package/src/node-haste/DependencyGraph/ModuleResolution.js +48 -42
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +35 -32
- package/src/node-haste/DependencyGraph/createFileMap.d.ts +29 -0
- package/src/node-haste/DependencyGraph/createFileMap.js +56 -38
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +44 -18
- package/src/node-haste/DependencyGraph.d.ts +57 -33
- package/src/node-haste/DependencyGraph.js +40 -31
- package/src/node-haste/DependencyGraph.js.flow +35 -37
- package/src/node-haste/Package.d.ts +21 -0
- package/src/node-haste/PackageCache.d.ts +34 -0
- package/src/node-haste/lib/AssetPaths.d.ts +29 -0
- package/src/node-haste/lib/AssetPaths.js +2 -2
- package/src/node-haste/lib/AssetPaths.js.flow +4 -4
- package/src/node-haste/lib/parsePlatformFilePath.d.ts +25 -0
- package/src/node-haste/lib/parsePlatformFilePath.js +6 -6
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +4 -4
- package/src/shared/output/RamBundle/as-assets.d.ts +25 -0
- package/src/shared/output/RamBundle/as-assets.js.flow +6 -6
- package/src/shared/output/RamBundle/as-indexed-file.d.ts +38 -0
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +5 -5
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.d.ts +23 -0
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +5 -5
- package/src/shared/output/RamBundle/magic-number.d.ts +14 -0
- package/src/shared/output/RamBundle/util.d.ts +41 -0
- package/src/shared/output/RamBundle/util.js.flow +5 -5
- package/src/shared/output/RamBundle/write-sourcemap.d.ts +16 -0
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
- package/src/shared/output/RamBundle.d.ts +26 -0
- package/src/shared/output/RamBundle.js.flow +1 -1
- package/src/shared/output/bundle.d.ts +9 -17
- package/src/shared/output/bundle.flow.js.flow +3 -3
- package/src/shared/output/meta.d.ts +15 -0
- package/src/shared/output/meta.js +2 -2
- package/src/shared/output/meta.js.flow +1 -1
- package/src/shared/output/unbundle.d.ts +11 -0
- package/src/shared/output/writeFile.d.ts +16 -0
- package/src/shared/output/writeFile.js +8 -3
- package/src/shared/output/writeFile.js.flow +8 -2
- package/src/shared/types.d.ts +81 -66
- package/src/shared/types.js.flow +20 -5
- package/src/Asset.d.ts +0 -25
- package/src/ModuleGraph/test-helpers.js +0 -75
|
@@ -8,91 +8,89 @@
|
|
|
8
8
|
* @oncall react_native
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type
|
|
11
|
+
import type {DeltaResult, Graph, Module} from './DeltaBundler';
|
|
12
12
|
import type {
|
|
13
13
|
Options as DeltaBundlerOptions,
|
|
14
14
|
ReadOnlyDependencies,
|
|
15
15
|
TransformInputOptions,
|
|
16
16
|
} from './DeltaBundler/types';
|
|
17
17
|
import type {GraphId} from './lib/getGraphId';
|
|
18
|
+
import type {ResolverInputOptions} from './shared/types';
|
|
18
19
|
import type {ConfigT} from 'metro-config';
|
|
19
20
|
|
|
20
|
-
import
|
|
21
|
-
import
|
|
21
|
+
import Bundler from './Bundler';
|
|
22
|
+
import DeltaBundler from './DeltaBundler';
|
|
22
23
|
|
|
23
|
-
export type RevisionId = string;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export interface GraphRevision {
|
|
24
|
+
export declare type RevisionId = string;
|
|
25
|
+
export type OutputGraph = Graph;
|
|
26
|
+
type OtherOptions = Readonly<{
|
|
27
|
+
onProgress: DeltaBundlerOptions['onProgress'];
|
|
28
|
+
shallow: boolean;
|
|
29
|
+
lazy: boolean;
|
|
30
|
+
}>;
|
|
31
|
+
export type GraphRevision = {
|
|
33
32
|
readonly id: RevisionId;
|
|
34
33
|
readonly date: Date;
|
|
35
34
|
readonly graphId: GraphId;
|
|
36
35
|
readonly graph: OutputGraph;
|
|
37
|
-
readonly prepend: ReadonlyArray<Module
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
readonly prepend: ReadonlyArray<Module>;
|
|
37
|
+
};
|
|
38
|
+
export type IncrementalBundlerOptions = Readonly<{
|
|
39
|
+
hasReducedPerformance?: boolean;
|
|
40
|
+
watch?: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
declare class IncrementalBundler {
|
|
43
|
+
_config: ConfigT;
|
|
44
|
+
_bundler: Bundler;
|
|
45
|
+
_deltaBundler: DeltaBundler;
|
|
46
|
+
_revisionsById: Map<RevisionId, Promise<GraphRevision>>;
|
|
47
|
+
_revisionsByGraphId: Map<GraphId, Promise<GraphRevision>>;
|
|
46
48
|
static revisionIdFromString: (str: string) => RevisionId;
|
|
47
49
|
constructor(config: ConfigT, options?: IncrementalBundlerOptions);
|
|
48
|
-
|
|
49
|
-
end(): void;
|
|
50
|
+
end(): Promise<void>;
|
|
50
51
|
getBundler(): Bundler;
|
|
51
|
-
getDeltaBundler(): DeltaBundler
|
|
52
|
-
getRevision(
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
getDeltaBundler(): DeltaBundler;
|
|
53
|
+
getRevision(
|
|
54
|
+
revisionId: RevisionId,
|
|
55
|
+
): null | undefined | Promise<GraphRevision>;
|
|
56
|
+
getRevisionByGraphId(
|
|
57
|
+
graphId: GraphId,
|
|
58
|
+
): null | undefined | Promise<GraphRevision>;
|
|
55
59
|
buildGraphForEntries(
|
|
56
60
|
entryFiles: ReadonlyArray<string>,
|
|
57
61
|
transformOptions: TransformInputOptions,
|
|
58
62
|
resolverOptions: ResolverInputOptions,
|
|
59
63
|
otherOptions?: OtherOptions,
|
|
60
64
|
): Promise<OutputGraph>;
|
|
61
|
-
|
|
62
65
|
getDependencies(
|
|
63
66
|
entryFiles: ReadonlyArray<string>,
|
|
64
67
|
transformOptions: TransformInputOptions,
|
|
65
68
|
resolverOptions: ResolverInputOptions,
|
|
66
69
|
otherOptions?: OtherOptions,
|
|
67
|
-
): Promise<ReadOnlyDependencies
|
|
68
|
-
|
|
70
|
+
): Promise<ReadOnlyDependencies>;
|
|
69
71
|
buildGraph(
|
|
70
72
|
entryFile: string,
|
|
71
73
|
transformOptions: TransformInputOptions,
|
|
72
74
|
resolverOptions: ResolverInputOptions,
|
|
73
75
|
otherOptions?: OtherOptions,
|
|
74
|
-
): Promise<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
): Promise<{
|
|
77
|
+
readonly graph: OutputGraph;
|
|
78
|
+
readonly prepend: ReadonlyArray<Module>;
|
|
79
|
+
}>;
|
|
78
80
|
initializeGraph(
|
|
79
81
|
entryFile: string,
|
|
80
82
|
transformOptions: TransformInputOptions,
|
|
81
83
|
resolverOptions: ResolverInputOptions,
|
|
82
84
|
otherOptions?: OtherOptions,
|
|
83
|
-
): Promise<{
|
|
84
|
-
delta: DeltaResult<void>;
|
|
85
|
-
revision: GraphRevision;
|
|
86
|
-
}>;
|
|
87
|
-
|
|
85
|
+
): Promise<{delta: DeltaResult; revision: GraphRevision}>;
|
|
88
86
|
updateGraph(
|
|
89
87
|
revision: GraphRevision,
|
|
90
88
|
reset: boolean,
|
|
91
|
-
): Promise<{
|
|
92
|
-
delta: DeltaResult<void>;
|
|
93
|
-
revision: GraphRevision;
|
|
94
|
-
}>;
|
|
95
|
-
|
|
89
|
+
): Promise<{delta: DeltaResult; revision: GraphRevision}>;
|
|
96
90
|
endGraph(graphId: GraphId): Promise<void>;
|
|
91
|
+
_getAbsoluteEntryFiles(
|
|
92
|
+
entryFiles: ReadonlyArray<string>,
|
|
93
|
+
): Promise<ReadonlyArray<string>>;
|
|
97
94
|
ready(): Promise<void>;
|
|
98
95
|
}
|
|
96
|
+
export default IncrementalBundler;
|
|
@@ -19,28 +19,32 @@ var transformHelpers = _interopRequireWildcard(
|
|
|
19
19
|
var _crypto = _interopRequireDefault(require("crypto"));
|
|
20
20
|
var _fs = _interopRequireDefault(require("fs"));
|
|
21
21
|
var _path = _interopRequireDefault(require("path"));
|
|
22
|
-
function
|
|
23
|
-
if ("function"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var n = { __proto__: null },
|
|
37
|
-
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
38
|
-
for (var u in e)
|
|
39
|
-
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
40
|
-
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
41
|
-
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
22
|
+
function _interopRequireWildcard(e, t) {
|
|
23
|
+
if ("function" == typeof WeakMap)
|
|
24
|
+
var r = new WeakMap(),
|
|
25
|
+
n = new WeakMap();
|
|
26
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
27
|
+
if (!t && e && e.__esModule) return e;
|
|
28
|
+
var o,
|
|
29
|
+
i,
|
|
30
|
+
f = { __proto__: null, default: e };
|
|
31
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
32
|
+
return f;
|
|
33
|
+
if ((o = t ? n : r)) {
|
|
34
|
+
if (o.has(e)) return o.get(e);
|
|
35
|
+
o.set(e, f);
|
|
42
36
|
}
|
|
43
|
-
|
|
37
|
+
for (const t in e)
|
|
38
|
+
"default" !== t &&
|
|
39
|
+
{}.hasOwnProperty.call(e, t) &&
|
|
40
|
+
((i =
|
|
41
|
+
(o = Object.defineProperty) &&
|
|
42
|
+
Object.getOwnPropertyDescriptor(e, t)) &&
|
|
43
|
+
(i.get || i.set)
|
|
44
|
+
? o(f, t, i)
|
|
45
|
+
: (f[t] = e[t]));
|
|
46
|
+
return f;
|
|
47
|
+
})(e, t);
|
|
44
48
|
}
|
|
45
49
|
function _interopRequireDefault(e) {
|
|
46
50
|
return e && e.__esModule ? e : { default: e };
|
|
@@ -108,6 +112,8 @@ class IncrementalBundler {
|
|
|
108
112
|
this._config.transformer.unstable_allowRequireContext,
|
|
109
113
|
unstable_enablePackageExports:
|
|
110
114
|
this._config.resolver.unstable_enablePackageExports,
|
|
115
|
+
unstable_incrementalResolution:
|
|
116
|
+
this._config.resolver.unstable_incrementalResolution,
|
|
111
117
|
shallow: otherOptions.shallow,
|
|
112
118
|
});
|
|
113
119
|
this._config.serializer.experimentalSerializerHook(graph, {
|
|
@@ -152,6 +158,8 @@ class IncrementalBundler {
|
|
|
152
158
|
this._config.transformer.unstable_allowRequireContext,
|
|
153
159
|
unstable_enablePackageExports:
|
|
154
160
|
this._config.resolver.unstable_enablePackageExports,
|
|
161
|
+
unstable_incrementalResolution:
|
|
162
|
+
this._config.resolver.unstable_incrementalResolution,
|
|
155
163
|
shallow: otherOptions.shallow,
|
|
156
164
|
},
|
|
157
165
|
);
|
|
@@ -33,7 +33,7 @@ export opaque type RevisionId: string = string;
|
|
|
33
33
|
|
|
34
34
|
export type OutputGraph = Graph<>;
|
|
35
35
|
|
|
36
|
-
type OtherOptions =
|
|
36
|
+
type OtherOptions = Readonly<{
|
|
37
37
|
onProgress: DeltaBundlerOptions<>['onProgress'],
|
|
38
38
|
shallow: boolean,
|
|
39
39
|
lazy: boolean,
|
|
@@ -45,10 +45,10 @@ export type GraphRevision = {
|
|
|
45
45
|
+date: Date,
|
|
46
46
|
+graphId: GraphId,
|
|
47
47
|
+graph: OutputGraph,
|
|
48
|
-
+prepend:
|
|
48
|
+
+prepend: ReadonlyArray<Module<>>,
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
export type IncrementalBundlerOptions =
|
|
51
|
+
export type IncrementalBundlerOptions = Readonly<{
|
|
52
52
|
hasReducedPerformance?: boolean,
|
|
53
53
|
watch?: boolean,
|
|
54
54
|
}>;
|
|
@@ -99,7 +99,7 @@ export default class IncrementalBundler {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
async buildGraphForEntries(
|
|
102
|
-
entryFiles:
|
|
102
|
+
entryFiles: ReadonlyArray<string>,
|
|
103
103
|
transformOptions: TransformInputOptions,
|
|
104
104
|
resolverOptions: ResolverInputOptions,
|
|
105
105
|
otherOptions?: OtherOptions = {
|
|
@@ -131,6 +131,8 @@ export default class IncrementalBundler {
|
|
|
131
131
|
this._config.transformer.unstable_allowRequireContext,
|
|
132
132
|
unstable_enablePackageExports:
|
|
133
133
|
this._config.resolver.unstable_enablePackageExports,
|
|
134
|
+
unstable_incrementalResolution:
|
|
135
|
+
this._config.resolver.unstable_incrementalResolution,
|
|
134
136
|
shallow: otherOptions.shallow,
|
|
135
137
|
});
|
|
136
138
|
|
|
@@ -145,7 +147,7 @@ export default class IncrementalBundler {
|
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
async getDependencies(
|
|
148
|
-
entryFiles:
|
|
150
|
+
entryFiles: ReadonlyArray<string>,
|
|
149
151
|
transformOptions: TransformInputOptions,
|
|
150
152
|
resolverOptions: ResolverInputOptions,
|
|
151
153
|
otherOptions?: OtherOptions = {
|
|
@@ -179,6 +181,8 @@ export default class IncrementalBundler {
|
|
|
179
181
|
this._config.transformer.unstable_allowRequireContext,
|
|
180
182
|
unstable_enablePackageExports:
|
|
181
183
|
this._config.resolver.unstable_enablePackageExports,
|
|
184
|
+
unstable_incrementalResolution:
|
|
185
|
+
this._config.resolver.unstable_incrementalResolution,
|
|
182
186
|
shallow: otherOptions.shallow,
|
|
183
187
|
},
|
|
184
188
|
);
|
|
@@ -195,7 +199,7 @@ export default class IncrementalBundler {
|
|
|
195
199
|
shallow: false,
|
|
196
200
|
lazy: false,
|
|
197
201
|
},
|
|
198
|
-
): Promise<{+graph: OutputGraph, +prepend:
|
|
202
|
+
): Promise<{+graph: OutputGraph, +prepend: ReadonlyArray<Module<>>}> {
|
|
199
203
|
const graph = await this.buildGraphForEntries(
|
|
200
204
|
[entryFile],
|
|
201
205
|
transformOptions,
|
|
@@ -330,8 +334,8 @@ export default class IncrementalBundler {
|
|
|
330
334
|
}
|
|
331
335
|
|
|
332
336
|
async _getAbsoluteEntryFiles(
|
|
333
|
-
entryFiles:
|
|
334
|
-
): Promise
|
|
337
|
+
entryFiles: ReadonlyArray<string>,
|
|
338
|
+
): Promise<ReadonlyArray<string>> {
|
|
335
339
|
const absoluteEntryFiles = entryFiles.map((entryFile: string) =>
|
|
336
340
|
path.resolve(
|
|
337
341
|
this._config.server.unstable_serverRoot ?? this._config.projectRoot,
|
|
@@ -342,7 +346,7 @@ export default class IncrementalBundler {
|
|
|
342
346
|
await Promise.all(
|
|
343
347
|
absoluteEntryFiles.map(
|
|
344
348
|
(entryFile: string) =>
|
|
345
|
-
new Promise((resolve: void => void, reject:
|
|
349
|
+
new Promise((resolve: void => void, reject: unknown => unknown) => {
|
|
346
350
|
// This should throw an error if the file doesn't exist.
|
|
347
351
|
// Using this instead of fs.exists to account for SimLinks.
|
|
348
352
|
fs.realpath(entryFile, err => {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type {File as BabelNodeFile} from '@babel/types';
|
|
11
|
+
|
|
12
|
+
declare const WRAP_NAME: '$$_REQUIRE';
|
|
13
|
+
declare function wrapModule(
|
|
14
|
+
fileAst: BabelNodeFile,
|
|
15
|
+
importDefaultName: string,
|
|
16
|
+
importAllName: string,
|
|
17
|
+
dependencyMapName: string,
|
|
18
|
+
globalPrefix: string,
|
|
19
|
+
skipRequireRename: boolean,
|
|
20
|
+
$$PARAM_6$$?: Readonly<{unstable_useStaticHermesModuleFactory?: boolean}>,
|
|
21
|
+
): {ast: BabelNodeFile; requireName: string};
|
|
22
|
+
declare function wrapPolyfill(fileAst: BabelNodeFile): BabelNodeFile;
|
|
23
|
+
declare function jsonToCommonJS(source: string): string;
|
|
24
|
+
declare function wrapJson(
|
|
25
|
+
source: string,
|
|
26
|
+
globalPrefix: string,
|
|
27
|
+
unstable_useStaticHermesModuleFactory?: boolean,
|
|
28
|
+
): string;
|
|
29
|
+
export {WRAP_NAME, wrapJson, jsonToCommonJS, wrapModule, wrapPolyfill};
|
|
@@ -12,28 +12,32 @@ var _template = _interopRequireDefault(require("@babel/template"));
|
|
|
12
12
|
var _traverse = _interopRequireDefault(require("@babel/traverse"));
|
|
13
13
|
var t = _interopRequireWildcard(require("@babel/types"));
|
|
14
14
|
var _invariant = _interopRequireDefault(require("invariant"));
|
|
15
|
-
function
|
|
16
|
-
if ("function"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var n = { __proto__: null },
|
|
30
|
-
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
31
|
-
for (var u in e)
|
|
32
|
-
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
33
|
-
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
34
|
-
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
15
|
+
function _interopRequireWildcard(e, t) {
|
|
16
|
+
if ("function" == typeof WeakMap)
|
|
17
|
+
var r = new WeakMap(),
|
|
18
|
+
n = new WeakMap();
|
|
19
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
20
|
+
if (!t && e && e.__esModule) return e;
|
|
21
|
+
var o,
|
|
22
|
+
i,
|
|
23
|
+
f = { __proto__: null, default: e };
|
|
24
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
25
|
+
return f;
|
|
26
|
+
if ((o = t ? n : r)) {
|
|
27
|
+
if (o.has(e)) return o.get(e);
|
|
28
|
+
o.set(e, f);
|
|
35
29
|
}
|
|
36
|
-
|
|
30
|
+
for (const t in e)
|
|
31
|
+
"default" !== t &&
|
|
32
|
+
{}.hasOwnProperty.call(e, t) &&
|
|
33
|
+
((i =
|
|
34
|
+
(o = Object.defineProperty) &&
|
|
35
|
+
Object.getOwnPropertyDescriptor(e, t)) &&
|
|
36
|
+
(i.get || i.set)
|
|
37
|
+
? o(f, t, i)
|
|
38
|
+
: (f[t] = e[t]));
|
|
39
|
+
return f;
|
|
40
|
+
})(e, t);
|
|
37
41
|
}
|
|
38
42
|
function _interopRequireDefault(e) {
|
|
39
43
|
return e && e.__esModule ? e : { default: e };
|
|
@@ -4,11 +4,16 @@
|
|
|
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.
|
|
6
6
|
*
|
|
7
|
-
* @format
|
|
8
7
|
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
File as BabelNodeFile,
|
|
13
|
+
FunctionExpression,
|
|
14
|
+
Identifier,
|
|
15
|
+
Program,
|
|
16
|
+
} from '@babel/types';
|
|
12
17
|
|
|
13
18
|
import template from '@babel/template';
|
|
14
19
|
import traverse from '@babel/traverse';
|
|
@@ -33,7 +38,7 @@ function wrapModule(
|
|
|
33
38
|
skipRequireRename: boolean,
|
|
34
39
|
{
|
|
35
40
|
unstable_useStaticHermesModuleFactory = false,
|
|
36
|
-
}:
|
|
41
|
+
}: Readonly<{unstable_useStaticHermesModuleFactory?: boolean}> = {},
|
|
37
42
|
): {
|
|
38
43
|
ast: BabelNodeFile,
|
|
39
44
|
requireName: string,
|
|
@@ -106,7 +111,7 @@ function wrapJson(
|
|
|
106
111
|
|
|
107
112
|
function functionFromProgram(
|
|
108
113
|
program: Program,
|
|
109
|
-
parameters:
|
|
114
|
+
parameters: ReadonlyArray<string>,
|
|
110
115
|
): FunctionExpression {
|
|
111
116
|
return t.functionExpression(
|
|
112
117
|
undefined,
|
|
@@ -123,7 +128,7 @@ function buildParameters(
|
|
|
123
128
|
importDefaultName: string,
|
|
124
129
|
importAllName: string,
|
|
125
130
|
dependencyMapName: string,
|
|
126
|
-
):
|
|
131
|
+
): ReadonlyArray<string> {
|
|
127
132
|
return [
|
|
128
133
|
'global',
|
|
129
134
|
'require',
|
|
@@ -5,23 +5,127 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
* @format
|
|
8
|
-
* @oncall react_native
|
|
9
8
|
*/
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
import type {ReadonlySourceLocation} from '../../shared/types';
|
|
11
|
+
import type {NodePath} from '@babel/traverse';
|
|
12
|
+
import type {
|
|
13
|
+
CallExpression,
|
|
14
|
+
File as BabelNodeFile,
|
|
15
|
+
Identifier,
|
|
16
|
+
StringLiteral,
|
|
17
|
+
} from '@babel/types';
|
|
18
|
+
import type {
|
|
19
|
+
AllowOptionalDependencies,
|
|
20
|
+
AsyncDependencyType,
|
|
21
|
+
} from 'metro/private/DeltaBundler/types';
|
|
17
22
|
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
export type Dependency = Readonly<{data: DependencyData; name: string}>;
|
|
24
|
+
export type ContextMode = 'sync' | 'eager' | 'lazy' | 'lazy-once';
|
|
25
|
+
type ContextFilter = Readonly<{pattern: string; flags: string}>;
|
|
26
|
+
export type RequireContextParams = Readonly<{
|
|
27
|
+
recursive: boolean;
|
|
28
|
+
filter: Readonly<ContextFilter>;
|
|
23
29
|
/** Mode for resolving dynamic dependencies. Defaults to `sync` */
|
|
24
|
-
|
|
30
|
+
mode: ContextMode;
|
|
31
|
+
}>;
|
|
32
|
+
type DependencyData = Readonly<{
|
|
33
|
+
key: string;
|
|
34
|
+
asyncType: AsyncDependencyType | null;
|
|
35
|
+
isESMImport: boolean;
|
|
36
|
+
isOptional?: boolean;
|
|
37
|
+
locs: ReadonlyArray<ReadonlySourceLocation>;
|
|
38
|
+
/** Context for requiring a collection of modules. */
|
|
39
|
+
contextParams?: RequireContextParams;
|
|
40
|
+
}>;
|
|
41
|
+
export type MutableInternalDependency = Omit<
|
|
42
|
+
DependencyData,
|
|
43
|
+
keyof {locs: Array<ReadonlySourceLocation>; index: number; name: string}
|
|
44
|
+
> & {locs: Array<ReadonlySourceLocation>; index: number; name: string};
|
|
45
|
+
export type InternalDependency = Readonly<MutableInternalDependency>;
|
|
46
|
+
export type State = {
|
|
47
|
+
asyncRequireModulePathStringLiteral: null | undefined | StringLiteral;
|
|
48
|
+
dependencyCalls: Set<string>;
|
|
49
|
+
dependencyRegistry: DependencyRegistry;
|
|
50
|
+
dependencyTransformer: DependencyTransformer;
|
|
51
|
+
dynamicRequires: DynamicRequiresBehavior;
|
|
52
|
+
dependencyMapIdentifier: null | undefined | Identifier;
|
|
53
|
+
keepRequireNames: boolean;
|
|
54
|
+
allowOptionalDependencies: AllowOptionalDependencies;
|
|
55
|
+
/** Enable `require.context` statements which can be used to import multiple files in a directory. */
|
|
56
|
+
unstable_allowRequireContext: boolean;
|
|
57
|
+
unstable_isESMImportAtSource:
|
|
58
|
+
| null
|
|
59
|
+
| undefined
|
|
60
|
+
| (($$PARAM_0$$: ReadonlySourceLocation) => boolean);
|
|
61
|
+
};
|
|
62
|
+
export type Options = Readonly<{
|
|
63
|
+
asyncRequireModulePath: string;
|
|
64
|
+
dependencyMapName: null | undefined | string;
|
|
65
|
+
dynamicRequires: DynamicRequiresBehavior;
|
|
66
|
+
inlineableCalls: ReadonlyArray<string>;
|
|
67
|
+
keepRequireNames: boolean;
|
|
68
|
+
allowOptionalDependencies: AllowOptionalDependencies;
|
|
69
|
+
dependencyTransformer?: DependencyTransformer;
|
|
70
|
+
/** Enable `require.context` statements which can be used to import multiple files in a directory. */
|
|
71
|
+
unstable_allowRequireContext: boolean;
|
|
72
|
+
unstable_isESMImportAtSource?:
|
|
73
|
+
| null
|
|
74
|
+
| undefined
|
|
75
|
+
| (($$PARAM_0$$: ReadonlySourceLocation) => boolean);
|
|
76
|
+
}>;
|
|
77
|
+
export type CollectedDependencies = Readonly<{
|
|
78
|
+
ast: BabelNodeFile;
|
|
79
|
+
dependencyMapName: string;
|
|
80
|
+
dependencies: ReadonlyArray<Dependency>;
|
|
81
|
+
}>;
|
|
82
|
+
export interface DependencyTransformer {
|
|
83
|
+
transformSyncRequire(
|
|
84
|
+
path: NodePath<CallExpression>,
|
|
85
|
+
dependency: InternalDependency,
|
|
86
|
+
state: State,
|
|
87
|
+
): void;
|
|
88
|
+
transformImportCall(
|
|
89
|
+
path: NodePath,
|
|
90
|
+
dependency: InternalDependency,
|
|
91
|
+
state: State,
|
|
92
|
+
): void;
|
|
93
|
+
transformImportMaybeSyncCall(
|
|
94
|
+
path: NodePath,
|
|
95
|
+
dependency: InternalDependency,
|
|
96
|
+
state: State,
|
|
97
|
+
): void;
|
|
98
|
+
transformPrefetch(
|
|
99
|
+
path: NodePath,
|
|
100
|
+
dependency: InternalDependency,
|
|
101
|
+
state: State,
|
|
102
|
+
): void;
|
|
103
|
+
transformIllegalDynamicRequire(path: NodePath, state: State): void;
|
|
25
104
|
}
|
|
26
|
-
|
|
27
105
|
export type DynamicRequiresBehavior = 'throwAtRuntime' | 'reject';
|
|
106
|
+
/**
|
|
107
|
+
* Transform all the calls to `require()` and `import()` in a file into ID-
|
|
108
|
+
* independent code, and return the list of dependencies. For example, a call
|
|
109
|
+
* like `require('Foo')` could be transformed to `require(_depMap[3], 'Foo')`
|
|
110
|
+
* where `_depMap` is provided by the outer scope. As such, we don't need to
|
|
111
|
+
* know the actual module ID.
|
|
112
|
+
*
|
|
113
|
+
* The second argument is only provided for debugging purposes.
|
|
114
|
+
*/
|
|
115
|
+
declare function collectDependencies(
|
|
116
|
+
ast: BabelNodeFile,
|
|
117
|
+
options: Options,
|
|
118
|
+
): CollectedDependencies;
|
|
119
|
+
export default collectDependencies;
|
|
120
|
+
export type ImportQualifier = Readonly<{
|
|
121
|
+
name: string;
|
|
122
|
+
asyncType: AsyncDependencyType | null;
|
|
123
|
+
isESMImport: boolean;
|
|
124
|
+
optional: boolean;
|
|
125
|
+
contextParams?: RequireContextParams;
|
|
126
|
+
}>;
|
|
127
|
+
declare class DependencyRegistry {
|
|
128
|
+
_dependencies: Map<string, InternalDependency>;
|
|
129
|
+
registerDependency(qualifier: ImportQualifier): InternalDependency;
|
|
130
|
+
getDependencies(): Array<InternalDependency>;
|
|
131
|
+
}
|
|
@@ -12,28 +12,32 @@ var types = _types;
|
|
|
12
12
|
var _crypto = _interopRequireDefault(require("crypto"));
|
|
13
13
|
var _invariant = _interopRequireDefault(require("invariant"));
|
|
14
14
|
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
15
|
-
function
|
|
16
|
-
if ("function"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var n = { __proto__: null },
|
|
30
|
-
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
31
|
-
for (var u in e)
|
|
32
|
-
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
33
|
-
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
34
|
-
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
15
|
+
function _interopRequireWildcard(e, t) {
|
|
16
|
+
if ("function" == typeof WeakMap)
|
|
17
|
+
var r = new WeakMap(),
|
|
18
|
+
n = new WeakMap();
|
|
19
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
20
|
+
if (!t && e && e.__esModule) return e;
|
|
21
|
+
var o,
|
|
22
|
+
i,
|
|
23
|
+
f = { __proto__: null, default: e };
|
|
24
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
25
|
+
return f;
|
|
26
|
+
if ((o = t ? n : r)) {
|
|
27
|
+
if (o.has(e)) return o.get(e);
|
|
28
|
+
o.set(e, f);
|
|
35
29
|
}
|
|
36
|
-
|
|
30
|
+
for (const t in e)
|
|
31
|
+
"default" !== t &&
|
|
32
|
+
{}.hasOwnProperty.call(e, t) &&
|
|
33
|
+
((i =
|
|
34
|
+
(o = Object.defineProperty) &&
|
|
35
|
+
Object.getOwnPropertyDescriptor(e, t)) &&
|
|
36
|
+
(i.get || i.set)
|
|
37
|
+
? o(f, t, i)
|
|
38
|
+
: (f[t] = e[t]));
|
|
39
|
+
return f;
|
|
40
|
+
})(e, t);
|
|
37
41
|
}
|
|
38
42
|
function _interopRequireDefault(e) {
|
|
39
43
|
return e && e.__esModule ? e : { default: e };
|