metro 0.65.2 → 0.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +27 -27
- package/src/Assets.js +9 -9
- package/src/Assets.js.flow +5 -7
- package/src/Bundler/util.js +17 -15
- package/src/Bundler/util.js.flow +12 -10
- package/src/Bundler.js +22 -9
- package/src/Bundler.js.flow +20 -7
- package/src/DeltaBundler/DeltaCalculator.js +17 -15
- package/src/DeltaBundler/DeltaCalculator.js.flow +9 -7
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js +13 -13
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js.flow +6 -7
- package/src/DeltaBundler/Serializers/baseJSBundle.js +4 -4
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +4 -4
- package/src/DeltaBundler/Serializers/getAllFiles.js +1 -1
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +3 -3
- package/src/DeltaBundler/Serializers/getAssets.js +3 -3
- package/src/DeltaBundler/Serializers/getAssets.js.flow +4 -5
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js +4 -4
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +4 -4
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js +20 -20
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +9 -10
- package/src/DeltaBundler/Serializers/helpers/bytecode.js +11 -11
- package/src/DeltaBundler/Serializers/helpers/bytecode.js.flow +5 -6
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js +1 -1
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js.flow +1 -1
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js +2 -2
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +4 -4
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js +1 -1
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js.flow +1 -1
- package/src/DeltaBundler/Serializers/helpers/js.js +18 -8
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +19 -10
- package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js +4 -4
- package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/helpers/processModules.js +4 -4
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +9 -9
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +9 -8
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +6 -6
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +3 -4
- package/src/DeltaBundler/Serializers/sourceMapObject.js +5 -5
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +4 -4
- package/src/DeltaBundler/Serializers/sourceMapString.js +2 -2
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +3 -3
- package/src/DeltaBundler/Transformer.js +16 -14
- package/src/DeltaBundler/Transformer.js.flow +15 -15
- package/src/DeltaBundler/Worker.js +8 -11
- package/src/DeltaBundler/Worker.js.flow +8 -11
- package/src/DeltaBundler/WorkerFarm.js +15 -18
- package/src/DeltaBundler/WorkerFarm.js.flow +9 -11
- package/src/DeltaBundler/__fixtures__/hasteImpl.js +2 -2
- package/src/DeltaBundler/computeDelta.js +2 -2
- package/src/DeltaBundler/computeDelta.js.flow +2 -2
- package/src/DeltaBundler/getTransformCacheKey.js +4 -4
- package/src/DeltaBundler/getTransformCacheKey.js.flow +5 -6
- package/src/DeltaBundler/mergeDeltas.js +2 -2
- package/src/DeltaBundler/mergeDeltas.js.flow +1 -1
- package/src/DeltaBundler/traverseDependencies.js +22 -22
- package/src/DeltaBundler/traverseDependencies.js.flow +3 -3
- package/src/DeltaBundler/types.flow.js +1 -1
- package/src/DeltaBundler/types.flow.js.flow +15 -1
- package/src/DeltaBundler.js +5 -5
- package/src/DeltaBundler.js.flow +4 -4
- package/src/HmrServer.js +73 -55
- package/src/HmrServer.js.flow +42 -37
- package/src/IncrementalBundler/GraphNotFoundError.js +1 -1
- package/src/IncrementalBundler/GraphNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler/ResourceNotFoundError.js +1 -1
- package/src/IncrementalBundler/ResourceNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler/RevisionNotFoundError.js +1 -1
- package/src/IncrementalBundler/RevisionNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler.js +46 -32
- package/src/IncrementalBundler.js.flow +32 -24
- package/src/ModuleGraph/module.js +3 -3
- package/src/ModuleGraph/module.js.flow +1 -1
- package/src/ModuleGraph/node-haste/HasteFS.js +5 -3
- package/src/ModuleGraph/node-haste/HasteFS.js.flow +3 -1
- package/src/ModuleGraph/node-haste/Module.js +1 -1
- package/src/ModuleGraph/node-haste/Module.js.flow +1 -1
- package/src/ModuleGraph/node-haste/ModuleCache.js +1 -1
- package/src/ModuleGraph/node-haste/ModuleCache.js.flow +3 -3
- package/src/ModuleGraph/node-haste/Package.js +3 -3
- package/src/ModuleGraph/node-haste/Package.js.flow +3 -3
- package/src/ModuleGraph/node-haste/node-haste.flow.js +1 -1
- package/src/ModuleGraph/node-haste/node-haste.flow.js.flow +1 -1
- package/src/ModuleGraph/node-haste/node-haste.js +41 -31
- package/src/ModuleGraph/node-haste/node-haste.js.flow +28 -22
- package/src/ModuleGraph/output/indexed-ram-bundle.js +17 -17
- package/src/ModuleGraph/output/indexed-ram-bundle.js.flow +41 -9
- package/src/ModuleGraph/output/multiple-files-ram-bundle.js +18 -18
- package/src/ModuleGraph/output/multiple-files-ram-bundle.js.flow +21 -9
- package/src/ModuleGraph/output/plain-bundle.js +6 -6
- package/src/ModuleGraph/output/plain-bundle.js.flow +7 -7
- package/src/ModuleGraph/output/reverse-dependency-map-references.js +3 -3
- package/src/ModuleGraph/output/reverse-dependency-map-references.js.flow +4 -8
- package/src/ModuleGraph/output/util.js +61 -40
- package/src/ModuleGraph/output/util.js.flow +51 -28
- package/src/ModuleGraph/silent-console.js +2 -2
- package/src/ModuleGraph/silent-console.js.flow +1 -1
- package/src/ModuleGraph/test-helpers.js +7 -7
- package/src/ModuleGraph/types.flow.js +1 -1
- package/src/ModuleGraph/types.flow.js.flow +47 -31
- package/src/ModuleGraph/worker/JsFileWrapping.js +16 -16
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +3 -2
- package/src/ModuleGraph/worker/Platforms.js +2 -2
- package/src/ModuleGraph/worker/Platforms.js.flow +1 -1
- package/src/ModuleGraph/worker/collectDependencies.js +24 -25
- package/src/ModuleGraph/worker/collectDependencies.js.flow +16 -18
- package/src/ModuleGraph/worker/generate.js +2 -2
- package/src/ModuleGraph/worker/generate.js.flow +3 -3
- package/src/ModuleGraph/worker/generateImportNames.js +5 -5
- package/src/ModuleGraph/worker/generateImportNames.js.flow +3 -5
- package/src/ModuleGraph/worker/mergeSourceMaps.js +8 -7
- package/src/ModuleGraph/worker/mergeSourceMaps.js.flow +3 -3
- package/src/Server/MultipartResponse.js +4 -8
- package/src/Server/symbolicate.js +8 -8
- package/src/Server/symbolicate.js.flow +17 -5
- package/src/Server.js +204 -150
- package/src/Server.js.flow +131 -87
- package/src/cli-utils.js +4 -4
- package/src/cli-utils.js.flow +15 -13
- package/src/cli.js +4 -4
- package/src/cli.js.flow +2 -4
- package/src/commands/build.js +23 -24
- package/src/commands/build.js.flow +6 -9
- package/src/commands/dependencies.js +25 -19
- package/src/commands/serve.js +19 -19
- package/src/commands/serve.js.flow +7 -9
- package/src/index.js +117 -50
- package/src/index.js.flow +108 -40
- package/src/integration_tests/basic_bundle/AssetRegistry.js +2 -2
- package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +1 -1
- package/src/integration_tests/basic_bundle/Bar.js +2 -2
- package/src/integration_tests/basic_bundle/Bar.js.flow +1 -1
- package/src/integration_tests/basic_bundle/ErrorBundle.js +2 -2
- package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +1 -1
- package/src/integration_tests/basic_bundle/Foo.js +2 -2
- package/src/integration_tests/basic_bundle/Foo.js.flow +1 -1
- package/src/integration_tests/basic_bundle/TestBundle.js +2 -2
- package/src/integration_tests/basic_bundle/TestBundle.js.flow +1 -1
- package/src/integration_tests/basic_bundle/TestPolyfill.js +1 -1
- package/src/integration_tests/basic_bundle/TestPolyfill.js.flow +1 -1
- package/src/integration_tests/basic_bundle/TypeScript.ts +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-1.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-1.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-2.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-2.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-3.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-3.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-4.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-4.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-5.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-5.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-6.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-6.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-null.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-null.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/index.js +17 -17
- package/src/integration_tests/basic_bundle/import-export/index.js.flow +1 -1
- package/src/integration_tests/basic_bundle/polyfill.js +1 -1
- package/src/integration_tests/execBundle.js +2 -2
- package/src/integration_tests/execBundle.js.flow +1 -1
- package/src/integration_tests/metro.config.js +8 -8
- package/src/lib/BatchProcessor.js +10 -6
- package/src/lib/BatchProcessor.js.flow +6 -1
- package/src/lib/JsonReporter.js +3 -2
- package/src/lib/JsonReporter.js.flow +2 -1
- package/src/lib/RamBundleParser.js +1 -1
- package/src/lib/RamBundleParser.js.flow +1 -1
- package/src/lib/TerminalReporter.js +15 -15
- package/src/lib/TerminalReporter.js.flow +15 -16
- package/src/lib/bundleToBytecode.js +6 -7
- package/src/lib/bundleToBytecode.js.flow +8 -7
- package/src/lib/bundleToString.js +3 -3
- package/src/lib/bundleToString.js.flow +5 -4
- package/src/lib/countLines.js +3 -7
- package/src/lib/countLines.js.flow +4 -7
- package/src/lib/createModuleIdFactory.js +2 -2
- package/src/lib/createModuleIdFactory.js.flow +1 -1
- package/src/lib/{attachWebsocketServer.js → createWebsocketServer.js} +18 -17
- package/src/lib/{attachWebsocketServer.js.flow → createWebsocketServer.js.flow} +13 -23
- package/src/lib/debounceAsyncQueue.js +2 -2
- package/src/lib/debounceAsyncQueue.js.flow +1 -1
- package/src/lib/formatBundlingError.js +21 -21
- package/src/lib/formatBundlingError.js.flow +18 -20
- package/src/lib/getAppendScripts.js +26 -27
- package/src/lib/getAppendScripts.js.flow +7 -8
- package/src/lib/getGraphId.js +3 -3
- package/src/lib/getGraphId.js.flow +3 -3
- package/src/lib/getMaxWorkers.js +2 -2
- package/src/lib/getMaxWorkers.js.flow +1 -1
- package/src/lib/getPreludeCode.js +2 -2
- package/src/lib/getPreludeCode.js.flow +1 -1
- package/src/lib/getPrependedScripts.js +16 -15
- package/src/lib/getPrependedScripts.js.flow +8 -8
- package/src/lib/logToConsole.js +12 -5
- package/src/lib/logToConsole.js.flow +19 -6
- package/src/lib/parseCustomTransformOptions.js +2 -2
- package/src/lib/parseCustomTransformOptions.js.flow +3 -3
- package/src/lib/parseOptionsFromUrl.js +7 -7
- package/src/lib/parseOptionsFromUrl.js.flow +29 -9
- package/src/lib/relativizeSourceMap.js +1 -1
- package/src/lib/relativizeSourceMap.js.flow +3 -3
- package/src/lib/reporting.js +5 -5
- package/src/lib/reporting.js.flow +18 -4
- package/src/lib/splitBundleOptions.js +5 -5
- package/src/lib/splitBundleOptions.js.flow +1 -1
- package/src/lib/transformHelpers.js +11 -10
- package/src/lib/transformHelpers.js.flow +6 -13
- package/src/node-haste/DependencyGraph/ModuleResolution.js +51 -30
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +49 -48
- package/src/node-haste/DependencyGraph/createHasteMap.js +99 -0
- package/src/node-haste/DependencyGraph/createHasteMap.js.flow +88 -0
- package/src/node-haste/DependencyGraph/{assets/empty-module.js → types.js} +2 -2
- package/src/node-haste/DependencyGraph/types.js.flow +88 -0
- package/src/node-haste/DependencyGraph.js +51 -118
- package/src/node-haste/DependencyGraph.js.flow +38 -111
- package/src/node-haste/Module.js +1 -1
- package/src/node-haste/Module.js.flow +3 -3
- package/src/node-haste/ModuleCache.js +54 -13
- package/src/node-haste/ModuleCache.js.flow +53 -12
- package/src/node-haste/Package.js +2 -2
- package/src/node-haste/Package.js.flow +1 -1
- package/src/node-haste/lib/AssetPaths.js +5 -5
- package/src/node-haste/lib/AssetPaths.js.flow +7 -6
- package/src/node-haste/lib/parsePlatformFilePath.js +4 -4
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +2 -2
- package/src/shared/output/RamBundle/as-assets.js +14 -15
- package/src/shared/output/RamBundle/as-assets.js.flow +9 -11
- package/src/shared/output/RamBundle/as-indexed-file.js +14 -15
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +8 -12
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js +7 -7
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +4 -4
- package/src/shared/output/RamBundle/magic-number.js +1 -1
- package/src/shared/output/RamBundle/magic-number.js.flow +1 -1
- package/src/shared/output/RamBundle/util.js +21 -19
- package/src/shared/output/RamBundle/util.js.flow +5 -8
- package/src/shared/output/RamBundle/write-sourcemap.js +1 -1
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
- package/src/shared/output/RamBundle.js +2 -2
- package/src/shared/output/RamBundle.js.flow +4 -5
- package/src/shared/output/bundle.js +6 -6
- package/src/shared/output/bundle.js.flow +4 -5
- package/src/shared/output/meta.js +4 -5
- package/src/shared/output/meta.js.flow +2 -4
- package/src/shared/output/unbundle.js +1 -1
- package/src/shared/output/unbundle.js.flow +1 -1
- package/src/shared/output/writeFile.js +1 -1
- package/src/shared/output/writeFile.js.flow +1 -1
- package/src/shared/types.flow.js +1 -1
- package/src/shared/types.flow.js.flow +6 -4
- package/src/node-haste/DependencyGraph/assets/empty-module.js.flow +0 -9
- package/src/node-haste/types.js +0 -10
- package/src/node-haste/types.js.flow +0 -23
package/src/Server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -9,67 +9,71 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const MultipartResponse = require("./Server/MultipartResponse");
|
|
15
|
-
|
|
16
|
-
const ResourceNotFoundError = require("./IncrementalBundler/ResourceNotFoundError");
|
|
12
|
+
const { getAsset } = require("./Assets");
|
|
17
13
|
|
|
18
14
|
const baseBytecodeBundle = require("./DeltaBundler/Serializers/baseBytecodeBundle");
|
|
19
15
|
|
|
20
16
|
const baseJSBundle = require("./DeltaBundler/Serializers/baseJSBundle");
|
|
21
17
|
|
|
22
|
-
const
|
|
18
|
+
const getAllFiles = require("./DeltaBundler/Serializers/getAllFiles");
|
|
23
19
|
|
|
24
|
-
const
|
|
20
|
+
const getAssets = require("./DeltaBundler/Serializers/getAssets");
|
|
25
21
|
|
|
26
|
-
const {
|
|
22
|
+
const {
|
|
23
|
+
getExplodedSourceMap,
|
|
24
|
+
} = require("./DeltaBundler/Serializers/getExplodedSourceMap");
|
|
27
25
|
|
|
28
|
-
const
|
|
26
|
+
const getRamBundleInfo = require("./DeltaBundler/Serializers/getRamBundleInfo");
|
|
29
27
|
|
|
30
|
-
const
|
|
28
|
+
const sourceMapString = require("./DeltaBundler/Serializers/sourceMapString");
|
|
31
29
|
|
|
32
|
-
const
|
|
30
|
+
const IncrementalBundler = require("./IncrementalBundler");
|
|
33
31
|
|
|
34
|
-
const
|
|
32
|
+
const ResourceNotFoundError = require("./IncrementalBundler/ResourceNotFoundError");
|
|
35
33
|
|
|
36
|
-
const
|
|
34
|
+
const bundleToBytecode = require("./lib/bundleToBytecode");
|
|
37
35
|
|
|
38
|
-
const
|
|
36
|
+
const bundleToString = require("./lib/bundleToString");
|
|
39
37
|
|
|
40
|
-
const
|
|
38
|
+
const formatBundlingError = require("./lib/formatBundlingError");
|
|
41
39
|
|
|
42
|
-
const
|
|
40
|
+
const getGraphId = require("./lib/getGraphId");
|
|
43
41
|
|
|
44
42
|
const parseOptionsFromUrl = require("./lib/parseOptionsFromUrl");
|
|
45
43
|
|
|
46
|
-
const
|
|
44
|
+
const splitBundleOptions = require("./lib/splitBundleOptions");
|
|
47
45
|
|
|
48
|
-
const
|
|
46
|
+
const transformHelpers = require("./lib/transformHelpers");
|
|
49
47
|
|
|
50
|
-
const
|
|
48
|
+
const parsePlatformFilePath = require("./node-haste/lib/parsePlatformFilePath");
|
|
51
49
|
|
|
52
|
-
const
|
|
50
|
+
const MultipartResponse = require("./Server/MultipartResponse");
|
|
53
51
|
|
|
54
52
|
const symbolicate = require("./Server/symbolicate");
|
|
55
53
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
const url = require("url");
|
|
59
|
-
|
|
60
|
-
const { VERSION: BYTECODE_VERSION } = require("metro-hermes-compiler");
|
|
54
|
+
const { codeFrameColumns } = require("@babel/code-frame");
|
|
61
55
|
|
|
62
|
-
const
|
|
56
|
+
const debug = require("debug")("Metro:Server");
|
|
63
57
|
|
|
64
|
-
const
|
|
65
|
-
getExplodedSourceMap
|
|
66
|
-
} = require("./DeltaBundler/Serializers/getExplodedSourceMap");
|
|
58
|
+
const fs = require("graceful-fs");
|
|
67
59
|
|
|
68
60
|
const {
|
|
69
61
|
Logger,
|
|
70
|
-
Logger: { createActionStartEntry, createActionEndEntry, log }
|
|
62
|
+
Logger: { createActionStartEntry, createActionEndEntry, log },
|
|
71
63
|
} = require("metro-core");
|
|
72
64
|
|
|
65
|
+
const { VERSION: BYTECODE_VERSION } = require("metro-hermes-compiler");
|
|
66
|
+
|
|
67
|
+
const mime = require("mime-types");
|
|
68
|
+
|
|
69
|
+
const nullthrows = require("nullthrows");
|
|
70
|
+
|
|
71
|
+
const path = require("path");
|
|
72
|
+
|
|
73
|
+
const querystring = require("querystring");
|
|
74
|
+
|
|
75
|
+
const url = require("url");
|
|
76
|
+
|
|
73
77
|
const DELTA_ID_HEADER = "X-Metro-Delta-ID";
|
|
74
78
|
const FILES_CHANGED_COUNT_HEADER = "X-Metro-Files-Changed-Count";
|
|
75
79
|
|
|
@@ -79,10 +83,10 @@ class Server {
|
|
|
79
83
|
this._serverOptions = options;
|
|
80
84
|
|
|
81
85
|
if (this._config.resetCache) {
|
|
82
|
-
this._config.cacheStores.forEach(store => store.clear());
|
|
86
|
+
this._config.cacheStores.forEach((store) => store.clear());
|
|
83
87
|
|
|
84
88
|
this._config.reporter.update({
|
|
85
|
-
type: "transform_cache_reset"
|
|
89
|
+
type: "transform_cache_reset",
|
|
86
90
|
});
|
|
87
91
|
}
|
|
88
92
|
|
|
@@ -97,7 +101,7 @@ class Server {
|
|
|
97
101
|
this._createModuleId = config.serializer.createModuleIdFactory();
|
|
98
102
|
this._bundler = new IncrementalBundler(config, {
|
|
99
103
|
hasReducedPerformance: options && options.hasReducedPerformance,
|
|
100
|
-
watch: options ? options.watch : undefined
|
|
104
|
+
watch: options ? options.watch : undefined,
|
|
101
105
|
});
|
|
102
106
|
this._nextBundleBuildID = 1;
|
|
103
107
|
}
|
|
@@ -124,22 +128,25 @@ class Server {
|
|
|
124
128
|
graphOptions,
|
|
125
129
|
onProgress,
|
|
126
130
|
serializerOptions,
|
|
127
|
-
transformOptions
|
|
131
|
+
transformOptions,
|
|
128
132
|
} = splitBundleOptions(options);
|
|
129
133
|
const { prepend, graph } = await this._bundler.buildGraph(
|
|
130
134
|
entryFile,
|
|
131
135
|
transformOptions,
|
|
132
136
|
{
|
|
133
137
|
onProgress,
|
|
134
|
-
shallow: graphOptions.shallow
|
|
138
|
+
shallow: graphOptions.shallow,
|
|
135
139
|
}
|
|
136
140
|
);
|
|
137
|
-
|
|
141
|
+
|
|
142
|
+
const entryPoint = this._getEntryPointAbsolutePath(entryFile);
|
|
143
|
+
|
|
138
144
|
const bundleOptions = {
|
|
139
145
|
asyncRequireModulePath: await this._resolveRelativePath(
|
|
140
146
|
this._config.transformer.asyncRequireModulePath,
|
|
141
147
|
{
|
|
142
|
-
transformOptions
|
|
148
|
+
transformOptions,
|
|
149
|
+
relativeTo: "project",
|
|
143
150
|
}
|
|
144
151
|
),
|
|
145
152
|
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
@@ -148,13 +155,14 @@ class Server {
|
|
|
148
155
|
dev: transformOptions.dev,
|
|
149
156
|
projectRoot: this._config.projectRoot,
|
|
150
157
|
modulesOnly: serializerOptions.modulesOnly,
|
|
151
|
-
runBeforeMainModule:
|
|
152
|
-
|
|
153
|
-
|
|
158
|
+
runBeforeMainModule:
|
|
159
|
+
this._config.serializer.getModulesRunBeforeMainModule(
|
|
160
|
+
path.relative(this._config.projectRoot, entryPoint)
|
|
161
|
+
),
|
|
154
162
|
runModule: serializerOptions.runModule,
|
|
155
163
|
sourceMapUrl: serializerOptions.sourceMapUrl,
|
|
156
164
|
sourceUrl: serializerOptions.sourceUrl,
|
|
157
|
-
inlineSourceMap: serializerOptions.inlineSourceMap
|
|
165
|
+
inlineSourceMap: serializerOptions.inlineSourceMap,
|
|
158
166
|
};
|
|
159
167
|
let bundleCode = null;
|
|
160
168
|
let bundleMap = null;
|
|
@@ -184,14 +192,14 @@ class Server {
|
|
|
184
192
|
[...prepend, ...this._getSortedModules(graph)],
|
|
185
193
|
{
|
|
186
194
|
excludeSource: serializerOptions.excludeSource,
|
|
187
|
-
processModuleFilter: this._config.serializer.processModuleFilter
|
|
195
|
+
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
188
196
|
}
|
|
189
197
|
);
|
|
190
198
|
}
|
|
191
199
|
|
|
192
200
|
return {
|
|
193
201
|
code: bundleCode,
|
|
194
|
-
map: bundleMap
|
|
202
|
+
map: bundleMap,
|
|
195
203
|
};
|
|
196
204
|
}
|
|
197
205
|
|
|
@@ -201,22 +209,25 @@ class Server {
|
|
|
201
209
|
graphOptions,
|
|
202
210
|
onProgress,
|
|
203
211
|
serializerOptions,
|
|
204
|
-
transformOptions
|
|
212
|
+
transformOptions,
|
|
205
213
|
} = splitBundleOptions(options);
|
|
206
214
|
const { prepend, graph } = await this._bundler.buildGraph(
|
|
207
215
|
entryFile,
|
|
208
216
|
transformOptions,
|
|
209
217
|
{
|
|
210
218
|
onProgress,
|
|
211
|
-
shallow: graphOptions.shallow
|
|
219
|
+
shallow: graphOptions.shallow,
|
|
212
220
|
}
|
|
213
221
|
);
|
|
214
|
-
|
|
222
|
+
|
|
223
|
+
const entryPoint = this._getEntryPointAbsolutePath(entryFile);
|
|
224
|
+
|
|
215
225
|
return await getRamBundleInfo(entryPoint, prepend, graph, {
|
|
216
226
|
asyncRequireModulePath: await this._resolveRelativePath(
|
|
217
227
|
this._config.transformer.asyncRequireModulePath,
|
|
218
228
|
{
|
|
219
|
-
transformOptions
|
|
229
|
+
transformOptions,
|
|
230
|
+
relativeTo: "project",
|
|
220
231
|
}
|
|
221
232
|
),
|
|
222
233
|
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
@@ -228,34 +239,34 @@ class Server {
|
|
|
228
239
|
platform: transformOptions.platform,
|
|
229
240
|
projectRoot: this._config.projectRoot,
|
|
230
241
|
modulesOnly: serializerOptions.modulesOnly,
|
|
231
|
-
runBeforeMainModule:
|
|
232
|
-
|
|
233
|
-
|
|
242
|
+
runBeforeMainModule:
|
|
243
|
+
this._config.serializer.getModulesRunBeforeMainModule(
|
|
244
|
+
path.relative(this._config.projectRoot, entryPoint)
|
|
245
|
+
),
|
|
234
246
|
runModule: serializerOptions.runModule,
|
|
235
247
|
sourceMapUrl: serializerOptions.sourceMapUrl,
|
|
236
248
|
sourceUrl: serializerOptions.sourceUrl,
|
|
237
|
-
inlineSourceMap: serializerOptions.inlineSourceMap
|
|
249
|
+
inlineSourceMap: serializerOptions.inlineSourceMap,
|
|
238
250
|
});
|
|
239
251
|
}
|
|
240
252
|
|
|
241
253
|
async getAssets(options) {
|
|
242
|
-
const { entryFile, transformOptions, onProgress } =
|
|
243
|
-
options
|
|
244
|
-
);
|
|
254
|
+
const { entryFile, transformOptions, onProgress } =
|
|
255
|
+
splitBundleOptions(options);
|
|
245
256
|
const dependencies = await this._bundler.getDependencies(
|
|
246
257
|
[entryFile],
|
|
247
258
|
transformOptions,
|
|
248
259
|
{
|
|
249
260
|
onProgress,
|
|
250
|
-
shallow: false
|
|
261
|
+
shallow: false,
|
|
251
262
|
}
|
|
252
263
|
);
|
|
253
264
|
return await getAssets(dependencies, {
|
|
254
265
|
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
255
266
|
assetPlugins: this._config.transformer.assetPlugins,
|
|
256
267
|
platform: transformOptions.platform,
|
|
257
|
-
projectRoot: this.
|
|
258
|
-
publicPath: this._config.transformer.publicPath
|
|
268
|
+
projectRoot: this._getServerRootDir(),
|
|
269
|
+
publicPath: this._config.transformer.publicPath,
|
|
259
270
|
});
|
|
260
271
|
}
|
|
261
272
|
|
|
@@ -266,14 +277,14 @@ class Server {
|
|
|
266
277
|
const { entryFile, transformOptions, onProgress } = splitBundleOptions({
|
|
267
278
|
...Server.DEFAULT_BUNDLE_OPTIONS,
|
|
268
279
|
...options,
|
|
269
|
-
bundleType: "bundle"
|
|
280
|
+
bundleType: "bundle",
|
|
270
281
|
});
|
|
271
282
|
const { prepend, graph } = await this._bundler.buildGraph(
|
|
272
283
|
entryFile,
|
|
273
284
|
transformOptions,
|
|
274
285
|
{
|
|
275
286
|
onProgress,
|
|
276
|
-
shallow: false
|
|
287
|
+
shallow: false,
|
|
277
288
|
}
|
|
278
289
|
);
|
|
279
290
|
const platform =
|
|
@@ -282,7 +293,7 @@ class Server {
|
|
|
282
293
|
|
|
283
294
|
return await getAllFiles(prepend, graph, {
|
|
284
295
|
platform,
|
|
285
|
-
processModuleFilter: this._config.serializer.processModuleFilter
|
|
296
|
+
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
286
297
|
});
|
|
287
298
|
}
|
|
288
299
|
|
|
@@ -298,7 +309,7 @@ class Server {
|
|
|
298
309
|
"Accept-Ranges": "bytes",
|
|
299
310
|
"Content-Length": chunksize.toString(),
|
|
300
311
|
"Content-Range": `bytes ${dataStart}-${dataEnd}/${data.length}`,
|
|
301
|
-
"Content-Type": mime.lookup(path.basename(assetPath))
|
|
312
|
+
"Content-Type": mime.lookup(path.basename(assetPath)),
|
|
302
313
|
});
|
|
303
314
|
return data.slice(dataStart, dataEnd + 1);
|
|
304
315
|
}
|
|
@@ -308,8 +319,23 @@ class Server {
|
|
|
308
319
|
|
|
309
320
|
async _processSingleAssetRequest(req, res) {
|
|
310
321
|
const urlObj = url.parse(decodeURI(req.url), true);
|
|
311
|
-
|
|
312
|
-
urlObj &&
|
|
322
|
+
let [, assetPath] =
|
|
323
|
+
(urlObj &&
|
|
324
|
+
urlObj.pathname &&
|
|
325
|
+
urlObj.pathname.match(/^\/assets\/(.+)$/)) ||
|
|
326
|
+
[];
|
|
327
|
+
|
|
328
|
+
if (!assetPath && urlObj && urlObj.query && urlObj.query.unstable_path) {
|
|
329
|
+
const [, actualPath, secondaryQuery] = nullthrows(
|
|
330
|
+
urlObj.query.unstable_path.match(/^([^?]*)\??(.*)$/)
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
if (secondaryQuery) {
|
|
334
|
+
Object.assign(urlObj.query, querystring.parse(secondaryQuery));
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
assetPath = actualPath;
|
|
338
|
+
}
|
|
313
339
|
|
|
314
340
|
if (!assetPath) {
|
|
315
341
|
throw new Error("Could not extract asset path from URL");
|
|
@@ -318,13 +344,13 @@ class Server {
|
|
|
318
344
|
const processingAssetRequestLogEntry = log(
|
|
319
345
|
createActionStartEntry({
|
|
320
346
|
action_name: "Processing asset request",
|
|
321
|
-
asset: assetPath[1]
|
|
347
|
+
asset: assetPath[1],
|
|
322
348
|
})
|
|
323
349
|
);
|
|
324
350
|
|
|
325
351
|
try {
|
|
326
352
|
const data = await getAsset(
|
|
327
|
-
assetPath
|
|
353
|
+
assetPath,
|
|
328
354
|
this._config.projectRoot,
|
|
329
355
|
this._config.watchFolders,
|
|
330
356
|
urlObj.query.platform,
|
|
@@ -336,7 +362,7 @@ class Server {
|
|
|
336
362
|
res.setHeader("Cache-Control", "max-age=31536000");
|
|
337
363
|
}
|
|
338
364
|
|
|
339
|
-
res.end(this._rangeRequestMiddleware(req, res, data, assetPath
|
|
365
|
+
res.end(this._rangeRequestMiddleware(req, res, data, assetPath));
|
|
340
366
|
process.nextTick(() => {
|
|
341
367
|
log(createActionEndEntry(processingAssetRequestLogEntry));
|
|
342
368
|
});
|
|
@@ -397,7 +423,7 @@ class Server {
|
|
|
397
423
|
res,
|
|
398
424
|
this._parseOptions(formattedUrl)
|
|
399
425
|
);
|
|
400
|
-
} else if (pathname.startsWith("/assets/")) {
|
|
426
|
+
} else if (pathname.startsWith("/assets/") || pathname === "/assets") {
|
|
401
427
|
await this._processSingleAssetRequest(req, res);
|
|
402
428
|
} else if (pathname === "/symbolicate") {
|
|
403
429
|
await this._symbolicate(req, res);
|
|
@@ -411,34 +437,31 @@ class Server {
|
|
|
411
437
|
createEndEntry,
|
|
412
438
|
build,
|
|
413
439
|
delete: deleteFn,
|
|
414
|
-
finish
|
|
440
|
+
finish,
|
|
415
441
|
}) {
|
|
416
442
|
return async function requestProcessor(req, res, bundleOptions) {
|
|
417
|
-
const {
|
|
418
|
-
|
|
419
|
-
graphOptions,
|
|
420
|
-
transformOptions,
|
|
421
|
-
serializerOptions
|
|
422
|
-
} = splitBundleOptions(bundleOptions);
|
|
443
|
+
const { entryFile, graphOptions, transformOptions, serializerOptions } =
|
|
444
|
+
splitBundleOptions(bundleOptions);
|
|
423
445
|
/**
|
|
424
446
|
* `entryFile` is relative to projectRoot, we need to use resolution function
|
|
425
447
|
* to find the appropriate file with supported extensions.
|
|
426
448
|
*/
|
|
427
449
|
|
|
428
450
|
const resolvedEntryFilePath = await this._resolveRelativePath(entryFile, {
|
|
429
|
-
transformOptions
|
|
451
|
+
transformOptions,
|
|
452
|
+
relativeTo: "server",
|
|
430
453
|
});
|
|
431
454
|
const graphId = getGraphId(resolvedEntryFilePath, transformOptions, {
|
|
432
455
|
shallow: graphOptions.shallow,
|
|
433
|
-
experimentalImportBundleSupport:
|
|
434
|
-
.experimentalImportBundleSupport
|
|
456
|
+
experimentalImportBundleSupport:
|
|
457
|
+
this._config.transformer.experimentalImportBundleSupport,
|
|
435
458
|
}); // For resources that support deletion, handle the DELETE method.
|
|
436
459
|
|
|
437
460
|
if (deleteFn && req.method === "DELETE") {
|
|
438
461
|
const deleteContext = {
|
|
439
462
|
graphId,
|
|
440
463
|
req,
|
|
441
|
-
res
|
|
464
|
+
res,
|
|
442
465
|
};
|
|
443
466
|
|
|
444
467
|
try {
|
|
@@ -447,7 +470,7 @@ class Server {
|
|
|
447
470
|
const formattedError = formatBundlingError(error);
|
|
448
471
|
const status = error instanceof ResourceNotFoundError ? 404 : 500;
|
|
449
472
|
res.writeHead(status, {
|
|
450
|
-
"Content-Type": "application/json; charset=UTF-8"
|
|
473
|
+
"Content-Type": "application/json; charset=UTF-8",
|
|
451
474
|
});
|
|
452
475
|
res.end(JSON.stringify(formattedError));
|
|
453
476
|
}
|
|
@@ -473,11 +496,11 @@ class Server {
|
|
|
473
496
|
if (currentProgress > lastProgress || totalFileCount < 10) {
|
|
474
497
|
mres.writeChunk(
|
|
475
498
|
{
|
|
476
|
-
"Content-Type": "application/json"
|
|
499
|
+
"Content-Type": "application/json",
|
|
477
500
|
},
|
|
478
501
|
JSON.stringify({
|
|
479
502
|
done: transformedFileCount,
|
|
480
|
-
total: totalFileCount
|
|
503
|
+
total: totalFileCount,
|
|
481
504
|
})
|
|
482
505
|
); // The `uncork` called internally in Node via `promise.nextTick()` may not fire
|
|
483
506
|
// until all of the Promises are resolved because the microtask queue we're
|
|
@@ -485,6 +508,7 @@ class Server {
|
|
|
485
508
|
// is not actually sent in the response until after bundling is complete. This
|
|
486
509
|
// would defeat the purpose of sending progress, so we `uncork` the stream now
|
|
487
510
|
// which will force the response to flush to the client immediately.
|
|
511
|
+
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
488
512
|
|
|
489
513
|
if (res.socket != null && res.socket.uncork != null) {
|
|
490
514
|
res.socket.uncork();
|
|
@@ -497,7 +521,7 @@ class Server {
|
|
|
497
521
|
buildID,
|
|
498
522
|
type: "bundle_transform_progressed",
|
|
499
523
|
transformedFileCount,
|
|
500
|
-
totalFileCount
|
|
524
|
+
totalFileCount,
|
|
501
525
|
});
|
|
502
526
|
};
|
|
503
527
|
}
|
|
@@ -510,9 +534,9 @@ class Server {
|
|
|
510
534
|
entryFile: resolvedEntryFilePath,
|
|
511
535
|
minify: transformOptions.minify,
|
|
512
536
|
platform: transformOptions.platform,
|
|
513
|
-
runtimeBytecodeVersion: transformOptions.runtimeBytecodeVersion
|
|
537
|
+
runtimeBytecodeVersion: transformOptions.runtimeBytecodeVersion,
|
|
514
538
|
},
|
|
515
|
-
type: "bundle_build_started"
|
|
539
|
+
type: "bundle_build_started",
|
|
516
540
|
});
|
|
517
541
|
|
|
518
542
|
const startContext = {
|
|
@@ -525,7 +549,7 @@ class Server {
|
|
|
525
549
|
onProgress,
|
|
526
550
|
req,
|
|
527
551
|
serializerOptions,
|
|
528
|
-
transformOptions
|
|
552
|
+
transformOptions,
|
|
529
553
|
};
|
|
530
554
|
const logEntry = log(
|
|
531
555
|
createActionStartEntry(createStartEntry(startContext))
|
|
@@ -538,19 +562,19 @@ class Server {
|
|
|
538
562
|
const formattedError = formatBundlingError(error);
|
|
539
563
|
const status = error instanceof ResourceNotFoundError ? 404 : 500;
|
|
540
564
|
mres.writeHead(status, {
|
|
541
|
-
"Content-Type": "application/json; charset=UTF-8"
|
|
565
|
+
"Content-Type": "application/json; charset=UTF-8",
|
|
542
566
|
});
|
|
543
567
|
mres.end(JSON.stringify(formattedError));
|
|
544
568
|
|
|
545
569
|
this._reporter.update({
|
|
546
570
|
buildID,
|
|
547
571
|
type: "bundle_build_failed",
|
|
548
|
-
bundleOptions
|
|
572
|
+
bundleOptions,
|
|
549
573
|
});
|
|
550
574
|
|
|
551
575
|
this._reporter.update({
|
|
552
576
|
error,
|
|
553
|
-
type: "bundling_error"
|
|
577
|
+
type: "bundling_error",
|
|
554
578
|
});
|
|
555
579
|
|
|
556
580
|
log({
|
|
@@ -559,8 +583,9 @@ class Server {
|
|
|
559
583
|
log_entry_label: "bundling_error",
|
|
560
584
|
bundle_id: graphId,
|
|
561
585
|
build_id: buildID,
|
|
562
|
-
stack: formattedError.message
|
|
586
|
+
stack: formattedError.message,
|
|
563
587
|
});
|
|
588
|
+
debug("Bundling error", error);
|
|
564
589
|
return;
|
|
565
590
|
}
|
|
566
591
|
|
|
@@ -569,7 +594,7 @@ class Server {
|
|
|
569
594
|
|
|
570
595
|
this._reporter.update({
|
|
571
596
|
buildID,
|
|
572
|
-
type: "bundle_build_done"
|
|
597
|
+
type: "bundle_build_done",
|
|
573
598
|
});
|
|
574
599
|
|
|
575
600
|
log(
|
|
@@ -590,13 +615,13 @@ class Server {
|
|
|
590
615
|
bundler: "delta",
|
|
591
616
|
build_id: context.buildID,
|
|
592
617
|
bundle_options: context.bundleOptions,
|
|
593
|
-
bundle_hash: context.graphId
|
|
618
|
+
bundle_hash: context.graphId,
|
|
594
619
|
};
|
|
595
620
|
},
|
|
596
621
|
|
|
597
622
|
createEndEntry(context) {
|
|
598
623
|
return {
|
|
599
|
-
outdated_modules: context.result.numModifiedFiles
|
|
624
|
+
outdated_modules: context.result.numModifiedFiles,
|
|
600
625
|
};
|
|
601
626
|
},
|
|
602
627
|
|
|
@@ -606,7 +631,7 @@ class Server {
|
|
|
606
631
|
graphOptions,
|
|
607
632
|
onProgress,
|
|
608
633
|
serializerOptions,
|
|
609
|
-
transformOptions
|
|
634
|
+
transformOptions,
|
|
610
635
|
}) => {
|
|
611
636
|
const revPromise = this._bundler.getRevisionByGraphId(graphId);
|
|
612
637
|
|
|
@@ -614,7 +639,7 @@ class Server {
|
|
|
614
639
|
? this._bundler.updateGraph(await revPromise, false)
|
|
615
640
|
: this._bundler.initializeGraph(entryFile, transformOptions, {
|
|
616
641
|
onProgress,
|
|
617
|
-
shallow: graphOptions.shallow
|
|
642
|
+
shallow: graphOptions.shallow,
|
|
618
643
|
}));
|
|
619
644
|
|
|
620
645
|
const serializer =
|
|
@@ -629,7 +654,8 @@ class Server {
|
|
|
629
654
|
asyncRequireModulePath: await this._resolveRelativePath(
|
|
630
655
|
this._config.transformer.asyncRequireModulePath,
|
|
631
656
|
{
|
|
632
|
-
transformOptions
|
|
657
|
+
transformOptions,
|
|
658
|
+
relativeTo: "project",
|
|
633
659
|
}
|
|
634
660
|
),
|
|
635
661
|
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
@@ -638,13 +664,14 @@ class Server {
|
|
|
638
664
|
dev: transformOptions.dev,
|
|
639
665
|
projectRoot: this._config.projectRoot,
|
|
640
666
|
modulesOnly: serializerOptions.modulesOnly,
|
|
641
|
-
runBeforeMainModule:
|
|
642
|
-
|
|
643
|
-
|
|
667
|
+
runBeforeMainModule:
|
|
668
|
+
this._config.serializer.getModulesRunBeforeMainModule(
|
|
669
|
+
path.relative(this._config.projectRoot, entryFile)
|
|
670
|
+
),
|
|
644
671
|
runModule: serializerOptions.runModule,
|
|
645
672
|
sourceMapUrl: serializerOptions.sourceMapUrl,
|
|
646
673
|
sourceUrl: serializerOptions.sourceUrl,
|
|
647
|
-
inlineSourceMap: serializerOptions.inlineSourceMap
|
|
674
|
+
inlineSourceMap: serializerOptions.inlineSourceMap,
|
|
648
675
|
}
|
|
649
676
|
);
|
|
650
677
|
const bundleCode = typeof bundle === "string" ? bundle : bundle.code;
|
|
@@ -654,7 +681,7 @@ class Server {
|
|
|
654
681
|
: delta.added.size + delta.modified.size + delta.deleted.size,
|
|
655
682
|
lastModifiedDate: revision.date,
|
|
656
683
|
nextRevId: revision.id,
|
|
657
|
-
bundle: bundleCode
|
|
684
|
+
bundle: bundleCode,
|
|
658
685
|
};
|
|
659
686
|
},
|
|
660
687
|
|
|
@@ -675,7 +702,7 @@ class Server {
|
|
|
675
702
|
String(result.numModifiedFiles)
|
|
676
703
|
);
|
|
677
704
|
mres.setHeader(DELTA_ID_HEADER, String(result.nextRevId));
|
|
678
|
-
mres.setHeader("Content-Type", "application/javascript");
|
|
705
|
+
mres.setHeader("Content-Type", "application/javascript; charset=UTF-8");
|
|
679
706
|
mres.setHeader("Last-Modified", result.lastModifiedDate.toUTCString());
|
|
680
707
|
mres.setHeader(
|
|
681
708
|
"Content-Length",
|
|
@@ -689,7 +716,7 @@ class Server {
|
|
|
689
716
|
await this._bundler.endGraph(graphId);
|
|
690
717
|
res.statusCode = 204;
|
|
691
718
|
res.end();
|
|
692
|
-
}
|
|
719
|
+
},
|
|
693
720
|
});
|
|
694
721
|
_processBytecodeBundleRequest = this._createRequestProcessor({
|
|
695
722
|
createStartEntry(context) {
|
|
@@ -700,13 +727,13 @@ class Server {
|
|
|
700
727
|
bundler: "delta",
|
|
701
728
|
build_id: context.buildID,
|
|
702
729
|
bundle_options: context.bundleOptions,
|
|
703
|
-
bundle_hash: context.graphId
|
|
730
|
+
bundle_hash: context.graphId,
|
|
704
731
|
};
|
|
705
732
|
},
|
|
706
733
|
|
|
707
734
|
createEndEntry(context) {
|
|
708
735
|
return {
|
|
709
|
-
outdated_modules: context.result.numModifiedFiles
|
|
736
|
+
outdated_modules: context.result.numModifiedFiles,
|
|
710
737
|
};
|
|
711
738
|
},
|
|
712
739
|
|
|
@@ -716,7 +743,7 @@ class Server {
|
|
|
716
743
|
graphOptions,
|
|
717
744
|
onProgress,
|
|
718
745
|
serializerOptions,
|
|
719
|
-
transformOptions
|
|
746
|
+
transformOptions,
|
|
720
747
|
}) => {
|
|
721
748
|
const revPromise = this._bundler.getRevisionByGraphId(graphId);
|
|
722
749
|
|
|
@@ -724,14 +751,15 @@ class Server {
|
|
|
724
751
|
? this._bundler.updateGraph(await revPromise, false)
|
|
725
752
|
: this._bundler.initializeGraph(entryFile, transformOptions, {
|
|
726
753
|
onProgress,
|
|
727
|
-
shallow: graphOptions.shallow
|
|
754
|
+
shallow: graphOptions.shallow,
|
|
728
755
|
}));
|
|
729
756
|
const bundle = bundleToBytecode(
|
|
730
757
|
baseBytecodeBundle(entryFile, revision.prepend, revision.graph, {
|
|
731
758
|
asyncRequireModulePath: await this._resolveRelativePath(
|
|
732
759
|
this._config.transformer.asyncRequireModulePath,
|
|
733
760
|
{
|
|
734
|
-
transformOptions
|
|
761
|
+
transformOptions,
|
|
762
|
+
relativeTo: "project",
|
|
735
763
|
}
|
|
736
764
|
),
|
|
737
765
|
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
@@ -740,13 +768,14 @@ class Server {
|
|
|
740
768
|
dev: transformOptions.dev,
|
|
741
769
|
projectRoot: this._config.projectRoot,
|
|
742
770
|
modulesOnly: serializerOptions.modulesOnly,
|
|
743
|
-
runBeforeMainModule:
|
|
744
|
-
|
|
745
|
-
|
|
771
|
+
runBeforeMainModule:
|
|
772
|
+
this._config.serializer.getModulesRunBeforeMainModule(
|
|
773
|
+
path.relative(this._config.projectRoot, entryFile)
|
|
774
|
+
),
|
|
746
775
|
runModule: serializerOptions.runModule,
|
|
747
776
|
sourceMapUrl: serializerOptions.sourceMapUrl,
|
|
748
777
|
sourceUrl: serializerOptions.sourceUrl,
|
|
749
|
-
inlineSourceMap: serializerOptions.inlineSourceMap
|
|
778
|
+
inlineSourceMap: serializerOptions.inlineSourceMap,
|
|
750
779
|
})
|
|
751
780
|
);
|
|
752
781
|
return {
|
|
@@ -755,7 +784,7 @@ class Server {
|
|
|
755
784
|
: delta.added.size + delta.modified.size + delta.deleted.size,
|
|
756
785
|
lastModifiedDate: revision.date,
|
|
757
786
|
nextRevId: revision.id,
|
|
758
|
-
bytecode: bundle.bytecode
|
|
787
|
+
bytecode: bundle.bytecode,
|
|
759
788
|
};
|
|
760
789
|
},
|
|
761
790
|
|
|
@@ -784,7 +813,7 @@ class Server {
|
|
|
784
813
|
);
|
|
785
814
|
mres.end(result.bytecode);
|
|
786
815
|
}
|
|
787
|
-
}
|
|
816
|
+
},
|
|
788
817
|
}); // This function ensures that modules in source maps are sorted in the same
|
|
789
818
|
// order as in a plain JS bundle.
|
|
790
819
|
|
|
@@ -806,13 +835,13 @@ class Server {
|
|
|
806
835
|
action_name: "Requesting sourcemap",
|
|
807
836
|
bundle_url: context.req.url,
|
|
808
837
|
entry_point: context.entryFile,
|
|
809
|
-
bundler: "delta"
|
|
838
|
+
bundler: "delta",
|
|
810
839
|
};
|
|
811
840
|
},
|
|
812
841
|
|
|
813
842
|
createEndEntry(context) {
|
|
814
843
|
return {
|
|
815
|
-
bundler: "delta"
|
|
844
|
+
bundler: "delta",
|
|
816
845
|
};
|
|
817
846
|
},
|
|
818
847
|
|
|
@@ -822,7 +851,7 @@ class Server {
|
|
|
822
851
|
graphOptions,
|
|
823
852
|
onProgress,
|
|
824
853
|
serializerOptions,
|
|
825
|
-
transformOptions
|
|
854
|
+
transformOptions,
|
|
826
855
|
}) => {
|
|
827
856
|
let revision;
|
|
828
857
|
|
|
@@ -834,7 +863,7 @@ class Server {
|
|
|
834
863
|
transformOptions,
|
|
835
864
|
{
|
|
836
865
|
onProgress,
|
|
837
|
-
shallow: graphOptions.shallow
|
|
866
|
+
shallow: graphOptions.shallow,
|
|
838
867
|
}
|
|
839
868
|
));
|
|
840
869
|
} else {
|
|
@@ -852,14 +881,14 @@ class Server {
|
|
|
852
881
|
|
|
853
882
|
return sourceMapString([...prepend, ...this._getSortedModules(graph)], {
|
|
854
883
|
excludeSource: serializerOptions.excludeSource,
|
|
855
|
-
processModuleFilter: this._config.serializer.processModuleFilter
|
|
884
|
+
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
856
885
|
});
|
|
857
886
|
},
|
|
858
887
|
|
|
859
888
|
finish({ mres, result }) {
|
|
860
889
|
mres.setHeader("Content-Type", "application/json");
|
|
861
890
|
mres.end(result.toString());
|
|
862
|
-
}
|
|
891
|
+
},
|
|
863
892
|
});
|
|
864
893
|
_processAssetsRequest = this._createRequestProcessor({
|
|
865
894
|
createStartEntry(context) {
|
|
@@ -867,13 +896,13 @@ class Server {
|
|
|
867
896
|
action_name: "Requesting assets",
|
|
868
897
|
bundle_url: context.req.url,
|
|
869
898
|
entry_point: context.entryFile,
|
|
870
|
-
bundler: "delta"
|
|
899
|
+
bundler: "delta",
|
|
871
900
|
};
|
|
872
901
|
},
|
|
873
902
|
|
|
874
903
|
createEndEntry(context) {
|
|
875
904
|
return {
|
|
876
|
-
bundler: "delta"
|
|
905
|
+
bundler: "delta",
|
|
877
906
|
};
|
|
878
907
|
},
|
|
879
908
|
|
|
@@ -883,7 +912,7 @@ class Server {
|
|
|
883
912
|
transformOptions,
|
|
884
913
|
{
|
|
885
914
|
onProgress,
|
|
886
|
-
shallow: false
|
|
915
|
+
shallow: false,
|
|
887
916
|
}
|
|
888
917
|
);
|
|
889
918
|
return await getAssets(dependencies, {
|
|
@@ -891,48 +920,50 @@ class Server {
|
|
|
891
920
|
assetPlugins: this._config.transformer.assetPlugins,
|
|
892
921
|
platform: transformOptions.platform,
|
|
893
922
|
publicPath: this._config.transformer.publicPath,
|
|
894
|
-
projectRoot: this._config.projectRoot
|
|
923
|
+
projectRoot: this._config.projectRoot,
|
|
895
924
|
});
|
|
896
925
|
},
|
|
897
926
|
|
|
898
927
|
finish({ mres, result }) {
|
|
899
928
|
mres.setHeader("Content-Type", "application/json");
|
|
900
929
|
mres.end(JSON.stringify(result));
|
|
901
|
-
}
|
|
930
|
+
},
|
|
902
931
|
});
|
|
903
932
|
|
|
904
933
|
async _symbolicate(req, res) {
|
|
905
934
|
const getCodeFrame = (urls, symbolicatedStack) => {
|
|
906
935
|
for (let i = 0; i < symbolicatedStack.length; i++) {
|
|
907
|
-
const { collapse, column, file, lineNumber } = symbolicatedStack[i];
|
|
908
|
-
|
|
909
|
-
|
|
936
|
+
const { collapse, column, file, lineNumber } = symbolicatedStack[i];
|
|
937
|
+
const fileAbsolute = path.resolve(
|
|
938
|
+
this._config.projectRoot,
|
|
939
|
+
file !== null && file !== void 0 ? file : ""
|
|
940
|
+
);
|
|
910
941
|
|
|
911
|
-
if (collapse || lineNumber == null || urls.has(
|
|
942
|
+
if (collapse || lineNumber == null || urls.has(fileAbsolute)) {
|
|
912
943
|
continue;
|
|
913
944
|
}
|
|
914
945
|
|
|
915
946
|
try {
|
|
916
947
|
return {
|
|
917
948
|
content: codeFrameColumns(
|
|
918
|
-
fs.readFileSync(
|
|
949
|
+
fs.readFileSync(fileAbsolute, "utf8"),
|
|
919
950
|
{
|
|
920
951
|
// Metro returns 0 based columns but codeFrameColumns expects 1-based columns
|
|
921
952
|
// $FlowFixMe[unsafe-addition]
|
|
922
953
|
start: {
|
|
923
954
|
column: column + 1,
|
|
924
|
-
line: lineNumber
|
|
925
|
-
}
|
|
955
|
+
line: lineNumber,
|
|
956
|
+
},
|
|
926
957
|
},
|
|
927
958
|
{
|
|
928
|
-
forceColor: true
|
|
959
|
+
forceColor: true,
|
|
929
960
|
}
|
|
930
961
|
),
|
|
931
962
|
location: {
|
|
932
963
|
row: lineNumber,
|
|
933
|
-
column
|
|
964
|
+
column,
|
|
934
965
|
},
|
|
935
|
-
fileName: file
|
|
966
|
+
fileName: file,
|
|
936
967
|
};
|
|
937
968
|
} catch (error) {
|
|
938
969
|
console.error(error);
|
|
@@ -950,11 +981,11 @@ class Server {
|
|
|
950
981
|
/* $FlowFixMe: where is `rawBody` defined? Is it added by the `connect` framework? */
|
|
951
982
|
|
|
952
983
|
const body = await req.rawBody;
|
|
953
|
-
const stack = JSON.parse(body).stack.map(frame => {
|
|
984
|
+
const stack = JSON.parse(body).stack.map((frame) => {
|
|
954
985
|
if (frame.file && frame.file.includes("://")) {
|
|
955
986
|
return {
|
|
956
987
|
...frame,
|
|
957
|
-
file: this._config.server.rewriteRequestUrl(frame.file)
|
|
988
|
+
file: this._config.server.rewriteRequestUrl(frame.file),
|
|
958
989
|
};
|
|
959
990
|
}
|
|
960
991
|
|
|
@@ -962,7 +993,7 @@ class Server {
|
|
|
962
993
|
}); // In case of multiple bundles / HMR, some stack frames can have different URLs from others
|
|
963
994
|
|
|
964
995
|
const urls = new Set();
|
|
965
|
-
stack.forEach(frame => {
|
|
996
|
+
stack.forEach((frame) => {
|
|
966
997
|
const sourceUrl = frame.file; // Skip `/debuggerWorker.js` which does not need symbolication.
|
|
967
998
|
|
|
968
999
|
if (
|
|
@@ -976,6 +1007,7 @@ class Server {
|
|
|
976
1007
|
});
|
|
977
1008
|
debug("Getting source maps for symbolication");
|
|
978
1009
|
const sourceMaps = await Promise.all(
|
|
1010
|
+
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
979
1011
|
Array.from(urls.values()).map(this._explodedSourceMapForURL, this)
|
|
980
1012
|
);
|
|
981
1013
|
debug("Performing fast symbolication");
|
|
@@ -988,7 +1020,7 @@ class Server {
|
|
|
988
1020
|
res.end(
|
|
989
1021
|
JSON.stringify({
|
|
990
1022
|
codeFrame: getCodeFrame(urls, symbolicatedStack),
|
|
991
|
-
stack: symbolicatedStack
|
|
1023
|
+
stack: symbolicatedStack,
|
|
992
1024
|
})
|
|
993
1025
|
);
|
|
994
1026
|
process.nextTick(() => {
|
|
@@ -999,7 +1031,7 @@ class Server {
|
|
|
999
1031
|
res.statusCode = 500;
|
|
1000
1032
|
res.end(
|
|
1001
1033
|
JSON.stringify({
|
|
1002
|
-
error: error.message
|
|
1034
|
+
error: error.message,
|
|
1003
1035
|
})
|
|
1004
1036
|
);
|
|
1005
1037
|
}
|
|
@@ -1016,7 +1048,7 @@ class Server {
|
|
|
1016
1048
|
transformOptions,
|
|
1017
1049
|
serializerOptions,
|
|
1018
1050
|
graphOptions,
|
|
1019
|
-
onProgress
|
|
1051
|
+
onProgress,
|
|
1020
1052
|
} = splitBundleOptions(options);
|
|
1021
1053
|
/**
|
|
1022
1054
|
* `entryFile` is relative to projectRoot, we need to use resolution function
|
|
@@ -1024,12 +1056,13 @@ class Server {
|
|
|
1024
1056
|
*/
|
|
1025
1057
|
|
|
1026
1058
|
const resolvedEntryFilePath = await this._resolveRelativePath(entryFile, {
|
|
1027
|
-
transformOptions
|
|
1059
|
+
transformOptions,
|
|
1060
|
+
relativeTo: "server",
|
|
1028
1061
|
});
|
|
1029
1062
|
const graphId = getGraphId(resolvedEntryFilePath, transformOptions, {
|
|
1030
1063
|
shallow: graphOptions.shallow,
|
|
1031
|
-
experimentalImportBundleSupport:
|
|
1032
|
-
.experimentalImportBundleSupport
|
|
1064
|
+
experimentalImportBundleSupport:
|
|
1065
|
+
this._config.transformer.experimentalImportBundleSupport,
|
|
1033
1066
|
});
|
|
1034
1067
|
let revision;
|
|
1035
1068
|
|
|
@@ -1041,7 +1074,7 @@ class Server {
|
|
|
1041
1074
|
transformOptions,
|
|
1042
1075
|
{
|
|
1043
1076
|
onProgress,
|
|
1044
|
-
shallow: graphOptions.shallow
|
|
1077
|
+
shallow: graphOptions.shallow,
|
|
1045
1078
|
}
|
|
1046
1079
|
));
|
|
1047
1080
|
} else {
|
|
@@ -1057,17 +1090,21 @@ class Server {
|
|
|
1057
1090
|
return getExplodedSourceMap(
|
|
1058
1091
|
[...prepend, ...this._getSortedModules(graph)],
|
|
1059
1092
|
{
|
|
1060
|
-
processModuleFilter: this._config.serializer.processModuleFilter
|
|
1093
|
+
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
1061
1094
|
}
|
|
1062
1095
|
);
|
|
1063
1096
|
}
|
|
1064
1097
|
|
|
1065
|
-
async _resolveRelativePath(filePath, { transformOptions }) {
|
|
1098
|
+
async _resolveRelativePath(filePath, { transformOptions, relativeTo }) {
|
|
1066
1099
|
const resolutionFn = await transformHelpers.getResolveDependencyFn(
|
|
1067
1100
|
this._bundler.getBundler(),
|
|
1068
1101
|
transformOptions.platform
|
|
1069
1102
|
);
|
|
1070
|
-
|
|
1103
|
+
const rootDir =
|
|
1104
|
+
relativeTo === "server"
|
|
1105
|
+
? this._getServerRootDir()
|
|
1106
|
+
: this._config.projectRoot;
|
|
1107
|
+
return resolutionFn(`${rootDir}/.`, filePath);
|
|
1071
1108
|
}
|
|
1072
1109
|
|
|
1073
1110
|
getNewBuildID() {
|
|
@@ -1088,7 +1125,7 @@ class Server {
|
|
|
1088
1125
|
hot: false,
|
|
1089
1126
|
minify: false,
|
|
1090
1127
|
runtimeBytecodeVersion: null,
|
|
1091
|
-
unstable_transformProfile: "default"
|
|
1128
|
+
unstable_transformProfile: "default",
|
|
1092
1129
|
};
|
|
1093
1130
|
static DEFAULT_BUNDLE_OPTIONS = {
|
|
1094
1131
|
...Server.DEFAULT_GRAPH_OPTIONS,
|
|
@@ -1099,8 +1136,25 @@ class Server {
|
|
|
1099
1136
|
runModule: true,
|
|
1100
1137
|
shallow: false,
|
|
1101
1138
|
sourceMapUrl: null,
|
|
1102
|
-
sourceUrl: null
|
|
1139
|
+
sourceUrl: null,
|
|
1103
1140
|
};
|
|
1141
|
+
|
|
1142
|
+
_getServerRootDir() {
|
|
1143
|
+
var _this$_config$server$;
|
|
1144
|
+
|
|
1145
|
+
return (_this$_config$server$ = this._config.server.unstable_serverRoot) !==
|
|
1146
|
+
null && _this$_config$server$ !== void 0
|
|
1147
|
+
? _this$_config$server$
|
|
1148
|
+
: this._config.projectRoot;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
_getEntryPointAbsolutePath(entryFile) {
|
|
1152
|
+
return path.resolve(this._getServerRootDir(), entryFile);
|
|
1153
|
+
} // Wait for the server to finish initializing.
|
|
1154
|
+
|
|
1155
|
+
async ready() {
|
|
1156
|
+
await this._bundler.ready();
|
|
1157
|
+
}
|
|
1104
1158
|
}
|
|
1105
1159
|
|
|
1106
1160
|
function* zip(xs, ys) {
|