metro 0.66.2 → 0.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +22 -24
- package/src/Assets.js +9 -9
- package/src/Assets.js.flow +5 -7
- package/src/Bundler/util.js +16 -15
- package/src/Bundler/util.js.flow +11 -10
- package/src/Bundler.js +21 -8
- package/src/Bundler.js.flow +19 -7
- package/src/DeltaBundler/DeltaCalculator.js +15 -15
- package/src/DeltaBundler/DeltaCalculator.js.flow +7 -7
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js +13 -13
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js.flow +6 -7
- package/src/DeltaBundler/Serializers/baseJSBundle.js +4 -4
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +4 -4
- package/src/DeltaBundler/Serializers/getAllFiles.js +1 -1
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +3 -3
- package/src/DeltaBundler/Serializers/getAssets.js +3 -3
- package/src/DeltaBundler/Serializers/getAssets.js.flow +4 -5
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js +4 -4
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +4 -4
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js +20 -20
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +9 -10
- package/src/DeltaBundler/Serializers/helpers/bytecode.js +11 -11
- package/src/DeltaBundler/Serializers/helpers/bytecode.js.flow +5 -6
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js +1 -1
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js.flow +1 -1
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js +2 -2
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +4 -4
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js +1 -1
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js.flow +1 -1
- package/src/DeltaBundler/Serializers/helpers/js.js +6 -6
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +11 -12
- package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js +4 -4
- package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/helpers/processModules.js +4 -4
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +9 -9
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +9 -8
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +6 -6
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +3 -4
- package/src/DeltaBundler/Serializers/sourceMapObject.js +5 -5
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +4 -4
- package/src/DeltaBundler/Serializers/sourceMapString.js +2 -2
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +3 -3
- package/src/DeltaBundler/Transformer.js +9 -9
- package/src/DeltaBundler/Transformer.js.flow +7 -9
- package/src/DeltaBundler/Worker.js +8 -11
- package/src/DeltaBundler/Worker.js.flow +8 -11
- package/src/DeltaBundler/WorkerFarm.js +14 -17
- package/src/DeltaBundler/WorkerFarm.js.flow +7 -10
- package/src/DeltaBundler/__fixtures__/hasteImpl.js +2 -2
- package/src/DeltaBundler/computeDelta.js +2 -2
- package/src/DeltaBundler/computeDelta.js.flow +2 -2
- package/src/DeltaBundler/getTransformCacheKey.js +4 -4
- package/src/DeltaBundler/getTransformCacheKey.js.flow +5 -6
- package/src/DeltaBundler/mergeDeltas.js +2 -2
- package/src/DeltaBundler/mergeDeltas.js.flow +1 -1
- package/src/DeltaBundler/traverseDependencies.js +22 -22
- package/src/DeltaBundler/traverseDependencies.js.flow +3 -3
- package/src/DeltaBundler/types.flow.js +1 -1
- package/src/DeltaBundler/types.flow.js.flow +1 -1
- package/src/DeltaBundler.js +5 -5
- package/src/DeltaBundler.js.flow +4 -4
- package/src/HmrServer.js +71 -55
- package/src/HmrServer.js.flow +40 -37
- package/src/IncrementalBundler/GraphNotFoundError.js +1 -1
- package/src/IncrementalBundler/GraphNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler/ResourceNotFoundError.js +1 -1
- package/src/IncrementalBundler/ResourceNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler/RevisionNotFoundError.js +1 -1
- package/src/IncrementalBundler/RevisionNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler.js +44 -32
- package/src/IncrementalBundler.js.flow +30 -24
- package/src/ModuleGraph/module.js +3 -3
- package/src/ModuleGraph/module.js.flow +1 -1
- package/src/ModuleGraph/node-haste/HasteFS.js +2 -2
- package/src/ModuleGraph/node-haste/HasteFS.js.flow +1 -1
- package/src/ModuleGraph/node-haste/Module.js +1 -1
- package/src/ModuleGraph/node-haste/Module.js.flow +1 -1
- package/src/ModuleGraph/node-haste/ModuleCache.js +1 -1
- package/src/ModuleGraph/node-haste/ModuleCache.js.flow +3 -3
- package/src/ModuleGraph/node-haste/Package.js +3 -3
- package/src/ModuleGraph/node-haste/Package.js.flow +3 -3
- package/src/ModuleGraph/node-haste/node-haste.flow.js +1 -1
- package/src/ModuleGraph/node-haste/node-haste.flow.js.flow +1 -1
- package/src/ModuleGraph/node-haste/node-haste.js +42 -32
- package/src/ModuleGraph/node-haste/node-haste.js.flow +28 -23
- package/src/ModuleGraph/output/indexed-ram-bundle.js +17 -17
- package/src/ModuleGraph/output/indexed-ram-bundle.js.flow +41 -9
- package/src/ModuleGraph/output/multiple-files-ram-bundle.js +18 -18
- package/src/ModuleGraph/output/multiple-files-ram-bundle.js.flow +21 -9
- package/src/ModuleGraph/output/plain-bundle.js +6 -6
- package/src/ModuleGraph/output/plain-bundle.js.flow +7 -7
- package/src/ModuleGraph/output/reverse-dependency-map-references.js +3 -3
- package/src/ModuleGraph/output/reverse-dependency-map-references.js.flow +4 -8
- package/src/ModuleGraph/output/util.js +31 -30
- package/src/ModuleGraph/output/util.js.flow +15 -16
- package/src/ModuleGraph/silent-console.js +2 -2
- package/src/ModuleGraph/silent-console.js.flow +1 -1
- package/src/ModuleGraph/test-helpers.js +7 -7
- package/src/ModuleGraph/types.flow.js +1 -1
- package/src/ModuleGraph/types.flow.js.flow +7 -7
- package/src/ModuleGraph/worker/JsFileWrapping.js +7 -7
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +3 -2
- package/src/ModuleGraph/worker/Platforms.js +2 -2
- package/src/ModuleGraph/worker/Platforms.js.flow +1 -1
- package/src/ModuleGraph/worker/collectDependencies.js +24 -25
- package/src/ModuleGraph/worker/collectDependencies.js.flow +15 -17
- package/src/ModuleGraph/worker/generate.js +2 -2
- package/src/ModuleGraph/worker/generate.js.flow +3 -3
- package/src/ModuleGraph/worker/generateImportNames.js +5 -5
- package/src/ModuleGraph/worker/generateImportNames.js.flow +3 -5
- package/src/ModuleGraph/worker/mergeSourceMaps.js +8 -7
- package/src/ModuleGraph/worker/mergeSourceMaps.js.flow +3 -3
- package/src/Server/MultipartResponse.js +4 -8
- package/src/Server/symbolicate.js +8 -8
- package/src/Server/symbolicate.js.flow +17 -5
- package/src/Server.js +202 -150
- package/src/Server.js.flow +129 -87
- package/src/cli-utils.js +4 -4
- package/src/cli-utils.js.flow +15 -13
- package/src/cli.js +4 -4
- package/src/cli.js.flow +2 -4
- package/src/commands/build.js +23 -24
- package/src/commands/build.js.flow +6 -9
- package/src/commands/dependencies.js +25 -19
- package/src/commands/serve.js +17 -18
- package/src/commands/serve.js.flow +6 -9
- package/src/index.js +116 -51
- package/src/index.js.flow +107 -41
- package/src/integration_tests/basic_bundle/AssetRegistry.js +2 -2
- package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +1 -1
- package/src/integration_tests/basic_bundle/Bar.js +2 -2
- package/src/integration_tests/basic_bundle/Bar.js.flow +1 -1
- package/src/integration_tests/basic_bundle/ErrorBundle.js +2 -2
- package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +1 -1
- package/src/integration_tests/basic_bundle/Foo.js +2 -2
- package/src/integration_tests/basic_bundle/Foo.js.flow +1 -1
- package/src/integration_tests/basic_bundle/TestBundle.js +3 -2
- package/src/integration_tests/basic_bundle/TestBundle.js.flow +3 -1
- package/src/integration_tests/basic_bundle/TestPolyfill.js +1 -1
- package/src/integration_tests/basic_bundle/TestPolyfill.js.flow +1 -1
- package/src/integration_tests/basic_bundle/TypeScript.ts +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-1.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-1.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-2.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-2.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-3.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-3.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-4.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-4.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-5.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-5.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-6.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-6.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-null.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-null.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/index.js +8 -8
- package/src/integration_tests/basic_bundle/import-export/index.js.flow +1 -1
- package/src/integration_tests/basic_bundle/polyfill.js +1 -1
- package/src/integration_tests/execBundle.js +2 -2
- package/src/integration_tests/execBundle.js.flow +1 -1
- package/src/integration_tests/metro.config.js +8 -8
- package/src/lib/BatchProcessor.js +3 -3
- package/src/lib/BatchProcessor.js.flow +1 -1
- package/src/lib/JsonReporter.js +2 -2
- package/src/lib/JsonReporter.js.flow +1 -1
- package/src/lib/RamBundleParser.js +1 -1
- package/src/lib/RamBundleParser.js.flow +1 -1
- package/src/lib/TerminalReporter.js +14 -14
- package/src/lib/TerminalReporter.js.flow +9 -10
- package/src/lib/bundleToBytecode.js +6 -7
- package/src/lib/bundleToBytecode.js.flow +8 -7
- package/src/lib/bundleToString.js +3 -3
- package/src/lib/bundleToString.js.flow +5 -4
- package/src/lib/countLines.js +3 -7
- package/src/lib/countLines.js.flow +4 -7
- package/src/lib/createModuleIdFactory.js +2 -2
- package/src/lib/createModuleIdFactory.js.flow +1 -1
- package/src/lib/{attachWebsocketServer.js → createWebsocketServer.js} +18 -17
- package/src/lib/{attachWebsocketServer.js.flow → createWebsocketServer.js.flow} +12 -21
- package/src/lib/debounceAsyncQueue.js +2 -2
- package/src/lib/debounceAsyncQueue.js.flow +1 -1
- package/src/lib/formatBundlingError.js +21 -21
- package/src/lib/formatBundlingError.js.flow +6 -8
- package/src/lib/getAppendScripts.js +26 -27
- package/src/lib/getAppendScripts.js.flow +7 -8
- package/src/lib/getGraphId.js +3 -3
- package/src/lib/getGraphId.js.flow +3 -3
- package/src/lib/getMaxWorkers.js +2 -2
- package/src/lib/getMaxWorkers.js.flow +1 -1
- package/src/lib/getPreludeCode.js +2 -2
- package/src/lib/getPreludeCode.js.flow +1 -1
- package/src/lib/getPrependedScripts.js +15 -15
- package/src/lib/getPrependedScripts.js.flow +7 -8
- package/src/lib/logToConsole.js +1 -1
- package/src/lib/logToConsole.js.flow +3 -3
- package/src/lib/parseCustomTransformOptions.js +2 -2
- package/src/lib/parseCustomTransformOptions.js.flow +3 -3
- package/src/lib/parseOptionsFromUrl.js +7 -7
- package/src/lib/parseOptionsFromUrl.js.flow +29 -9
- package/src/lib/relativizeSourceMap.js +1 -1
- package/src/lib/relativizeSourceMap.js.flow +3 -3
- package/src/lib/reporting.js +5 -5
- package/src/lib/reporting.js.flow +16 -3
- package/src/lib/splitBundleOptions.js +5 -5
- package/src/lib/splitBundleOptions.js.flow +1 -1
- package/src/lib/transformHelpers.js +10 -10
- package/src/lib/transformHelpers.js.flow +5 -5
- package/src/node-haste/DependencyGraph/ModuleResolution.js +51 -30
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +46 -42
- package/src/node-haste/DependencyGraph/createHasteMap.js +99 -0
- package/src/node-haste/DependencyGraph/createHasteMap.js.flow +88 -0
- package/src/node-haste/DependencyGraph/{assets/empty-module.js → types.js} +2 -2
- package/src/node-haste/DependencyGraph/types.js.flow +88 -0
- package/src/node-haste/DependencyGraph.js +49 -117
- package/src/node-haste/DependencyGraph.js.flow +36 -111
- package/src/node-haste/Module.js +1 -1
- package/src/node-haste/Module.js.flow +3 -3
- package/src/node-haste/ModuleCache.js +54 -13
- package/src/node-haste/ModuleCache.js.flow +53 -12
- package/src/node-haste/Package.js +7 -9
- package/src/node-haste/Package.js.flow +1 -8
- package/src/node-haste/lib/AssetPaths.js +5 -5
- package/src/node-haste/lib/AssetPaths.js.flow +2 -4
- package/src/node-haste/lib/parsePlatformFilePath.js +4 -4
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +1 -1
- package/src/shared/output/RamBundle/as-assets.js +16 -17
- package/src/shared/output/RamBundle/as-assets.js.flow +11 -15
- package/src/shared/output/RamBundle/as-indexed-file.js +14 -15
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +8 -12
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js +7 -7
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +4 -4
- package/src/shared/output/RamBundle/magic-number.js +1 -1
- package/src/shared/output/RamBundle/magic-number.js.flow +1 -1
- package/src/shared/output/RamBundle/util.js +21 -19
- package/src/shared/output/RamBundle/util.js.flow +5 -8
- package/src/shared/output/RamBundle/write-sourcemap.js +1 -1
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
- package/src/shared/output/RamBundle.js +2 -2
- package/src/shared/output/RamBundle.js.flow +4 -5
- package/src/shared/output/bundle.js +6 -6
- package/src/shared/output/bundle.js.flow +4 -5
- package/src/shared/output/meta.js +4 -5
- package/src/shared/output/meta.js.flow +2 -4
- package/src/shared/output/unbundle.js +1 -1
- package/src/shared/output/unbundle.js.flow +1 -1
- package/src/shared/output/writeFile.js +1 -1
- package/src/shared/output/writeFile.js.flow +1 -1
- package/src/shared/types.flow.js +1 -1
- package/src/shared/types.flow.js.flow +2 -2
- package/src/node-haste/DependencyGraph/assets/empty-module.js.flow +0 -9
- package/src/node-haste/types.js +0 -10
- package/src/node-haste/types.js.flow +0 -23
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -15,18 +15,18 @@ const DeltaBundler = require("./DeltaBundler");
|
|
|
15
15
|
|
|
16
16
|
const ResourceNotFoundError = require("./IncrementalBundler/ResourceNotFoundError");
|
|
17
17
|
|
|
18
|
-
const crypto = require("crypto");
|
|
19
|
-
|
|
20
|
-
const fs = require("fs");
|
|
21
|
-
|
|
22
18
|
const getGraphId = require("./lib/getGraphId");
|
|
23
19
|
|
|
24
20
|
const getPrependedScripts = require("./lib/getPrependedScripts");
|
|
25
21
|
|
|
26
|
-
const path = require("path");
|
|
27
|
-
|
|
28
22
|
const transformHelpers = require("./lib/transformHelpers");
|
|
29
23
|
|
|
24
|
+
const crypto = require("crypto");
|
|
25
|
+
|
|
26
|
+
const fs = require("fs");
|
|
27
|
+
|
|
28
|
+
const path = require("path");
|
|
29
|
+
|
|
30
30
|
function createRevisionId() {
|
|
31
31
|
return crypto.randomBytes(8).toString("hex");
|
|
32
32
|
}
|
|
@@ -73,7 +73,7 @@ class IncrementalBundler {
|
|
|
73
73
|
transformOptions,
|
|
74
74
|
otherOptions = {
|
|
75
75
|
onProgress: null,
|
|
76
|
-
shallow: false
|
|
76
|
+
shallow: false,
|
|
77
77
|
}
|
|
78
78
|
) {
|
|
79
79
|
const absoluteEntryFiles = await this._getAbsoluteEntryFiles(entryFiles);
|
|
@@ -91,16 +91,16 @@ class IncrementalBundler {
|
|
|
91
91
|
),
|
|
92
92
|
transformOptions,
|
|
93
93
|
onProgress: otherOptions.onProgress,
|
|
94
|
-
experimentalImportBundleSupport:
|
|
95
|
-
.experimentalImportBundleSupport,
|
|
96
|
-
shallow: otherOptions.shallow
|
|
94
|
+
experimentalImportBundleSupport:
|
|
95
|
+
this._config.transformer.experimentalImportBundleSupport,
|
|
96
|
+
shallow: otherOptions.shallow,
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
this._config.serializer.experimentalSerializerHook(graph, {
|
|
100
100
|
added: graph.dependencies,
|
|
101
101
|
modified: new Map(),
|
|
102
102
|
deleted: new Set(),
|
|
103
|
-
reset: true
|
|
103
|
+
reset: true,
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
return graph;
|
|
@@ -111,7 +111,7 @@ class IncrementalBundler {
|
|
|
111
111
|
transformOptions,
|
|
112
112
|
otherOptions = {
|
|
113
113
|
onProgress: null,
|
|
114
|
-
shallow: false
|
|
114
|
+
shallow: false,
|
|
115
115
|
}
|
|
116
116
|
) {
|
|
117
117
|
const absoluteEntryFiles = await this._getAbsoluteEntryFiles(entryFiles);
|
|
@@ -131,9 +131,9 @@ class IncrementalBundler {
|
|
|
131
131
|
),
|
|
132
132
|
transformOptions,
|
|
133
133
|
onProgress: otherOptions.onProgress,
|
|
134
|
-
experimentalImportBundleSupport:
|
|
135
|
-
.experimentalImportBundleSupport,
|
|
136
|
-
shallow: otherOptions.shallow
|
|
134
|
+
experimentalImportBundleSupport:
|
|
135
|
+
this._config.transformer.experimentalImportBundleSupport,
|
|
136
|
+
shallow: otherOptions.shallow,
|
|
137
137
|
}
|
|
138
138
|
);
|
|
139
139
|
return dependencies;
|
|
@@ -144,7 +144,7 @@ class IncrementalBundler {
|
|
|
144
144
|
transformOptions,
|
|
145
145
|
otherOptions = {
|
|
146
146
|
onProgress: null,
|
|
147
|
-
shallow: false
|
|
147
|
+
shallow: false,
|
|
148
148
|
}
|
|
149
149
|
) {
|
|
150
150
|
const graph = await this.buildGraphForEntries(
|
|
@@ -161,7 +161,7 @@ class IncrementalBundler {
|
|
|
161
161
|
);
|
|
162
162
|
return {
|
|
163
163
|
prepend,
|
|
164
|
-
graph
|
|
164
|
+
graph,
|
|
165
165
|
};
|
|
166
166
|
} // TODO T34760750 (alexkirsz) Eventually, I'd like to get to a point where
|
|
167
167
|
// this class exposes only initializeGraph and updateGraph.
|
|
@@ -171,13 +171,13 @@ class IncrementalBundler {
|
|
|
171
171
|
transformOptions,
|
|
172
172
|
otherOptions = {
|
|
173
173
|
onProgress: null,
|
|
174
|
-
shallow: false
|
|
174
|
+
shallow: false,
|
|
175
175
|
}
|
|
176
176
|
) {
|
|
177
177
|
const graphId = getGraphId(entryFile, transformOptions, {
|
|
178
178
|
shallow: otherOptions.shallow,
|
|
179
|
-
experimentalImportBundleSupport:
|
|
180
|
-
.experimentalImportBundleSupport
|
|
179
|
+
experimentalImportBundleSupport:
|
|
180
|
+
this._config.transformer.experimentalImportBundleSupport,
|
|
181
181
|
});
|
|
182
182
|
const revisionId = createRevisionId();
|
|
183
183
|
|
|
@@ -192,7 +192,7 @@ class IncrementalBundler {
|
|
|
192
192
|
date: new Date(),
|
|
193
193
|
graphId,
|
|
194
194
|
graph,
|
|
195
|
-
prepend
|
|
195
|
+
prepend,
|
|
196
196
|
};
|
|
197
197
|
})();
|
|
198
198
|
|
|
@@ -206,11 +206,11 @@ class IncrementalBundler {
|
|
|
206
206
|
added: revision.graph.dependencies,
|
|
207
207
|
modified: new Map(),
|
|
208
208
|
deleted: new Set(),
|
|
209
|
-
reset: true
|
|
209
|
+
reset: true,
|
|
210
210
|
};
|
|
211
211
|
return {
|
|
212
212
|
revision,
|
|
213
|
-
delta
|
|
213
|
+
delta,
|
|
214
214
|
};
|
|
215
215
|
} catch (err) {
|
|
216
216
|
// Evict a bad revision from the cache since otherwise
|
|
@@ -226,7 +226,7 @@ class IncrementalBundler {
|
|
|
226
226
|
async updateGraph(revision, reset) {
|
|
227
227
|
const delta = await this._deltaBundler.getDelta(revision.graph, {
|
|
228
228
|
reset,
|
|
229
|
-
shallow: false
|
|
229
|
+
shallow: false,
|
|
230
230
|
});
|
|
231
231
|
|
|
232
232
|
this._config.serializer.experimentalSerializerHook(revision.graph, delta);
|
|
@@ -243,7 +243,7 @@ class IncrementalBundler {
|
|
|
243
243
|
// Generate a new revision id, to be used to verify the next incremental
|
|
244
244
|
// request.
|
|
245
245
|
id: crypto.randomBytes(8).toString("hex"),
|
|
246
|
-
date: new Date()
|
|
246
|
+
date: new Date(),
|
|
247
247
|
};
|
|
248
248
|
const revisionPromise = Promise.resolve(revision);
|
|
249
249
|
|
|
@@ -254,7 +254,7 @@ class IncrementalBundler {
|
|
|
254
254
|
|
|
255
255
|
return {
|
|
256
256
|
revision,
|
|
257
|
-
delta
|
|
257
|
+
delta,
|
|
258
258
|
};
|
|
259
259
|
}
|
|
260
260
|
|
|
@@ -275,16 +275,24 @@ class IncrementalBundler {
|
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
async _getAbsoluteEntryFiles(entryFiles) {
|
|
278
|
-
const absoluteEntryFiles = entryFiles.map(entryFile =>
|
|
279
|
-
|
|
280
|
-
|
|
278
|
+
const absoluteEntryFiles = entryFiles.map((entryFile) => {
|
|
279
|
+
var _this$_config$server$;
|
|
280
|
+
|
|
281
|
+
return path.resolve(
|
|
282
|
+
(_this$_config$server$ = this._config.server.unstable_serverRoot) !==
|
|
283
|
+
null && _this$_config$server$ !== void 0
|
|
284
|
+
? _this$_config$server$
|
|
285
|
+
: this._config.projectRoot,
|
|
286
|
+
entryFile
|
|
287
|
+
);
|
|
288
|
+
});
|
|
281
289
|
await Promise.all(
|
|
282
290
|
absoluteEntryFiles.map(
|
|
283
|
-
entryFile =>
|
|
291
|
+
(entryFile) =>
|
|
284
292
|
new Promise((resolve, reject) => {
|
|
285
293
|
// This should throw an error if the file doesn't exist.
|
|
286
294
|
// Using this instead of fs.exists to account for SimLinks.
|
|
287
|
-
fs.realpath(entryFile, err => {
|
|
295
|
+
fs.realpath(entryFile, (err) => {
|
|
288
296
|
if (err) {
|
|
289
297
|
reject(new ResourceNotFoundError(entryFile));
|
|
290
298
|
} else {
|
|
@@ -295,6 +303,10 @@ class IncrementalBundler {
|
|
|
295
303
|
)
|
|
296
304
|
);
|
|
297
305
|
return absoluteEntryFiles;
|
|
306
|
+
} // Wait for the bundler to become ready.
|
|
307
|
+
|
|
308
|
+
async ready() {
|
|
309
|
+
await this._bundler.ready();
|
|
298
310
|
}
|
|
299
311
|
}
|
|
300
312
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -10,26 +10,25 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
const DeltaBundler = require('./DeltaBundler');
|
|
15
|
-
const ResourceNotFoundError = require('./IncrementalBundler/ResourceNotFoundError');
|
|
16
|
-
|
|
17
|
-
const crypto = require('crypto');
|
|
18
|
-
const fs = require('fs');
|
|
19
|
-
const getGraphId = require('./lib/getGraphId');
|
|
20
|
-
const getPrependedScripts = require('./lib/getPrependedScripts');
|
|
21
|
-
const path = require('path');
|
|
22
|
-
const transformHelpers = require('./lib/transformHelpers');
|
|
23
|
-
|
|
13
|
+
import type {DeltaResult, Graph, Module} from './DeltaBundler';
|
|
24
14
|
import type {
|
|
15
|
+
Dependencies,
|
|
25
16
|
Options as DeltaBundlerOptions,
|
|
26
17
|
TransformInputOptions,
|
|
27
|
-
Dependencies,
|
|
28
18
|
} from './DeltaBundler/types.flow';
|
|
29
|
-
import type {DeltaResult, Module, Graph} from './DeltaBundler';
|
|
30
19
|
import type {GraphId} from './lib/getGraphId';
|
|
31
20
|
import type {ConfigT} from 'metro-config/src/configTypes.flow';
|
|
32
21
|
|
|
22
|
+
const Bundler = require('./Bundler');
|
|
23
|
+
const DeltaBundler = require('./DeltaBundler');
|
|
24
|
+
const ResourceNotFoundError = require('./IncrementalBundler/ResourceNotFoundError');
|
|
25
|
+
const getGraphId = require('./lib/getGraphId');
|
|
26
|
+
const getPrependedScripts = require('./lib/getPrependedScripts');
|
|
27
|
+
const transformHelpers = require('./lib/transformHelpers');
|
|
28
|
+
const crypto = require('crypto');
|
|
29
|
+
const fs = require('fs');
|
|
30
|
+
const path = require('path');
|
|
31
|
+
|
|
33
32
|
export opaque type RevisionId: string = string;
|
|
34
33
|
|
|
35
34
|
export type OutputGraph = Graph<>;
|
|
@@ -68,9 +67,8 @@ class IncrementalBundler {
|
|
|
68
67
|
_revisionsById: Map<RevisionId, Promise<GraphRevision>> = new Map();
|
|
69
68
|
_revisionsByGraphId: Map<GraphId, Promise<GraphRevision>> = new Map();
|
|
70
69
|
|
|
71
|
-
static revisionIdFromString: (
|
|
72
|
-
|
|
73
|
-
) => RevisionId = revisionIdFromString;
|
|
70
|
+
static revisionIdFromString: (str: string) => RevisionId =
|
|
71
|
+
revisionIdFromString;
|
|
74
72
|
|
|
75
73
|
constructor(config: ConfigT, options?: IncrementalBundlerOptions) {
|
|
76
74
|
this._config = config;
|
|
@@ -123,8 +121,8 @@ class IncrementalBundler {
|
|
|
123
121
|
),
|
|
124
122
|
transformOptions,
|
|
125
123
|
onProgress: otherOptions.onProgress,
|
|
126
|
-
experimentalImportBundleSupport:
|
|
127
|
-
.experimentalImportBundleSupport,
|
|
124
|
+
experimentalImportBundleSupport:
|
|
125
|
+
this._config.transformer.experimentalImportBundleSupport,
|
|
128
126
|
shallow: otherOptions.shallow,
|
|
129
127
|
});
|
|
130
128
|
|
|
@@ -164,8 +162,8 @@ class IncrementalBundler {
|
|
|
164
162
|
),
|
|
165
163
|
transformOptions,
|
|
166
164
|
onProgress: otherOptions.onProgress,
|
|
167
|
-
experimentalImportBundleSupport:
|
|
168
|
-
.experimentalImportBundleSupport,
|
|
165
|
+
experimentalImportBundleSupport:
|
|
166
|
+
this._config.transformer.experimentalImportBundleSupport,
|
|
169
167
|
shallow: otherOptions.shallow,
|
|
170
168
|
},
|
|
171
169
|
);
|
|
@@ -218,8 +216,8 @@ class IncrementalBundler {
|
|
|
218
216
|
}> {
|
|
219
217
|
const graphId = getGraphId(entryFile, transformOptions, {
|
|
220
218
|
shallow: otherOptions.shallow,
|
|
221
|
-
experimentalImportBundleSupport:
|
|
222
|
-
.experimentalImportBundleSupport,
|
|
219
|
+
experimentalImportBundleSupport:
|
|
220
|
+
this._config.transformer.experimentalImportBundleSupport,
|
|
223
221
|
});
|
|
224
222
|
const revisionId = createRevisionId();
|
|
225
223
|
const revisionPromise = (async () => {
|
|
@@ -311,7 +309,10 @@ class IncrementalBundler {
|
|
|
311
309
|
entryFiles: $ReadOnlyArray<string>,
|
|
312
310
|
): Promise<$ReadOnlyArray<string>> {
|
|
313
311
|
const absoluteEntryFiles = entryFiles.map((entryFile: string) =>
|
|
314
|
-
path.resolve(
|
|
312
|
+
path.resolve(
|
|
313
|
+
this._config.server.unstable_serverRoot ?? this._config.projectRoot,
|
|
314
|
+
entryFile,
|
|
315
|
+
),
|
|
315
316
|
);
|
|
316
317
|
|
|
317
318
|
await Promise.all(
|
|
@@ -333,6 +334,11 @@ class IncrementalBundler {
|
|
|
333
334
|
|
|
334
335
|
return absoluteEntryFiles;
|
|
335
336
|
}
|
|
337
|
+
|
|
338
|
+
// Wait for the bundler to become ready.
|
|
339
|
+
async ready(): Promise<void> {
|
|
340
|
+
await this._bundler.ready();
|
|
341
|
+
}
|
|
336
342
|
}
|
|
337
343
|
|
|
338
344
|
module.exports = IncrementalBundler;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -20,8 +20,8 @@ const virtual = (code, filePath) => ({
|
|
|
20
20
|
functionMap: null,
|
|
21
21
|
path: filePath,
|
|
22
22
|
type: "script",
|
|
23
|
-
libraryIdx: null
|
|
24
|
-
}
|
|
23
|
+
libraryIdx: null,
|
|
24
|
+
},
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
exports.virtual = virtual;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -62,7 +62,7 @@ module.exports = class HasteFS {
|
|
|
62
62
|
|
|
63
63
|
function buildDirectorySet(files) {
|
|
64
64
|
const directories = new Set();
|
|
65
|
-
files.forEach(path => {
|
|
65
|
+
files.forEach((path) => {
|
|
66
66
|
const parsedPath = parse(path);
|
|
67
67
|
const root = parsedPath.root;
|
|
68
68
|
let dir = parsedPath.dir;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
+
import type {PackageData, TransformedCodeFile} from '../types.flow';
|
|
14
|
+
|
|
13
15
|
const Module = require('./Module');
|
|
14
16
|
const Package = require('./Package');
|
|
15
17
|
|
|
16
|
-
import type {PackageData, TransformedCodeFile} from '../types.flow';
|
|
17
|
-
|
|
18
18
|
type GetClosestPackageFn = (filePath: string) => ?string;
|
|
19
19
|
|
|
20
20
|
module.exports = class ModuleCache {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -113,13 +113,13 @@ function getReplacements(pkg) {
|
|
|
113
113
|
|
|
114
114
|
if (typeof rn !== "object") {
|
|
115
115
|
rn = {
|
|
116
|
-
[main]: rn
|
|
116
|
+
[main]: rn,
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
if (typeof browser !== "object") {
|
|
121
121
|
browser = {
|
|
122
|
-
[main]: browser
|
|
122
|
+
[main]: browser,
|
|
123
123
|
};
|
|
124
124
|
} // merge with "browser" as default,
|
|
125
125
|
// "react-native" as override
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
+
import type {PackageData} from '../types.flow';
|
|
14
|
+
|
|
13
15
|
const nullthrows = require('nullthrows');
|
|
14
16
|
const path = require('path');
|
|
15
17
|
|
|
16
|
-
import type {PackageData} from '../types.flow';
|
|
17
|
-
|
|
18
18
|
module.exports = class Package {
|
|
19
19
|
data: PackageData;
|
|
20
20
|
path: string;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _jestHasteMap = require("jest-haste-map");
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
|
-
* Copyright (c)
|
|
6
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
7
|
*
|
|
4
8
|
* This source code is licensed under the MIT license found in the
|
|
5
9
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -7,7 +11,11 @@
|
|
|
7
11
|
*
|
|
8
12
|
* @format
|
|
9
13
|
*/
|
|
10
|
-
|
|
14
|
+
const {
|
|
15
|
+
ModuleResolver,
|
|
16
|
+
} = require("../../node-haste/DependencyGraph/ModuleResolution");
|
|
17
|
+
|
|
18
|
+
const parsePlatformFilePath = require("../../node-haste/lib/parsePlatformFilePath");
|
|
11
19
|
|
|
12
20
|
const HasteFS = require("./HasteFS");
|
|
13
21
|
|
|
@@ -17,17 +25,9 @@ const ModuleCache = require("./ModuleCache");
|
|
|
17
25
|
|
|
18
26
|
const defaults = require("metro-config/src/defaults/defaults");
|
|
19
27
|
|
|
20
|
-
const parsePlatformFilePath = require("../../node-haste/lib/parsePlatformFilePath");
|
|
21
|
-
|
|
22
28
|
const path = require("path");
|
|
23
29
|
|
|
24
|
-
const
|
|
25
|
-
ModuleResolver
|
|
26
|
-
} = require("../../node-haste/DependencyGraph/ModuleResolution");
|
|
27
|
-
|
|
28
|
-
const { ModuleMap } = require("jest-haste-map");
|
|
29
|
-
|
|
30
|
-
const platforms = new Set(defaults.platforms);
|
|
30
|
+
const NATIVE_PLATFORM = "native";
|
|
31
31
|
const GENERIC_PLATFORM = "g";
|
|
32
32
|
const PACKAGE_JSON = path.sep + "package.json";
|
|
33
33
|
const NULL_MODULE = {
|
|
@@ -41,15 +41,21 @@ const NULL_MODULE = {
|
|
|
41
41
|
|
|
42
42
|
getName() {
|
|
43
43
|
throw new Error("not implemented");
|
|
44
|
-
}
|
|
44
|
+
},
|
|
45
45
|
};
|
|
46
46
|
const NODE_MODULES = path.sep + "node_modules" + path.sep;
|
|
47
47
|
|
|
48
|
-
const isNodeModules = file => file.includes(NODE_MODULES); // This function maps the ModuleGraph data structure to jest-haste-map's ModuleMap
|
|
48
|
+
const isNodeModules = (file) => file.includes(NODE_MODULES); // This function maps the ModuleGraph data structure to jest-haste-map's ModuleMap
|
|
49
49
|
|
|
50
|
-
const createModuleMap = ({ files, moduleCache, sourceExts }) => {
|
|
50
|
+
const createModuleMap = ({ files, moduleCache, sourceExts, platforms }) => {
|
|
51
|
+
const platformSet = new Set(
|
|
52
|
+
(platforms !== null && platforms !== void 0
|
|
53
|
+
? platforms
|
|
54
|
+
: defaults.platforms
|
|
55
|
+
).concat([NATIVE_PLATFORM])
|
|
56
|
+
);
|
|
51
57
|
const map = new Map();
|
|
52
|
-
files.forEach(filePath => {
|
|
58
|
+
files.forEach((filePath) => {
|
|
53
59
|
if (isNodeModules(filePath)) {
|
|
54
60
|
return;
|
|
55
61
|
}
|
|
@@ -71,7 +77,7 @@ const createModuleMap = ({ files, moduleCache, sourceExts }) => {
|
|
|
71
77
|
|
|
72
78
|
const mapModule = map.get(id) || Object.create(null);
|
|
73
79
|
const platform =
|
|
74
|
-
parsePlatformFilePath(filePath,
|
|
80
|
+
parsePlatformFilePath(filePath, platformSet).platform || GENERIC_PLATFORM;
|
|
75
81
|
const existingModule = mapModule[platform]; // 0 = Module, 1 = Package in jest-haste-map
|
|
76
82
|
|
|
77
83
|
mapModule[platform] = [filePath, module.type === "Package" ? 1 : 0];
|
|
@@ -79,12 +85,12 @@ const createModuleMap = ({ files, moduleCache, sourceExts }) => {
|
|
|
79
85
|
if (existingModule && existingModule[0] !== filePath) {
|
|
80
86
|
throw new Error(
|
|
81
87
|
[
|
|
82
|
-
"@providesModule naming collision:",
|
|
88
|
+
"@providesModule naming collision:",
|
|
83
89
|
` Duplicate module name: \`${id}\``,
|
|
84
90
|
` Paths: \`${filePath}\` collides with \`${existingModule[0]}\``,
|
|
85
91
|
"",
|
|
86
92
|
"This error is caused by a @providesModule declaration " +
|
|
87
|
-
"with the same name across two different files."
|
|
93
|
+
"with the same name across two different files.",
|
|
88
94
|
].join("\n")
|
|
89
95
|
);
|
|
90
96
|
}
|
|
@@ -94,14 +100,15 @@ const createModuleMap = ({ files, moduleCache, sourceExts }) => {
|
|
|
94
100
|
return map;
|
|
95
101
|
};
|
|
96
102
|
|
|
97
|
-
exports.createResolveFn = function(options) {
|
|
103
|
+
exports.createResolveFn = function (options) {
|
|
98
104
|
const {
|
|
99
105
|
assetExts,
|
|
100
106
|
assetResolutions,
|
|
101
107
|
extraNodeModules,
|
|
102
108
|
transformedFiles,
|
|
103
109
|
sourceExts,
|
|
104
|
-
platform
|
|
110
|
+
platform,
|
|
111
|
+
platforms,
|
|
105
112
|
} = options;
|
|
106
113
|
const files = Object.keys(transformedFiles);
|
|
107
114
|
|
|
@@ -117,30 +124,33 @@ exports.createResolveFn = function(options) {
|
|
|
117
124
|
|
|
118
125
|
const hasteFS = new HasteFS(files);
|
|
119
126
|
const moduleCache = new ModuleCache(
|
|
120
|
-
filePath => hasteFS.closest(filePath, "package.json"),
|
|
127
|
+
(filePath) => hasteFS.closest(filePath, "package.json"),
|
|
121
128
|
getTransformedFile
|
|
122
129
|
);
|
|
123
|
-
const assetExtensions = new Set(assetExts.map(asset => "." + asset));
|
|
130
|
+
const assetExtensions = new Set(assetExts.map((asset) => "." + asset));
|
|
124
131
|
|
|
125
|
-
const isAssetFile = file => assetExtensions.has(path.extname(file));
|
|
132
|
+
const isAssetFile = (file) => assetExtensions.has(path.extname(file));
|
|
126
133
|
|
|
127
134
|
const moduleResolver = new ModuleResolver({
|
|
128
|
-
dirExists: filePath => hasteFS.dirExists(filePath),
|
|
129
|
-
|
|
135
|
+
dirExists: (filePath) => hasteFS.dirExists(filePath),
|
|
136
|
+
disableHierarchicalLookup: options.disableHierarchicalLookup,
|
|
137
|
+
doesFileExist: (filePath) => hasteFS.exists(filePath),
|
|
138
|
+
emptyModulePath: options.emptyModulePath,
|
|
130
139
|
extraNodeModules,
|
|
131
140
|
isAssetFile,
|
|
132
141
|
mainFields: options.mainFields,
|
|
133
142
|
// $FlowFixMe -- error revealed by types-first codemod
|
|
134
143
|
moduleCache,
|
|
135
|
-
moduleMap: new ModuleMap({
|
|
144
|
+
moduleMap: new _jestHasteMap.ModuleMap({
|
|
136
145
|
duplicates: new Map(),
|
|
137
146
|
map: createModuleMap({
|
|
138
147
|
files,
|
|
139
148
|
moduleCache,
|
|
140
|
-
sourceExts
|
|
149
|
+
sourceExts,
|
|
150
|
+
platforms,
|
|
141
151
|
}),
|
|
142
152
|
mocks: new Map(),
|
|
143
|
-
rootDir: ""
|
|
153
|
+
rootDir: "",
|
|
144
154
|
}),
|
|
145
155
|
nodeModulesPaths: options.nodeModulesPaths,
|
|
146
156
|
preferNativePlatform: true,
|
|
@@ -150,13 +160,13 @@ exports.createResolveFn = function(options) {
|
|
|
150
160
|
const assets = [
|
|
151
161
|
basePath + extension,
|
|
152
162
|
...assetResolutions.map(
|
|
153
|
-
resolution => basePath + "@" + resolution + "x" + extension
|
|
154
|
-
)
|
|
155
|
-
].filter(candidate => hasteFS.exists(candidate));
|
|
163
|
+
(resolution) => basePath + "@" + resolution + "x" + extension
|
|
164
|
+
),
|
|
165
|
+
].filter((candidate) => hasteFS.exists(candidate));
|
|
156
166
|
return assets.length ? assets : null;
|
|
157
167
|
},
|
|
158
168
|
resolveRequest: options.resolveRequest,
|
|
159
|
-
sourceExts
|
|
169
|
+
sourceExts,
|
|
160
170
|
});
|
|
161
171
|
return (id, sourcePath) => {
|
|
162
172
|
const from =
|