metro 0.83.1 → 0.83.2
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 +15 -15
- package/src/Assets.js +68 -42
- package/src/Assets.js.flow +13 -24
- package/src/Bundler/util.js +40 -17
- package/src/Bundler/util.js.flow +6 -13
- package/src/Bundler.js +17 -6
- package/src/Bundler.js.flow +3 -7
- package/src/DeltaBundler/DeltaCalculator.js +14 -10
- package/src/DeltaBundler/DeltaCalculator.js.flow +4 -7
- package/src/DeltaBundler/Graph.js +44 -35
- package/src/DeltaBundler/Graph.js.flow +3 -4
- package/src/DeltaBundler/Serializers/baseJSBundle.js +24 -10
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +6 -9
- package/src/DeltaBundler/Serializers/getAllFiles.js +9 -6
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +4 -8
- package/src/DeltaBundler/Serializers/getAssets.js +18 -11
- package/src/DeltaBundler/Serializers/getAssets.js.flow +5 -9
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +26 -0
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js +7 -6
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +3 -9
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js +40 -23
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +11 -18
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js +4 -1
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js.flow +1 -5
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js +7 -4
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +3 -7
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js +4 -1
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js.flow +2 -6
- package/src/DeltaBundler/Serializers/helpers/js.js +65 -31
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +21 -21
- package/src/DeltaBundler/Serializers/helpers/processModules.js +8 -5
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -7
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +70 -25
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +43 -33
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +19 -16
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -14
- package/src/DeltaBundler/Serializers/sourceMapObject.js +12 -10
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +4 -9
- package/src/DeltaBundler/Serializers/sourceMapString.js +14 -12
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +4 -9
- package/src/DeltaBundler/Transformer.js +31 -22
- package/src/DeltaBundler/Transformer.js.flow +10 -17
- package/src/DeltaBundler/Worker.flow.js +25 -18
- package/src/DeltaBundler/Worker.flow.js.flow +12 -18
- package/src/DeltaBundler/Worker.js.flow +2 -0
- package/src/DeltaBundler/WorkerFarm.js +13 -11
- package/src/DeltaBundler/WorkerFarm.js.flow +7 -9
- package/src/DeltaBundler/buildSubgraph.js +12 -12
- package/src/DeltaBundler/buildSubgraph.js.flow +1 -1
- package/src/DeltaBundler/getTransformCacheKey.js +12 -6
- package/src/DeltaBundler/getTransformCacheKey.js.flow +5 -7
- package/src/DeltaBundler/mergeDeltas.js +4 -1
- package/src/DeltaBundler/mergeDeltas.js.flow +5 -6
- package/src/DeltaBundler/types.d.ts +4 -1
- package/src/DeltaBundler/{types.flow.js.flow → types.js.flow} +5 -3
- package/src/DeltaBundler.js +15 -6
- package/src/DeltaBundler.js.flow +4 -8
- package/src/HmrServer.js +116 -68
- package/src/HmrServer.js.flow +41 -52
- package/src/IncrementalBundler/GraphNotFoundError.js +5 -1
- package/src/IncrementalBundler/GraphNotFoundError.js.flow +1 -5
- package/src/IncrementalBundler/ResourceNotFoundError.js +5 -1
- package/src/IncrementalBundler/ResourceNotFoundError.js.flow +1 -5
- package/src/IncrementalBundler/RevisionNotFoundError.js +5 -1
- package/src/IncrementalBundler/RevisionNotFoundError.js.flow +1 -5
- package/src/IncrementalBundler.js +71 -35
- package/src/IncrementalBundler.js.flow +12 -16
- package/src/ModuleGraph/test-helpers.js +19 -14
- package/src/ModuleGraph/worker/JsFileWrapping.js +19 -18
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +1 -10
- package/src/ModuleGraph/worker/collectDependencies.js +81 -52
- package/src/ModuleGraph/worker/collectDependencies.js.flow +15 -22
- package/src/ModuleGraph/worker/generateImportNames.js +12 -6
- package/src/ModuleGraph/worker/generateImportNames.js.flow +3 -7
- package/src/ModuleGraph/worker/importLocationsPlugin.js +5 -4
- package/src/ModuleGraph/worker/importLocationsPlugin.js.flow +2 -4
- package/src/Server/MultipartResponse.js +11 -4
- package/src/Server/MultipartResponse.js.flow +2 -5
- package/src/Server/symbolicate.d.ts +31 -0
- package/src/Server/symbolicate.js +15 -16
- package/src/Server/symbolicate.js.flow +6 -16
- package/src/Server.d.ts +0 -1
- package/src/Server.js +298 -191
- package/src/Server.js.flow +136 -99
- package/src/cli-utils.js +13 -4
- package/src/cli-utils.js.flow +3 -5
- package/src/cli.js.flow +2 -0
- package/src/commands/build.js +17 -10
- package/src/commands/build.js.flow +6 -6
- package/src/commands/dependencies.js +26 -16
- package/src/commands/dependencies.js.flow +7 -9
- package/src/commands/serve.js +16 -11
- package/src/commands/serve.js.flow +5 -6
- package/src/index.d.ts +26 -3
- package/src/index.flow.js +162 -72
- package/src/index.flow.js.flow +60 -47
- package/src/index.js.flow +2 -0
- package/src/integration_tests/basic_bundle/TestBundle.js.flow +2 -1
- package/src/integration_tests/basic_bundle/import-export/index.js +2 -2
- package/src/integration_tests/basic_bundle/require-context/mode-eager.js +2 -2
- package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js +2 -2
- package/src/integration_tests/basic_bundle/require-context/mode-lazy.js +2 -2
- package/src/integration_tests/basic_bundle/require-context/mode-sync.js +1 -1
- package/src/integration_tests/basic_bundle/require-context/utils.js +1 -1
- package/src/integration_tests/execBundle.js +7 -4
- package/src/integration_tests/execBundle.js.flow +1 -3
- package/src/integration_tests/metro.config.js +3 -3
- package/src/lib/BatchProcessor.js +15 -5
- package/src/lib/BatchProcessor.js.flow +2 -6
- package/src/lib/CountingSet.js.flow +2 -2
- package/src/lib/JsonReporter.js +6 -2
- package/src/lib/JsonReporter.js.flow +1 -5
- package/src/lib/RamBundleParser.js +12 -3
- package/src/lib/RamBundleParser.js.flow +2 -6
- package/src/lib/TerminalReporter.js +95 -56
- package/src/lib/TerminalReporter.js.flow +9 -12
- package/src/lib/bundleToString.js +4 -1
- package/src/lib/bundleToString.js.flow +2 -9
- package/src/lib/contextModule.js +2 -2
- package/src/lib/contextModuleTemplates.js +7 -13
- package/src/lib/countLines.js +5 -1
- package/src/lib/countLines.js.flow +1 -3
- package/src/lib/createWebsocketServer.js +6 -2
- package/src/lib/createWebsocketServer.js.flow +4 -4
- package/src/lib/debounceAsyncQueue.js +4 -1
- package/src/lib/debounceAsyncQueue.js.flow +1 -5
- package/src/lib/formatBundlingError.js +32 -22
- package/src/lib/formatBundlingError.js.flow +18 -20
- package/src/lib/getAppendScripts.js +19 -15
- package/src/lib/getAppendScripts.js.flow +9 -13
- package/src/lib/getGraphId.js +12 -6
- package/src/lib/getGraphId.js.flow +4 -10
- package/src/lib/getPreludeCode.js +7 -10
- package/src/lib/getPreludeCode.js.flow +2 -6
- package/src/lib/getPrependedScripts.js +39 -11
- package/src/lib/getPrependedScripts.js.flow +8 -13
- package/src/lib/isResolvedDependency.js.flow +1 -1
- package/src/lib/logToConsole.js +18 -12
- package/src/lib/logToConsole.js.flow +5 -14
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +144 -0
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.js.flow +146 -0
- package/src/lib/parseCustomResolverOptions.js +8 -6
- package/src/lib/parseCustomResolverOptions.js.flow +6 -12
- package/src/lib/parseCustomTransformOptions.js +8 -6
- package/src/lib/parseCustomTransformOptions.js.flow +11 -14
- package/src/lib/parseJsonBody.js +4 -1
- package/src/lib/parseJsonBody.js.flow +1 -3
- package/src/lib/pathUtils.js +34 -0
- package/src/lib/pathUtils.js.flow +16 -0
- package/src/lib/relativizeSourceMap.js +12 -3
- package/src/lib/relativizeSourceMap.js.flow +2 -6
- package/src/lib/reporting.js +25 -19
- package/src/lib/reporting.js.flow +6 -16
- package/src/lib/splitBundleOptions.js +4 -2
- package/src/lib/splitBundleOptions.js.flow +4 -7
- package/src/lib/transformHelpers.js +18 -20
- package/src/lib/transformHelpers.js.flow +5 -15
- package/src/node-haste/DependencyGraph/ModuleResolution.js +75 -57
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +28 -44
- package/src/node-haste/DependencyGraph/createFileMap.js +13 -7
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +2 -5
- package/src/node-haste/DependencyGraph.js +61 -45
- package/src/node-haste/DependencyGraph.js.flow +34 -31
- package/src/node-haste/Package.js +13 -6
- package/src/node-haste/Package.js.flow +3 -7
- package/src/node-haste/{ModuleCache.js → PackageCache.js} +11 -19
- package/src/node-haste/{ModuleCache.js.flow → PackageCache.js.flow} +2 -30
- package/src/node-haste/lib/AssetPaths.js +14 -8
- package/src/node-haste/lib/AssetPaths.js.flow +7 -8
- package/src/node-haste/lib/parsePlatformFilePath.js +10 -4
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +2 -6
- package/src/shared/output/RamBundle/as-assets.js +42 -22
- package/src/shared/output/RamBundle/as-assets.js.flow +12 -15
- package/src/shared/output/RamBundle/as-indexed-file.js +33 -23
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +10 -16
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js +11 -10
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +4 -6
- package/src/shared/output/RamBundle/magic-number.js +5 -1
- package/src/shared/output/RamBundle/magic-number.js.flow +1 -3
- package/src/shared/output/RamBundle/util.js +20 -13
- package/src/shared/output/RamBundle/util.js.flow +4 -6
- package/src/shared/output/RamBundle/write-sourcemap.js +9 -3
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +2 -6
- package/src/shared/output/RamBundle.js +16 -9
- package/src/shared/output/RamBundle.js.flow +8 -12
- package/src/shared/output/bundle.flow.js +37 -13
- package/src/shared/output/bundle.flow.js.flow +24 -12
- package/src/shared/output/bundle.js.flow +2 -0
- package/src/shared/output/meta.js +16 -9
- package/src/shared/output/meta.js.flow +3 -5
- package/src/shared/output/unbundle.js +14 -1
- package/src/shared/output/unbundle.js.flow +1 -3
- package/src/shared/output/writeFile.js +11 -4
- package/src/shared/output/writeFile.js.flow +3 -5
- package/src/shared/types.d.ts +0 -1
- package/src/shared/{types.flow.js.flow → types.js.flow} +16 -17
- package/src/lib/createModuleIdFactory.js +0 -15
- package/src/lib/createModuleIdFactory.js.flow +0 -27
- package/src/lib/getMaxWorkers.js +0 -9
- package/src/lib/getMaxWorkers.js.flow +0 -22
- package/src/lib/parseOptionsFromUrl.js +0 -62
- package/src/lib/parseOptionsFromUrl.js.flow +0 -97
- package/src/node-haste/Module.js +0 -20
- package/src/node-haste/Module.js.flow +0 -41
- /package/src/DeltaBundler/{types.flow.js → types.js} +0 -0
- /package/src/shared/{types.flow.js → types.js} +0 -0
|
@@ -1,31 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = hmrJSBundle;
|
|
7
|
+
var _js = require("./helpers/js");
|
|
8
|
+
var jscSafeUrl = _interopRequireWildcard(require("jsc-safe-url"));
|
|
9
|
+
var _metroTransformPlugins = require("metro-transform-plugins");
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
function _interopRequireDefault(e) {
|
|
12
|
+
return e && e.__esModule ? e : { default: e };
|
|
13
|
+
}
|
|
14
|
+
function _getRequireWildcardCache(e) {
|
|
15
|
+
if ("function" != typeof WeakMap) return null;
|
|
16
|
+
var r = new WeakMap(),
|
|
17
|
+
t = new WeakMap();
|
|
18
|
+
return (_getRequireWildcardCache = function (e) {
|
|
19
|
+
return e ? t : r;
|
|
20
|
+
})(e);
|
|
21
|
+
}
|
|
22
|
+
function _interopRequireWildcard(e, r) {
|
|
23
|
+
if (!r && e && e.__esModule) return e;
|
|
24
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
25
|
+
return { default: e };
|
|
26
|
+
var t = _getRequireWildcardCache(r);
|
|
27
|
+
if (t && t.has(e)) return t.get(e);
|
|
28
|
+
var n = { __proto__: null },
|
|
29
|
+
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
30
|
+
for (var u in e)
|
|
31
|
+
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
32
|
+
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
33
|
+
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
34
|
+
}
|
|
35
|
+
return ((n.default = e), t && t.set(e, n), n);
|
|
36
|
+
}
|
|
37
|
+
const debug = require("debug")("Metro:HMR");
|
|
8
38
|
function generateModules(sourceModules, graph, options) {
|
|
9
39
|
const modules = [];
|
|
10
40
|
for (const module of sourceModules) {
|
|
11
|
-
if (isJsModule(module)) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
41
|
+
if ((0, _js.isJsModule)(module)) {
|
|
42
|
+
const getPathname = (extension) => {
|
|
43
|
+
return _path.default
|
|
44
|
+
.relative(
|
|
45
|
+
options.serverRoot ?? options.projectRoot,
|
|
46
|
+
_path.default.join(
|
|
47
|
+
_path.default.dirname(module.path),
|
|
48
|
+
_path.default.basename(
|
|
49
|
+
module.path,
|
|
50
|
+
_path.default.extname(module.path),
|
|
51
|
+
) +
|
|
52
|
+
"." +
|
|
53
|
+
extension,
|
|
54
|
+
),
|
|
22
55
|
)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
56
|
+
.split(_path.default.sep)
|
|
57
|
+
.map((segment) => encodeURIComponent(segment))
|
|
58
|
+
.join("/");
|
|
26
59
|
};
|
|
27
|
-
const
|
|
28
|
-
|
|
60
|
+
const clientUrl = new URL(options.clientUrl);
|
|
61
|
+
clientUrl.searchParams.delete("excludeSource");
|
|
62
|
+
clientUrl.pathname = getPathname("map");
|
|
63
|
+
const sourceMappingURL = clientUrl.toString();
|
|
64
|
+
clientUrl.pathname = getPathname("bundle");
|
|
65
|
+
const sourceURL = jscSafeUrl.toJscSafeUrl(clientUrl.toString());
|
|
66
|
+
debug(
|
|
67
|
+
"got sourceMappingURL: %s\nand sourceURL: %s\nfor module: %s",
|
|
68
|
+
sourceMappingURL,
|
|
69
|
+
sourceURL,
|
|
70
|
+
module.path,
|
|
71
|
+
);
|
|
29
72
|
const code =
|
|
30
73
|
prepareModule(module, graph, options) +
|
|
31
74
|
`\n//# sourceMappingURL=${sourceMappingURL}\n` +
|
|
@@ -40,9 +83,9 @@ function generateModules(sourceModules, graph, options) {
|
|
|
40
83
|
return modules;
|
|
41
84
|
}
|
|
42
85
|
function prepareModule(module, graph, options) {
|
|
43
|
-
const code = wrapModule(module, {
|
|
86
|
+
const code = (0, _js.wrapModule)(module, {
|
|
44
87
|
...options,
|
|
45
|
-
sourceUrl:
|
|
88
|
+
sourceUrl: options.clientUrl.toString(),
|
|
46
89
|
dev: true,
|
|
47
90
|
});
|
|
48
91
|
const inverseDependencies = getInverseDependencies(module.path, graph);
|
|
@@ -52,7 +95,10 @@ function prepareModule(module, graph, options) {
|
|
|
52
95
|
path
|
|
53
96
|
].map(options.createModuleId);
|
|
54
97
|
});
|
|
55
|
-
return
|
|
98
|
+
return (0, _metroTransformPlugins.addParamsToDefineCall)(
|
|
99
|
+
code,
|
|
100
|
+
inverseDependenciesById,
|
|
101
|
+
);
|
|
56
102
|
}
|
|
57
103
|
function getInverseDependencies(path, graph, inverseDependencies = {}) {
|
|
58
104
|
if (path in inverseDependencies) {
|
|
@@ -76,4 +122,3 @@ function hmrJSBundle(delta, graph, options) {
|
|
|
76
122
|
deleted: [...delta.deleted].map((path) => options.createModuleId(path)),
|
|
77
123
|
};
|
|
78
124
|
}
|
|
79
|
-
module.exports = hmrJSBundle;
|
|
@@ -9,20 +9,19 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
import type {DeltaResult, Module, ReadOnlyGraph} from '../types';
|
|
13
|
+
import type {HmrModule} from 'metro-runtime/src/modules/types';
|
|
13
14
|
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
15
|
+
import {isJsModule, wrapModule} from './helpers/js';
|
|
16
|
+
import * as jscSafeUrl from 'jsc-safe-url';
|
|
17
|
+
import {addParamsToDefineCall} from 'metro-transform-plugins';
|
|
18
|
+
import path from 'path';
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
const {addParamsToDefineCall} = require('metro-transform-plugins');
|
|
21
|
-
const path = require('path');
|
|
22
|
-
const url = require('url');
|
|
20
|
+
// eslint-disable-next-line import/no-commonjs
|
|
21
|
+
const debug = require('debug')('Metro:HMR');
|
|
23
22
|
|
|
24
23
|
type Options = $ReadOnly<{
|
|
25
|
-
clientUrl:
|
|
24
|
+
clientUrl: URL,
|
|
26
25
|
createModuleId: string => number,
|
|
27
26
|
includeAsyncPaths: boolean,
|
|
28
27
|
projectRoot: string,
|
|
@@ -39,28 +38,41 @@ function generateModules(
|
|
|
39
38
|
|
|
40
39
|
for (const module of sourceModules) {
|
|
41
40
|
if (isJsModule(module)) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
41
|
+
const getPathname = (extension: 'bundle' | 'map') => {
|
|
42
|
+
return (
|
|
43
|
+
path
|
|
44
|
+
.relative(
|
|
45
|
+
options.serverRoot ?? options.projectRoot,
|
|
46
|
+
path.join(
|
|
47
|
+
path.dirname(module.path),
|
|
48
|
+
path.basename(module.path, path.extname(module.path)) +
|
|
49
|
+
'.' +
|
|
50
|
+
extension,
|
|
51
|
+
),
|
|
52
|
+
)
|
|
53
|
+
.split(path.sep)
|
|
54
|
+
// using this Metro particular convention for encoding file paths as URL paths.
|
|
55
|
+
.map(segment => encodeURIComponent(segment))
|
|
56
|
+
.join('/')
|
|
57
57
|
);
|
|
58
|
-
delete moduleUrl.query.excludeSource;
|
|
59
|
-
return url.format(moduleUrl);
|
|
60
58
|
};
|
|
61
59
|
|
|
62
|
-
const
|
|
63
|
-
|
|
60
|
+
const clientUrl = new URL(options.clientUrl);
|
|
61
|
+
clientUrl.searchParams.delete('excludeSource');
|
|
62
|
+
|
|
63
|
+
clientUrl.pathname = getPathname('map');
|
|
64
|
+
const sourceMappingURL = clientUrl.toString();
|
|
65
|
+
|
|
66
|
+
clientUrl.pathname = getPathname('bundle');
|
|
67
|
+
const sourceURL = jscSafeUrl.toJscSafeUrl(clientUrl.toString());
|
|
68
|
+
|
|
69
|
+
debug(
|
|
70
|
+
'got sourceMappingURL: %s\nand sourceURL: %s\nfor module: %s',
|
|
71
|
+
sourceMappingURL,
|
|
72
|
+
sourceURL,
|
|
73
|
+
module.path,
|
|
74
|
+
);
|
|
75
|
+
|
|
64
76
|
const code =
|
|
65
77
|
prepareModule(module, graph, options) +
|
|
66
78
|
`\n//# sourceMappingURL=${sourceMappingURL}\n` +
|
|
@@ -84,7 +96,7 @@ function prepareModule(
|
|
|
84
96
|
): string {
|
|
85
97
|
const code = wrapModule(module, {
|
|
86
98
|
...options,
|
|
87
|
-
sourceUrl:
|
|
99
|
+
sourceUrl: options.clientUrl.toString(),
|
|
88
100
|
dev: true,
|
|
89
101
|
});
|
|
90
102
|
|
|
@@ -131,7 +143,7 @@ function getInverseDependencies(
|
|
|
131
143
|
return inverseDependencies;
|
|
132
144
|
}
|
|
133
145
|
|
|
134
|
-
function hmrJSBundle(
|
|
146
|
+
export default function hmrJSBundle(
|
|
135
147
|
delta: DeltaResult<>,
|
|
136
148
|
graph: ReadOnlyGraph<>,
|
|
137
149
|
options: Options,
|
|
@@ -148,5 +160,3 @@ function hmrJSBundle(
|
|
|
148
160
|
),
|
|
149
161
|
};
|
|
150
162
|
}
|
|
151
|
-
|
|
152
|
-
module.exports = hmrJSBundle;
|
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.sourceMapGenerator = sourceMapGenerator;
|
|
7
|
+
exports.sourceMapGeneratorNonBlocking = sourceMapGeneratorNonBlocking;
|
|
8
|
+
var _getSourceMapInfo = _interopRequireDefault(
|
|
9
|
+
require("./helpers/getSourceMapInfo"),
|
|
10
|
+
);
|
|
11
|
+
var _js = require("./helpers/js");
|
|
12
|
+
var _metroSourceMap = require("metro-source-map");
|
|
13
|
+
function _interopRequireDefault(e) {
|
|
14
|
+
return e && e.__esModule ? e : { default: e };
|
|
15
|
+
}
|
|
9
16
|
function getSourceMapInfosImpl(isBlocking, onDone, modules, options) {
|
|
10
17
|
const sourceMapInfos = [];
|
|
11
18
|
const modulesToProcess = modules
|
|
12
|
-
.filter(isJsModule)
|
|
19
|
+
.filter(_js.isJsModule)
|
|
13
20
|
.filter(options.processModuleFilter);
|
|
14
21
|
function processNextModule() {
|
|
15
22
|
if (modulesToProcess.length === 0) {
|
|
16
23
|
return true;
|
|
17
24
|
}
|
|
18
25
|
const mod = modulesToProcess.shift();
|
|
19
|
-
const info =
|
|
26
|
+
const info = (0, _getSourceMapInfo.default)(mod, {
|
|
20
27
|
excludeSource: options.excludeSource,
|
|
21
28
|
shouldAddToIgnoreList: options.shouldAddToIgnoreList,
|
|
22
29
|
getSourceUrl: options.getSourceUrl,
|
|
@@ -52,22 +59,18 @@ function sourceMapGenerator(modules, options) {
|
|
|
52
59
|
sourceMapInfos = infos;
|
|
53
60
|
},
|
|
54
61
|
modules,
|
|
55
|
-
options
|
|
62
|
+
options,
|
|
56
63
|
);
|
|
57
64
|
if (sourceMapInfos == null) {
|
|
58
65
|
throw new Error(
|
|
59
|
-
"Expected getSourceMapInfosImpl() to finish synchronously."
|
|
66
|
+
"Expected getSourceMapInfosImpl() to finish synchronously.",
|
|
60
67
|
);
|
|
61
68
|
}
|
|
62
|
-
return fromRawMappings(sourceMapInfos);
|
|
69
|
+
return (0, _metroSourceMap.fromRawMappings)(sourceMapInfos);
|
|
63
70
|
}
|
|
64
71
|
async function sourceMapGeneratorNonBlocking(modules, options) {
|
|
65
72
|
const sourceMapInfos = await new Promise((resolve) => {
|
|
66
73
|
getSourceMapInfosImpl(false, resolve, modules, options);
|
|
67
74
|
});
|
|
68
|
-
return fromRawMappingsNonBlocking(sourceMapInfos);
|
|
75
|
+
return (0, _metroSourceMap.fromRawMappingsNonBlocking)(sourceMapInfos);
|
|
69
76
|
}
|
|
70
|
-
module.exports = {
|
|
71
|
-
sourceMapGenerator,
|
|
72
|
-
sourceMapGeneratorNonBlocking,
|
|
73
|
-
};
|
|
@@ -9,16 +9,11 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
import type {Module} from '../types';
|
|
13
13
|
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const {isJsModule} = require('./helpers/js');
|
|
18
|
-
const {
|
|
19
|
-
fromRawMappings,
|
|
20
|
-
fromRawMappingsNonBlocking,
|
|
21
|
-
} = require('metro-source-map');
|
|
14
|
+
import getSourceMapInfo from './helpers/getSourceMapInfo';
|
|
15
|
+
import {isJsModule} from './helpers/js';
|
|
16
|
+
import {fromRawMappings, fromRawMappingsNonBlocking} from 'metro-source-map';
|
|
22
17
|
|
|
23
18
|
export type SourceMapGeneratorOptions = $ReadOnly<{
|
|
24
19
|
excludeSource: boolean,
|
|
@@ -44,7 +39,7 @@ function getSourceMapInfosImpl(
|
|
|
44
39
|
}
|
|
45
40
|
|
|
46
41
|
const mod = modulesToProcess.shift();
|
|
47
|
-
// $FlowFixMe[incompatible-
|
|
42
|
+
// $FlowFixMe[incompatible-type]
|
|
48
43
|
const info = getSourceMapInfo(mod, {
|
|
49
44
|
excludeSource: options.excludeSource,
|
|
50
45
|
shouldAddToIgnoreList: options.shouldAddToIgnoreList,
|
|
@@ -113,7 +108,4 @@ async function sourceMapGeneratorNonBlocking(
|
|
|
113
108
|
return fromRawMappingsNonBlocking(sourceMapInfos);
|
|
114
109
|
}
|
|
115
110
|
|
|
116
|
-
|
|
117
|
-
sourceMapGenerator,
|
|
118
|
-
sourceMapGeneratorNonBlocking,
|
|
119
|
-
};
|
|
111
|
+
export {sourceMapGenerator, sourceMapGeneratorNonBlocking};
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.sourceMapObject = sourceMapObject;
|
|
7
|
+
exports.sourceMapObjectNonBlocking = sourceMapObjectNonBlocking;
|
|
8
|
+
var _sourceMapGenerator = require("./sourceMapGenerator");
|
|
7
9
|
function sourceMapObject(modules, options) {
|
|
8
|
-
const generator =
|
|
10
|
+
const generator = (0, _sourceMapGenerator.sourceMapGenerator)(
|
|
11
|
+
modules,
|
|
12
|
+
options,
|
|
13
|
+
);
|
|
9
14
|
return generator.toMap(undefined, {
|
|
10
15
|
excludeSource: options.excludeSource,
|
|
11
16
|
});
|
|
12
17
|
}
|
|
13
18
|
async function sourceMapObjectNonBlocking(modules, options) {
|
|
14
|
-
const generator = await
|
|
19
|
+
const generator = await (0,
|
|
20
|
+
_sourceMapGenerator.sourceMapGeneratorNonBlocking)(modules, options);
|
|
15
21
|
return generator.toMap(undefined, {
|
|
16
22
|
excludeSource: options.excludeSource,
|
|
17
23
|
});
|
|
18
24
|
}
|
|
19
|
-
module.exports = {
|
|
20
|
-
sourceMapObject,
|
|
21
|
-
sourceMapObjectNonBlocking,
|
|
22
|
-
};
|
|
@@ -9,16 +9,14 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import type {Module} from '../types.flow';
|
|
12
|
+
import type {Module} from '../types';
|
|
15
13
|
import type {SourceMapGeneratorOptions} from './sourceMapGenerator';
|
|
16
14
|
import type {MixedSourceMap} from 'metro-source-map';
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
import {
|
|
19
17
|
sourceMapGenerator,
|
|
20
18
|
sourceMapGeneratorNonBlocking,
|
|
21
|
-
}
|
|
19
|
+
} from './sourceMapGenerator';
|
|
22
20
|
|
|
23
21
|
function sourceMapObject(
|
|
24
22
|
modules: $ReadOnlyArray<Module<>>,
|
|
@@ -40,7 +38,4 @@ async function sourceMapObjectNonBlocking(
|
|
|
40
38
|
});
|
|
41
39
|
}
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
sourceMapObject,
|
|
45
|
-
sourceMapObjectNonBlocking,
|
|
46
|
-
};
|
|
41
|
+
export {sourceMapObject, sourceMapObjectNonBlocking};
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.sourceMapString = sourceMapString;
|
|
7
|
+
exports.sourceMapStringNonBlocking = sourceMapStringNonBlocking;
|
|
8
|
+
var _sourceMapGenerator = require("./sourceMapGenerator");
|
|
7
9
|
function sourceMapString(modules, options) {
|
|
8
|
-
return sourceMapGenerator(modules, options).toString(
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
return (0, _sourceMapGenerator.sourceMapGenerator)(modules, options).toString(
|
|
11
|
+
undefined,
|
|
12
|
+
{
|
|
13
|
+
excludeSource: options.excludeSource,
|
|
14
|
+
},
|
|
15
|
+
);
|
|
11
16
|
}
|
|
12
17
|
async function sourceMapStringNonBlocking(modules, options) {
|
|
13
|
-
const generator = await
|
|
18
|
+
const generator = await (0,
|
|
19
|
+
_sourceMapGenerator.sourceMapGeneratorNonBlocking)(modules, options);
|
|
14
20
|
return generator.toString(undefined, {
|
|
15
21
|
excludeSource: options.excludeSource,
|
|
16
22
|
});
|
|
17
23
|
}
|
|
18
|
-
module.exports = {
|
|
19
|
-
sourceMapString,
|
|
20
|
-
sourceMapStringNonBlocking,
|
|
21
|
-
};
|
|
@@ -9,15 +9,13 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import type {Module} from '../types.flow';
|
|
12
|
+
import type {Module} from '../types';
|
|
15
13
|
import type {SourceMapGeneratorOptions} from './sourceMapGenerator';
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
import {
|
|
18
16
|
sourceMapGenerator,
|
|
19
17
|
sourceMapGeneratorNonBlocking,
|
|
20
|
-
}
|
|
18
|
+
} from './sourceMapGenerator';
|
|
21
19
|
|
|
22
20
|
function sourceMapString(
|
|
23
21
|
modules: $ReadOnlyArray<Module<>>,
|
|
@@ -38,7 +36,4 @@ async function sourceMapStringNonBlocking(
|
|
|
38
36
|
});
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
sourceMapString,
|
|
43
|
-
sourceMapStringNonBlocking,
|
|
44
|
-
};
|
|
39
|
+
export {sourceMapString, sourceMapStringNonBlocking};
|
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _pathUtils = require("../lib/pathUtils");
|
|
8
|
+
var _getTransformCacheKey = _interopRequireDefault(
|
|
9
|
+
require("./getTransformCacheKey"),
|
|
10
|
+
);
|
|
11
|
+
var _WorkerFarm = _interopRequireDefault(require("./WorkerFarm"));
|
|
12
|
+
var _assert = _interopRequireDefault(require("assert"));
|
|
3
13
|
var _crypto = _interopRequireDefault(require("crypto"));
|
|
14
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
15
|
+
var _metroCache = require("metro-cache");
|
|
16
|
+
var _path = _interopRequireDefault(require("path"));
|
|
4
17
|
function _interopRequireDefault(e) {
|
|
5
18
|
return e && e.__esModule ? e : { default: e };
|
|
6
19
|
}
|
|
7
|
-
const getTransformCacheKey = require("./getTransformCacheKey");
|
|
8
|
-
const WorkerFarm = require("./WorkerFarm");
|
|
9
|
-
const assert = require("assert");
|
|
10
20
|
const debug = require("debug")("Metro:Transformer");
|
|
11
|
-
const fs = require("fs");
|
|
12
|
-
const { Cache, stableHash } = require("metro-cache");
|
|
13
|
-
const path = require("path");
|
|
14
21
|
class Transformer {
|
|
15
22
|
constructor(config, opts) {
|
|
16
23
|
this._config = config;
|
|
17
24
|
this._config.watchFolders.forEach(verifyRootExists);
|
|
18
|
-
this._cache = new Cache(config.cacheStores);
|
|
25
|
+
this._cache = new _metroCache.Cache(config.cacheStores);
|
|
19
26
|
this._getSha1 = opts.getOrComputeSha1;
|
|
20
27
|
const {
|
|
21
28
|
getTransformOptions: _getTransformOptions,
|
|
@@ -27,15 +34,15 @@ class Transformer {
|
|
|
27
34
|
transformerPath: this._config.transformerPath,
|
|
28
35
|
transformerConfig,
|
|
29
36
|
};
|
|
30
|
-
this._workerFarm = new
|
|
37
|
+
this._workerFarm = new _WorkerFarm.default(config, transformerOptions);
|
|
31
38
|
const globalCacheKey = this._cache.isDisabled
|
|
32
39
|
? ""
|
|
33
|
-
:
|
|
40
|
+
: (0, _getTransformCacheKey.default)({
|
|
34
41
|
cacheVersion: this._config.cacheVersion,
|
|
35
42
|
projectRoot: this._config.projectRoot,
|
|
36
43
|
transformerConfig: transformerOptions,
|
|
37
44
|
});
|
|
38
|
-
const baseHashBuffer = stableHash([globalCacheKey]);
|
|
45
|
+
const baseHashBuffer = (0, _metroCache.stableHash)([globalCacheKey]);
|
|
39
46
|
this._baseHash = baseHashBuffer.toString("binary");
|
|
40
47
|
debug("Base hash: %s", baseHashBuffer.toString("hex"));
|
|
41
48
|
}
|
|
@@ -45,14 +52,12 @@ class Transformer {
|
|
|
45
52
|
customTransformOptions,
|
|
46
53
|
dev,
|
|
47
54
|
experimentalImportSupport,
|
|
48
|
-
hot,
|
|
49
55
|
inlinePlatform,
|
|
50
56
|
inlineRequires,
|
|
51
57
|
minify,
|
|
52
58
|
nonInlinedRequires,
|
|
53
59
|
platform,
|
|
54
60
|
type,
|
|
55
|
-
unstable_disableES6Transforms,
|
|
56
61
|
unstable_transformProfile,
|
|
57
62
|
unstable_memoizeInlineRequires,
|
|
58
63
|
unstable_nonMemoizedInlineRequires,
|
|
@@ -61,25 +66,26 @@ class Transformer {
|
|
|
61
66
|
for (const key in extra) {
|
|
62
67
|
if (hasOwnProperty.call(extra, key)) {
|
|
63
68
|
throw new Error(
|
|
64
|
-
"Extra keys detected: " + Object.keys(extra).join(", ")
|
|
69
|
+
"Extra keys detected: " + Object.keys(extra).join(", "),
|
|
65
70
|
);
|
|
66
71
|
}
|
|
67
72
|
}
|
|
68
|
-
const localPath =
|
|
69
|
-
|
|
73
|
+
const localPath = _path.default.relative(
|
|
74
|
+
this._config.projectRoot,
|
|
75
|
+
filePath,
|
|
76
|
+
);
|
|
77
|
+
const partialKey = (0, _metroCache.stableHash)([
|
|
70
78
|
this._baseHash,
|
|
71
|
-
|
|
79
|
+
(0, _pathUtils.normalizePathSeparatorsToPosix)(localPath),
|
|
72
80
|
customTransformOptions,
|
|
73
81
|
dev,
|
|
74
82
|
experimentalImportSupport,
|
|
75
|
-
hot,
|
|
76
83
|
inlinePlatform,
|
|
77
84
|
inlineRequires,
|
|
78
85
|
minify,
|
|
79
86
|
nonInlinedRequires,
|
|
80
87
|
platform,
|
|
81
88
|
type,
|
|
82
|
-
unstable_disableES6Transforms,
|
|
83
89
|
unstable_memoizeInlineRequires,
|
|
84
90
|
unstable_nonMemoizedInlineRequires,
|
|
85
91
|
unstable_transformProfile,
|
|
@@ -118,7 +124,7 @@ class Transformer {
|
|
|
118
124
|
: await this._workerFarm.transform(
|
|
119
125
|
localPath,
|
|
120
126
|
transformerOptions,
|
|
121
|
-
content
|
|
127
|
+
content,
|
|
122
128
|
);
|
|
123
129
|
if (sha1 !== data.sha1) {
|
|
124
130
|
fullKey = Buffer.concat([partialKey, Buffer.from(data.sha1, "hex")]);
|
|
@@ -136,7 +142,7 @@ class Transformer {
|
|
|
136
142
|
if (fileBuffer) {
|
|
137
143
|
return fileBuffer;
|
|
138
144
|
}
|
|
139
|
-
return
|
|
145
|
+
return _fs.default.readFileSync(filePath);
|
|
140
146
|
},
|
|
141
147
|
};
|
|
142
148
|
}
|
|
@@ -144,7 +150,10 @@ class Transformer {
|
|
|
144
150
|
await this._workerFarm.kill();
|
|
145
151
|
}
|
|
146
152
|
}
|
|
153
|
+
exports.default = Transformer;
|
|
147
154
|
function verifyRootExists(root) {
|
|
148
|
-
|
|
155
|
+
(0, _assert.default)(
|
|
156
|
+
_fs.default.statSync(root).isDirectory(),
|
|
157
|
+
"Root has to be a valid directory",
|
|
158
|
+
);
|
|
149
159
|
}
|
|
150
|
-
module.exports = Transformer;
|