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,11 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
function _interopRequireDefault(e) {
|
|
10
|
+
return e && e.__esModule ? e : { default: e };
|
|
11
|
+
}
|
|
5
12
|
class Package {
|
|
6
13
|
constructor({ file }) {
|
|
7
|
-
this.path =
|
|
8
|
-
this._root =
|
|
14
|
+
this.path = _path.default.resolve(file);
|
|
15
|
+
this._root = _path.default.dirname(this.path);
|
|
9
16
|
this._content = null;
|
|
10
17
|
}
|
|
11
18
|
invalidate() {
|
|
@@ -13,9 +20,9 @@ class Package {
|
|
|
13
20
|
}
|
|
14
21
|
read() {
|
|
15
22
|
if (this._content == null) {
|
|
16
|
-
this._content = JSON.parse(
|
|
23
|
+
this._content = JSON.parse(_fs.default.readFileSync(this.path, "utf8"));
|
|
17
24
|
}
|
|
18
25
|
return this._content;
|
|
19
26
|
}
|
|
20
27
|
}
|
|
21
|
-
|
|
28
|
+
exports.default = Package;
|
|
@@ -9,14 +9,12 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
import type {PackageJson} from 'metro-resolver/private/types';
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
import fs from 'fs';
|
|
15
|
+
import path from 'path';
|
|
18
16
|
|
|
19
|
-
class Package {
|
|
17
|
+
export default class Package {
|
|
20
18
|
path: string;
|
|
21
19
|
|
|
22
20
|
_root: string;
|
|
@@ -39,5 +37,3 @@ class Package {
|
|
|
39
37
|
return this._content;
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
|
-
|
|
43
|
-
module.exports = Package;
|
|
@@ -1,32 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.PackageCache = void 0;
|
|
7
|
+
var _Package = _interopRequireDefault(require("./Package"));
|
|
8
|
+
function _interopRequireDefault(e) {
|
|
9
|
+
return e && e.__esModule ? e : { default: e };
|
|
10
|
+
}
|
|
11
|
+
class PackageCache {
|
|
6
12
|
constructor(options) {
|
|
7
13
|
this._getClosestPackage = options.getClosestPackage;
|
|
8
|
-
this._moduleCache = Object.create(null);
|
|
9
14
|
this._packageCache = Object.create(null);
|
|
10
15
|
this._packagePathAndSubpathByModulePath = Object.create(null);
|
|
11
16
|
this._modulePathsByPackagePath = Object.create(null);
|
|
12
17
|
}
|
|
13
|
-
getModule(filePath) {
|
|
14
|
-
if (!this._moduleCache[filePath]) {
|
|
15
|
-
this._moduleCache[filePath] = new Module(filePath, this);
|
|
16
|
-
}
|
|
17
|
-
return this._moduleCache[filePath];
|
|
18
|
-
}
|
|
19
18
|
getPackage(filePath) {
|
|
20
19
|
if (!this._packageCache[filePath]) {
|
|
21
|
-
this._packageCache[filePath] = new
|
|
20
|
+
this._packageCache[filePath] = new _Package.default({
|
|
22
21
|
file: filePath,
|
|
23
22
|
});
|
|
24
23
|
}
|
|
25
24
|
return this._packageCache[filePath];
|
|
26
25
|
}
|
|
27
|
-
getPackageForModule(module) {
|
|
28
|
-
return this.getPackageOf(module.path);
|
|
29
|
-
}
|
|
30
26
|
getPackageOf(absoluteModulePath) {
|
|
31
27
|
let packagePathAndSubpath =
|
|
32
28
|
this._packagePathAndSubpathByModulePath[absoluteModulePath];
|
|
@@ -56,10 +52,6 @@ class ModuleCache {
|
|
|
56
52
|
};
|
|
57
53
|
}
|
|
58
54
|
invalidate(filePath) {
|
|
59
|
-
if (this._moduleCache[filePath]) {
|
|
60
|
-
this._moduleCache[filePath].invalidate();
|
|
61
|
-
delete this._moduleCache[filePath];
|
|
62
|
-
}
|
|
63
55
|
if (this._packageCache[filePath]) {
|
|
64
56
|
this._packageCache[filePath].invalidate();
|
|
65
57
|
delete this._packageCache[filePath];
|
|
@@ -87,4 +79,4 @@ class ModuleCache {
|
|
|
87
79
|
}
|
|
88
80
|
}
|
|
89
81
|
}
|
|
90
|
-
|
|
82
|
+
exports.PackageCache = PackageCache;
|
|
@@ -9,23 +9,15 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const Module = require('./Module');
|
|
15
|
-
const Package = require('./Package');
|
|
12
|
+
import Package from './Package';
|
|
16
13
|
|
|
17
14
|
type GetClosestPackageFn = (absoluteFilePath: string) => ?{
|
|
18
15
|
packageJsonPath: string,
|
|
19
16
|
packageRelativePath: string,
|
|
20
17
|
};
|
|
21
18
|
|
|
22
|
-
class
|
|
19
|
+
export class PackageCache {
|
|
23
20
|
_getClosestPackage: GetClosestPackageFn;
|
|
24
|
-
_moduleCache: {
|
|
25
|
-
[filePath: string]: Module,
|
|
26
|
-
__proto__: null,
|
|
27
|
-
...
|
|
28
|
-
};
|
|
29
21
|
_packageCache: {
|
|
30
22
|
[filePath: string]: Package,
|
|
31
23
|
__proto__: null,
|
|
@@ -49,19 +41,11 @@ class ModuleCache {
|
|
|
49
41
|
|
|
50
42
|
constructor(options: {getClosestPackage: GetClosestPackageFn, ...}) {
|
|
51
43
|
this._getClosestPackage = options.getClosestPackage;
|
|
52
|
-
this._moduleCache = Object.create(null);
|
|
53
44
|
this._packageCache = Object.create(null);
|
|
54
45
|
this._packagePathAndSubpathByModulePath = Object.create(null);
|
|
55
46
|
this._modulePathsByPackagePath = Object.create(null);
|
|
56
47
|
}
|
|
57
48
|
|
|
58
|
-
getModule(filePath: string): Module {
|
|
59
|
-
if (!this._moduleCache[filePath]) {
|
|
60
|
-
this._moduleCache[filePath] = new Module(filePath, this);
|
|
61
|
-
}
|
|
62
|
-
return this._moduleCache[filePath];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
49
|
getPackage(filePath: string): Package {
|
|
66
50
|
if (!this._packageCache[filePath]) {
|
|
67
51
|
this._packageCache[filePath] = new Package({
|
|
@@ -71,12 +55,6 @@ class ModuleCache {
|
|
|
71
55
|
return this._packageCache[filePath];
|
|
72
56
|
}
|
|
73
57
|
|
|
74
|
-
getPackageForModule(
|
|
75
|
-
module: Module,
|
|
76
|
-
): ?{pkg: Package, packageRelativePath: string} {
|
|
77
|
-
return this.getPackageOf(module.path);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
58
|
getPackageOf(
|
|
81
59
|
absoluteModulePath: string,
|
|
82
60
|
): ?{pkg: Package, packageRelativePath: string} {
|
|
@@ -113,10 +91,6 @@ class ModuleCache {
|
|
|
113
91
|
}
|
|
114
92
|
|
|
115
93
|
invalidate(filePath: string) {
|
|
116
|
-
if (this._moduleCache[filePath]) {
|
|
117
|
-
this._moduleCache[filePath].invalidate();
|
|
118
|
-
delete this._moduleCache[filePath];
|
|
119
|
-
}
|
|
120
94
|
if (this._packageCache[filePath]) {
|
|
121
95
|
this._packageCache[filePath].invalidate();
|
|
122
96
|
delete this._packageCache[filePath];
|
|
@@ -149,5 +123,3 @@ class ModuleCache {
|
|
|
149
123
|
}
|
|
150
124
|
}
|
|
151
125
|
}
|
|
152
|
-
|
|
153
|
-
module.exports = ModuleCache;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.parse = parse;
|
|
7
|
+
exports.tryParse = tryParse;
|
|
8
|
+
var _parsePlatformFilePath = _interopRequireDefault(
|
|
9
|
+
require("./parsePlatformFilePath"),
|
|
10
|
+
);
|
|
11
|
+
var _path = _interopRequireDefault(require("path"));
|
|
12
|
+
function _interopRequireDefault(e) {
|
|
13
|
+
return e && e.__esModule ? e : { default: e };
|
|
14
|
+
}
|
|
5
15
|
const ASSET_BASE_NAME_RE = /(.+?)(@([\d.]+)x)?$/;
|
|
6
16
|
function parseBaseName(baseName) {
|
|
7
17
|
const match = baseName.match(ASSET_BASE_NAME_RE);
|
|
@@ -24,14 +34,14 @@ function parseBaseName(baseName) {
|
|
|
24
34
|
};
|
|
25
35
|
}
|
|
26
36
|
function tryParse(filePath, platforms) {
|
|
27
|
-
const result =
|
|
37
|
+
const result = (0, _parsePlatformFilePath.default)(filePath, platforms);
|
|
28
38
|
const { dirPath, baseName, platform, extension } = result;
|
|
29
39
|
if (extension == null) {
|
|
30
40
|
return null;
|
|
31
41
|
}
|
|
32
42
|
const { rootName, resolution } = parseBaseName(baseName);
|
|
33
43
|
return {
|
|
34
|
-
assetName:
|
|
44
|
+
assetName: _path.default.join(dirPath, `${rootName}.${extension}`),
|
|
35
45
|
name: rootName,
|
|
36
46
|
platform,
|
|
37
47
|
resolution,
|
|
@@ -45,7 +55,3 @@ function parse(filePath, platforms) {
|
|
|
45
55
|
}
|
|
46
56
|
return result;
|
|
47
57
|
}
|
|
48
|
-
module.exports = {
|
|
49
|
-
parse,
|
|
50
|
-
tryParse,
|
|
51
|
-
};
|
|
@@ -9,10 +9,8 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const parsePlatformFilePath = require('./parsePlatformFilePath');
|
|
15
|
-
const path = require('path');
|
|
12
|
+
import parsePlatformFilePath from './parsePlatformFilePath';
|
|
13
|
+
import path from 'path';
|
|
16
14
|
|
|
17
15
|
export type AssetPath = {
|
|
18
16
|
assetName: string,
|
|
@@ -47,7 +45,7 @@ function parseBaseName(baseName: string): {
|
|
|
47
45
|
* Return `null` if the `filePath` doesn't have a valid extension, required
|
|
48
46
|
* to describe the type of an asset.
|
|
49
47
|
*/
|
|
50
|
-
function tryParse(
|
|
48
|
+
export function tryParse(
|
|
51
49
|
filePath: string,
|
|
52
50
|
platforms: $ReadOnlySet<string>,
|
|
53
51
|
): ?AssetPath {
|
|
@@ -66,12 +64,13 @@ function tryParse(
|
|
|
66
64
|
};
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
function parse(
|
|
67
|
+
export function parse(
|
|
68
|
+
filePath: string,
|
|
69
|
+
platforms: $ReadOnlySet<string>,
|
|
70
|
+
): AssetPath {
|
|
70
71
|
const result = tryParse(filePath, platforms);
|
|
71
72
|
if (result == null) {
|
|
72
73
|
throw new Error(`invalid asset file path: ${filePath}`);
|
|
73
74
|
}
|
|
74
75
|
return result;
|
|
75
76
|
}
|
|
76
|
-
|
|
77
|
-
module.exports = {parse, tryParse};
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = parsePlatformFilePath;
|
|
7
|
+
var _path = _interopRequireDefault(require("path"));
|
|
8
|
+
function _interopRequireDefault(e) {
|
|
9
|
+
return e && e.__esModule ? e : { default: e };
|
|
10
|
+
}
|
|
4
11
|
const PATH_RE = /^(.+?)(\.([^.]+))?\.([^.]+)$/;
|
|
5
12
|
function parsePlatformFilePath(filePath, platforms) {
|
|
6
|
-
const dirPath =
|
|
7
|
-
const fileName =
|
|
13
|
+
const dirPath = _path.default.dirname(filePath);
|
|
14
|
+
const fileName = _path.default.basename(filePath);
|
|
8
15
|
const match = fileName.match(PATH_RE);
|
|
9
16
|
if (!match) {
|
|
10
17
|
return {
|
|
@@ -32,4 +39,3 @@ function parsePlatformFilePath(filePath, platforms) {
|
|
|
32
39
|
extension,
|
|
33
40
|
};
|
|
34
41
|
}
|
|
35
|
-
module.exports = parsePlatformFilePath;
|
|
@@ -9,9 +9,7 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const path = require('path');
|
|
12
|
+
import path from 'path';
|
|
15
13
|
|
|
16
14
|
type PlatformFilePathParts = {
|
|
17
15
|
dirPath: string,
|
|
@@ -26,7 +24,7 @@ const PATH_RE = /^(.+?)(\.([^.]+))?\.([^.]+)$/;
|
|
|
26
24
|
* Extract the components of a file path that can have a platform specifier: Ex.
|
|
27
25
|
* `index.ios.js` is specific to the `ios` platform and has the extension `js`.
|
|
28
26
|
*/
|
|
29
|
-
function parsePlatformFilePath(
|
|
27
|
+
export default function parsePlatformFilePath(
|
|
30
28
|
filePath: string,
|
|
31
29
|
platforms: $ReadOnlySet<string>,
|
|
32
30
|
): PlatformFilePathParts {
|
|
@@ -44,5 +42,3 @@ function parsePlatformFilePath(
|
|
|
44
42
|
const baseName = `${match[1]}.${platform}`;
|
|
45
43
|
return {dirPath, baseName, platform: null, extension};
|
|
46
44
|
}
|
|
47
|
-
|
|
48
|
-
module.exports = parsePlatformFilePath;
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = saveAsAssets;
|
|
7
|
+
var _relativizeSourceMap = _interopRequireDefault(
|
|
8
|
+
require("../../../lib/relativizeSourceMap"),
|
|
9
|
+
);
|
|
10
|
+
var _writeFile = _interopRequireDefault(require("../writeFile"));
|
|
11
|
+
var _buildSourcemapWithMetadata = _interopRequireDefault(
|
|
12
|
+
require("./buildSourcemapWithMetadata"),
|
|
13
|
+
);
|
|
14
|
+
var _magicNumber = _interopRequireDefault(require("./magic-number"));
|
|
15
|
+
var _util = require("./util");
|
|
16
|
+
var _writeSourcemap = _interopRequireDefault(require("./write-sourcemap"));
|
|
17
|
+
var _fs = require("fs");
|
|
18
|
+
var _path = _interopRequireDefault(require("path"));
|
|
19
|
+
function _interopRequireDefault(e) {
|
|
20
|
+
return e && e.__esModule ? e : { default: e };
|
|
21
|
+
}
|
|
11
22
|
const MAGIC_RAM_BUNDLE_FILENAME = "UNBUNDLE";
|
|
12
23
|
const MODULES_DIR = "js-modules";
|
|
13
24
|
function saveAsAssets(bundle, options, log) {
|
|
@@ -20,31 +31,34 @@ function saveAsAssets(bundle, options, log) {
|
|
|
20
31
|
log("start");
|
|
21
32
|
const { startupModules, lazyModules } = bundle;
|
|
22
33
|
log("finish");
|
|
23
|
-
const startupCode = joinModules(startupModules);
|
|
34
|
+
const startupCode = (0, _util.joinModules)(startupModules);
|
|
24
35
|
log("Writing bundle output to:", bundleOutput);
|
|
25
|
-
const modulesDir =
|
|
36
|
+
const modulesDir = _path.default.join(
|
|
37
|
+
_path.default.dirname(bundleOutput),
|
|
38
|
+
MODULES_DIR,
|
|
39
|
+
);
|
|
26
40
|
const writeUnbundle = createDir(modulesDir).then(() =>
|
|
27
41
|
Promise.all([
|
|
28
42
|
writeModules(lazyModules, modulesDir, encoding),
|
|
29
|
-
|
|
43
|
+
(0, _writeFile.default)(bundleOutput, startupCode, encoding),
|
|
30
44
|
writeMagicFlagFile(modulesDir),
|
|
31
|
-
])
|
|
45
|
+
]),
|
|
32
46
|
);
|
|
33
47
|
writeUnbundle.then(() => log("Done writing unbundle output"));
|
|
34
48
|
if (sourcemapOutput) {
|
|
35
|
-
const sourceMap =
|
|
49
|
+
const sourceMap = (0, _buildSourcemapWithMetadata.default)({
|
|
36
50
|
fixWrapperOffset: true,
|
|
37
51
|
lazyModules: lazyModules.concat(),
|
|
38
52
|
moduleGroups: null,
|
|
39
53
|
startupModules: startupModules.concat(),
|
|
40
54
|
});
|
|
41
55
|
if (sourcemapSourcesRoot != null) {
|
|
42
|
-
|
|
56
|
+
(0, _relativizeSourceMap.default)(sourceMap, sourcemapSourcesRoot);
|
|
43
57
|
}
|
|
44
|
-
const wroteSourceMap =
|
|
58
|
+
const wroteSourceMap = (0, _writeSourcemap.default)(
|
|
45
59
|
sourcemapOutput,
|
|
46
60
|
JSON.stringify(sourceMap),
|
|
47
|
-
log
|
|
61
|
+
log,
|
|
48
62
|
);
|
|
49
63
|
return Promise.all([writeUnbundle, wroteSourceMap]);
|
|
50
64
|
} else {
|
|
@@ -52,23 +66,29 @@ function saveAsAssets(bundle, options, log) {
|
|
|
52
66
|
}
|
|
53
67
|
}
|
|
54
68
|
function createDir(dirName) {
|
|
55
|
-
return
|
|
69
|
+
return _fs.promises.mkdir(dirName, {
|
|
56
70
|
recursive: true,
|
|
57
71
|
});
|
|
58
72
|
}
|
|
59
73
|
function writeModuleFile(module, modulesDir, encoding) {
|
|
60
74
|
const { code, id } = module;
|
|
61
|
-
return
|
|
75
|
+
return (0, _writeFile.default)(
|
|
76
|
+
_path.default.join(modulesDir, id + ".js"),
|
|
77
|
+
code,
|
|
78
|
+
encoding,
|
|
79
|
+
);
|
|
62
80
|
}
|
|
63
81
|
function writeModules(modules, modulesDir, encoding) {
|
|
64
82
|
const writeFiles = modules.map((module) =>
|
|
65
|
-
writeModuleFile(module, modulesDir, encoding)
|
|
83
|
+
writeModuleFile(module, modulesDir, encoding),
|
|
66
84
|
);
|
|
67
85
|
return Promise.all(writeFiles);
|
|
68
86
|
}
|
|
69
87
|
function writeMagicFlagFile(outputDir) {
|
|
70
88
|
const buffer = Buffer.alloc(4);
|
|
71
|
-
buffer.writeUInt32LE(
|
|
72
|
-
return
|
|
89
|
+
buffer.writeUInt32LE(_magicNumber.default, 0);
|
|
90
|
+
return (0, _writeFile.default)(
|
|
91
|
+
_path.default.join(outputDir, MAGIC_RAM_BUNDLE_FILENAME),
|
|
92
|
+
buffer,
|
|
93
|
+
);
|
|
73
94
|
}
|
|
74
|
-
module.exports = saveAsAssets;
|
|
@@ -9,20 +9,19 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
import type {RamBundleInfo} from '../../../DeltaBundler/Serializers/getRamBundleInfo';
|
|
15
|
-
import type {ModuleTransportLike} from '../../../shared/types
|
|
16
|
-
import type {OutputOptions} from '../../types
|
|
13
|
+
import type {ModuleTransportLike} from '../../../shared/types';
|
|
14
|
+
import type {OutputOptions} from '../../types';
|
|
15
|
+
|
|
16
|
+
import relativizeSourceMapInline from '../../../lib/relativizeSourceMap';
|
|
17
|
+
import writeFile from '../writeFile';
|
|
18
|
+
import buildSourcemapWithMetadata from './buildSourcemapWithMetadata';
|
|
19
|
+
import MAGIC_RAM_BUNDLE_NUMBER from './magic-number';
|
|
20
|
+
import {joinModules} from './util';
|
|
21
|
+
import writeSourceMap from './write-sourcemap';
|
|
22
|
+
import {promises as fsPromises} from 'fs';
|
|
23
|
+
import path from 'path';
|
|
17
24
|
|
|
18
|
-
const relativizeSourceMapInline = require('../../../lib/relativizeSourceMap');
|
|
19
|
-
const writeFile = require('../writeFile');
|
|
20
|
-
const buildSourcemapWithMetadata = require('./buildSourcemapWithMetadata');
|
|
21
|
-
const MAGIC_RAM_BUNDLE_NUMBER = require('./magic-number');
|
|
22
|
-
const {joinModules} = require('./util');
|
|
23
|
-
const writeSourceMap = require('./write-sourcemap');
|
|
24
|
-
const fsPromises = require('fs').promises;
|
|
25
|
-
const path = require('path');
|
|
26
25
|
// must not start with a dot, as that won't go into the apk
|
|
27
26
|
const MAGIC_RAM_BUNDLE_FILENAME = 'UNBUNDLE';
|
|
28
27
|
const MODULES_DIR = 'js-modules';
|
|
@@ -34,7 +33,7 @@ const MODULES_DIR = 'js-modules';
|
|
|
34
33
|
* All other modules go into a 'js-modules' folder that in the same parent
|
|
35
34
|
* directory as the startup file.
|
|
36
35
|
*/
|
|
37
|
-
function saveAsAssets(
|
|
36
|
+
export default function saveAsAssets(
|
|
38
37
|
bundle: RamBundleInfo,
|
|
39
38
|
options: OutputOptions,
|
|
40
39
|
log: (...args: Array<string>) => void,
|
|
@@ -123,5 +122,3 @@ function writeMagicFlagFile(outputDir: string): Promise<mixed> {
|
|
|
123
122
|
buffer.writeUInt32LE(MAGIC_RAM_BUNDLE_NUMBER, 0);
|
|
124
123
|
return writeFile(path.join(outputDir, MAGIC_RAM_BUNDLE_FILENAME), buffer);
|
|
125
124
|
}
|
|
126
|
-
|
|
127
|
-
module.exports = saveAsAssets;
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.buildTableAndContents = buildTableAndContents;
|
|
7
|
+
exports.createModuleGroups = createModuleGroups;
|
|
8
|
+
exports.save = save;
|
|
9
|
+
var _relativizeSourceMap = _interopRequireDefault(
|
|
10
|
+
require("../../../lib/relativizeSourceMap"),
|
|
11
|
+
);
|
|
12
|
+
var _buildSourcemapWithMetadata = _interopRequireDefault(
|
|
13
|
+
require("./buildSourcemapWithMetadata"),
|
|
14
|
+
);
|
|
15
|
+
var _magicNumber = _interopRequireDefault(require("./magic-number"));
|
|
16
|
+
var _util = require("./util");
|
|
17
|
+
var _writeSourcemap = _interopRequireDefault(require("./write-sourcemap"));
|
|
18
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
19
|
+
function _interopRequireDefault(e) {
|
|
20
|
+
return e && e.__esModule ? e : { default: e };
|
|
21
|
+
}
|
|
9
22
|
const SIZEOF_UINT32 = 4;
|
|
10
|
-
function
|
|
23
|
+
function save(bundle, options, log) {
|
|
11
24
|
const {
|
|
12
25
|
bundleOutput,
|
|
13
26
|
bundleEncoding: encoding,
|
|
@@ -18,26 +31,26 @@ function saveAsIndexedFile(bundle, options, log) {
|
|
|
18
31
|
const { startupModules, lazyModules, groups } = bundle;
|
|
19
32
|
log("finish");
|
|
20
33
|
const moduleGroups = createModuleGroups(groups, lazyModules);
|
|
21
|
-
const startupCode = joinModules(startupModules);
|
|
34
|
+
const startupCode = (0, _util.joinModules)(startupModules);
|
|
22
35
|
log("Writing unbundle output to:", bundleOutput);
|
|
23
36
|
const writeUnbundle = writeBuffers(
|
|
24
|
-
|
|
25
|
-
buildTableAndContents(startupCode, lazyModules, moduleGroups, encoding)
|
|
37
|
+
_fs.default.createWriteStream(bundleOutput),
|
|
38
|
+
buildTableAndContents(startupCode, lazyModules, moduleGroups, encoding),
|
|
26
39
|
).then(() => log("Done writing unbundle output"));
|
|
27
40
|
if (sourcemapOutput) {
|
|
28
|
-
const sourceMap =
|
|
41
|
+
const sourceMap = (0, _buildSourcemapWithMetadata.default)({
|
|
29
42
|
startupModules: startupModules.concat(),
|
|
30
43
|
lazyModules: lazyModules.concat(),
|
|
31
44
|
moduleGroups,
|
|
32
45
|
fixWrapperOffset: true,
|
|
33
46
|
});
|
|
34
47
|
if (sourcemapSourcesRoot != null) {
|
|
35
|
-
|
|
48
|
+
(0, _relativizeSourceMap.default)(sourceMap, sourcemapSourcesRoot);
|
|
36
49
|
}
|
|
37
|
-
const wroteSourceMap =
|
|
50
|
+
const wroteSourceMap = (0, _writeSourcemap.default)(
|
|
38
51
|
sourcemapOutput,
|
|
39
52
|
JSON.stringify(sourceMap),
|
|
40
|
-
log
|
|
53
|
+
log,
|
|
41
54
|
);
|
|
42
55
|
return Promise.all([writeUnbundle, wroteSourceMap]);
|
|
43
56
|
} else {
|
|
@@ -45,7 +58,7 @@ function saveAsIndexedFile(bundle, options, log) {
|
|
|
45
58
|
}
|
|
46
59
|
}
|
|
47
60
|
const fileHeader = Buffer.alloc(4);
|
|
48
|
-
fileHeader.writeUInt32LE(
|
|
61
|
+
fileHeader.writeUInt32LE(_magicNumber.default, 0);
|
|
49
62
|
const nullByteBuffer = Buffer.alloc(1).fill(0);
|
|
50
63
|
function writeBuffers(stream, buffers) {
|
|
51
64
|
buffers.forEach((buffer) => stream.write(buffer));
|
|
@@ -98,7 +111,7 @@ function groupCode(rootCode, moduleGroup, modulesById) {
|
|
|
98
111
|
modulesById.get(id) || {
|
|
99
112
|
code: "",
|
|
100
113
|
}
|
|
101
|
-
).code
|
|
114
|
+
).code,
|
|
102
115
|
);
|
|
103
116
|
}
|
|
104
117
|
return code.join("\n");
|
|
@@ -110,8 +123,8 @@ function buildModuleBuffers(modules, moduleGroups, encoding) {
|
|
|
110
123
|
moduleToBuffer(
|
|
111
124
|
id,
|
|
112
125
|
groupCode(code, moduleGroups.groups.get(id), moduleGroups.modulesById),
|
|
113
|
-
encoding
|
|
114
|
-
)
|
|
126
|
+
encoding,
|
|
127
|
+
),
|
|
115
128
|
);
|
|
116
129
|
}
|
|
117
130
|
function buildTableAndContents(startupCode, modules, moduleGroups, encoding) {
|
|
@@ -120,10 +133,10 @@ function buildTableAndContents(startupCode, modules, moduleGroups, encoding) {
|
|
|
120
133
|
const table = buildModuleTable(
|
|
121
134
|
startupCodeBuffer,
|
|
122
135
|
moduleBuffers,
|
|
123
|
-
moduleGroups
|
|
136
|
+
moduleGroups,
|
|
124
137
|
);
|
|
125
138
|
return [fileHeader, table, startupCodeBuffer].concat(
|
|
126
|
-
moduleBuffers.map(({ buffer }) => buffer)
|
|
139
|
+
moduleBuffers.map(({ buffer }) => buffer),
|
|
127
140
|
);
|
|
128
141
|
}
|
|
129
142
|
function createModuleGroups(groups, modules) {
|
|
@@ -138,6 +151,3 @@ function* concat(iterators) {
|
|
|
138
151
|
yield* it;
|
|
139
152
|
}
|
|
140
153
|
}
|
|
141
|
-
exports.save = saveAsIndexedFile;
|
|
142
|
-
exports.buildTableAndContents = buildTableAndContents;
|
|
143
|
-
exports.createModuleGroups = createModuleGroups;
|
|
@@ -9,22 +9,20 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
import type {RamBundleInfo} from '../../../DeltaBundler/Serializers/getRamBundleInfo';
|
|
15
13
|
import type {
|
|
16
14
|
ModuleGroups,
|
|
17
15
|
ModuleTransportLike,
|
|
18
16
|
OutputOptions,
|
|
19
|
-
} from '../../types
|
|
17
|
+
} from '../../types';
|
|
20
18
|
import type {WriteStream} from 'fs';
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
import relativizeSourceMapInline from '../../../lib/relativizeSourceMap';
|
|
21
|
+
import buildSourcemapWithMetadata from './buildSourcemapWithMetadata';
|
|
22
|
+
import MAGIC_UNBUNDLE_FILE_HEADER from './magic-number';
|
|
23
|
+
import {joinModules} from './util';
|
|
24
|
+
import writeSourceMap from './write-sourcemap';
|
|
25
|
+
import fs from 'fs';
|
|
28
26
|
|
|
29
27
|
const SIZEOF_UINT32 = 4;
|
|
30
28
|
|
|
@@ -35,7 +33,7 @@ const SIZEOF_UINT32 = 4;
|
|
|
35
33
|
* The module id for the startup code (prelude, polyfills etc.) is the
|
|
36
34
|
* empty string.
|
|
37
35
|
*/
|
|
38
|
-
function
|
|
36
|
+
export function save(
|
|
39
37
|
bundle: RamBundleInfo,
|
|
40
38
|
options: OutputOptions,
|
|
41
39
|
log: (...args: Array<string>) => void,
|
|
@@ -217,7 +215,7 @@ function buildModuleBuffers(
|
|
|
217
215
|
);
|
|
218
216
|
}
|
|
219
217
|
|
|
220
|
-
function buildTableAndContents(
|
|
218
|
+
export function buildTableAndContents(
|
|
221
219
|
startupCode: string,
|
|
222
220
|
modules: $ReadOnlyArray<ModuleTransportLike>,
|
|
223
221
|
moduleGroups: ModuleGroups,
|
|
@@ -242,7 +240,7 @@ function buildTableAndContents(
|
|
|
242
240
|
);
|
|
243
241
|
}
|
|
244
242
|
|
|
245
|
-
function createModuleGroups(
|
|
243
|
+
export function createModuleGroups(
|
|
246
244
|
groups: Map<number, Set<number>>,
|
|
247
245
|
modules: $ReadOnlyArray<ModuleTransportLike>,
|
|
248
246
|
): ModuleGroups {
|
|
@@ -260,7 +258,3 @@ function* concat(
|
|
|
260
258
|
yield* it;
|
|
261
259
|
}
|
|
262
260
|
}
|
|
263
|
-
|
|
264
|
-
exports.save = saveAsIndexedFile;
|
|
265
|
-
exports.buildTableAndContents = buildTableAndContents;
|
|
266
|
-
exports.createModuleGroups = createModuleGroups;
|