metro 0.83.0 → 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 +16 -16
- 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 +15 -15
- package/src/DeltaBundler/DeltaCalculator.js.flow +4 -7
- package/src/DeltaBundler/Graph.js +45 -40
- 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 +32 -27
- 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 +13 -17
- 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 → types.js} +1 -5
- 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 +22 -29
- 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 +18 -15
- 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/build-errors/cannot-resolve-import.js +1 -5
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js +1 -5
- package/src/integration_tests/basic_bundle/import-export/index.js +5 -13
- 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 +3 -7
- package/src/lib/contextModuleTemplates.js +9 -19
- package/src/lib/countLines.js +5 -1
- package/src/lib/countLines.js.flow +1 -3
- package/src/lib/createWebsocketServer.js +7 -7
- 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 +20 -20
- 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 +40 -16
- 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 +19 -25
- 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 +15 -13
- 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 +21 -18
- 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 -24
- package/src/node-haste/Module.js.flow +0 -41
- /package/src/shared/{types.flow.js → types.js} +0 -0
|
@@ -1,16 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _Bundler = _interopRequireDefault(require("./Bundler"));
|
|
8
|
+
var _DeltaBundler = _interopRequireDefault(require("./DeltaBundler"));
|
|
9
|
+
var _ResourceNotFoundError = _interopRequireDefault(
|
|
10
|
+
require("./IncrementalBundler/ResourceNotFoundError"),
|
|
11
|
+
);
|
|
12
|
+
var _getGraphId = _interopRequireDefault(require("./lib/getGraphId"));
|
|
13
|
+
var _getPrependedScripts = _interopRequireDefault(
|
|
14
|
+
require("./lib/getPrependedScripts"),
|
|
15
|
+
);
|
|
16
|
+
var transformHelpers = _interopRequireWildcard(
|
|
17
|
+
require("./lib/transformHelpers"),
|
|
18
|
+
);
|
|
19
|
+
var _crypto = _interopRequireDefault(require("crypto"));
|
|
20
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
21
|
+
var _path = _interopRequireDefault(require("path"));
|
|
22
|
+
function _getRequireWildcardCache(e) {
|
|
23
|
+
if ("function" != typeof WeakMap) return null;
|
|
24
|
+
var r = new WeakMap(),
|
|
25
|
+
t = new WeakMap();
|
|
26
|
+
return (_getRequireWildcardCache = function (e) {
|
|
27
|
+
return e ? t : r;
|
|
28
|
+
})(e);
|
|
29
|
+
}
|
|
30
|
+
function _interopRequireWildcard(e, r) {
|
|
31
|
+
if (!r && e && e.__esModule) return e;
|
|
32
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
33
|
+
return { default: e };
|
|
34
|
+
var t = _getRequireWildcardCache(r);
|
|
35
|
+
if (t && t.has(e)) return t.get(e);
|
|
36
|
+
var n = { __proto__: null },
|
|
37
|
+
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
38
|
+
for (var u in e)
|
|
39
|
+
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
40
|
+
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
41
|
+
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
42
|
+
}
|
|
43
|
+
return ((n.default = e), t && t.set(e, n), n);
|
|
44
|
+
}
|
|
45
|
+
function _interopRequireDefault(e) {
|
|
46
|
+
return e && e.__esModule ? e : { default: e };
|
|
47
|
+
}
|
|
12
48
|
function createRevisionId() {
|
|
13
|
-
return
|
|
49
|
+
return _crypto.default.randomBytes(8).toString("hex");
|
|
14
50
|
}
|
|
15
51
|
function revisionIdFromString(str) {
|
|
16
52
|
return str;
|
|
@@ -21,8 +57,8 @@ class IncrementalBundler {
|
|
|
21
57
|
static revisionIdFromString = revisionIdFromString;
|
|
22
58
|
constructor(config, options) {
|
|
23
59
|
this._config = config;
|
|
24
|
-
this._bundler = new
|
|
25
|
-
this._deltaBundler = new
|
|
60
|
+
this._bundler = new _Bundler.default(config, options);
|
|
61
|
+
this._deltaBundler = new _DeltaBundler.default(this._bundler.getWatcher());
|
|
26
62
|
}
|
|
27
63
|
async end() {
|
|
28
64
|
this._deltaBundler.end();
|
|
@@ -48,14 +84,14 @@ class IncrementalBundler {
|
|
|
48
84
|
onProgress: null,
|
|
49
85
|
shallow: false,
|
|
50
86
|
lazy: false,
|
|
51
|
-
}
|
|
87
|
+
},
|
|
52
88
|
) {
|
|
53
89
|
const absoluteEntryFiles = await this._getAbsoluteEntryFiles(entryFiles);
|
|
54
90
|
const graph = await this._deltaBundler.buildGraph(absoluteEntryFiles, {
|
|
55
91
|
resolve: await transformHelpers.getResolveDependencyFn(
|
|
56
92
|
this._bundler,
|
|
57
93
|
transformOptions.platform,
|
|
58
|
-
resolverOptions
|
|
94
|
+
resolverOptions,
|
|
59
95
|
),
|
|
60
96
|
transform: await transformHelpers.getTransformFn(
|
|
61
97
|
absoluteEntryFiles,
|
|
@@ -63,7 +99,7 @@ class IncrementalBundler {
|
|
|
63
99
|
this._deltaBundler,
|
|
64
100
|
this._config,
|
|
65
101
|
transformOptions,
|
|
66
|
-
resolverOptions
|
|
102
|
+
resolverOptions,
|
|
67
103
|
),
|
|
68
104
|
transformOptions,
|
|
69
105
|
onProgress: otherOptions.onProgress,
|
|
@@ -90,7 +126,7 @@ class IncrementalBundler {
|
|
|
90
126
|
onProgress: null,
|
|
91
127
|
shallow: false,
|
|
92
128
|
lazy: false,
|
|
93
|
-
}
|
|
129
|
+
},
|
|
94
130
|
) {
|
|
95
131
|
const absoluteEntryFiles = await this._getAbsoluteEntryFiles(entryFiles);
|
|
96
132
|
const dependencies = await this._deltaBundler.getDependencies(
|
|
@@ -99,7 +135,7 @@ class IncrementalBundler {
|
|
|
99
135
|
resolve: await transformHelpers.getResolveDependencyFn(
|
|
100
136
|
this._bundler,
|
|
101
137
|
transformOptions.platform,
|
|
102
|
-
resolverOptions
|
|
138
|
+
resolverOptions,
|
|
103
139
|
),
|
|
104
140
|
transform: await transformHelpers.getTransformFn(
|
|
105
141
|
absoluteEntryFiles,
|
|
@@ -107,7 +143,7 @@ class IncrementalBundler {
|
|
|
107
143
|
this._deltaBundler,
|
|
108
144
|
this._config,
|
|
109
145
|
transformOptions,
|
|
110
|
-
resolverOptions
|
|
146
|
+
resolverOptions,
|
|
111
147
|
),
|
|
112
148
|
transformOptions,
|
|
113
149
|
onProgress: otherOptions.onProgress,
|
|
@@ -117,7 +153,7 @@ class IncrementalBundler {
|
|
|
117
153
|
unstable_enablePackageExports:
|
|
118
154
|
this._config.resolver.unstable_enablePackageExports,
|
|
119
155
|
shallow: otherOptions.shallow,
|
|
120
|
-
}
|
|
156
|
+
},
|
|
121
157
|
);
|
|
122
158
|
return dependencies;
|
|
123
159
|
}
|
|
@@ -129,21 +165,21 @@ class IncrementalBundler {
|
|
|
129
165
|
onProgress: null,
|
|
130
166
|
shallow: false,
|
|
131
167
|
lazy: false,
|
|
132
|
-
}
|
|
168
|
+
},
|
|
133
169
|
) {
|
|
134
170
|
const graph = await this.buildGraphForEntries(
|
|
135
171
|
[entryFile],
|
|
136
172
|
transformOptions,
|
|
137
173
|
resolverOptions,
|
|
138
|
-
otherOptions
|
|
174
|
+
otherOptions,
|
|
139
175
|
);
|
|
140
176
|
const { type: _, ...transformOptionsWithoutType } = transformOptions;
|
|
141
|
-
const prepend = await
|
|
177
|
+
const prepend = await (0, _getPrependedScripts.default)(
|
|
142
178
|
this._config,
|
|
143
179
|
transformOptionsWithoutType,
|
|
144
180
|
resolverOptions,
|
|
145
181
|
this._bundler,
|
|
146
|
-
this._deltaBundler
|
|
182
|
+
this._deltaBundler,
|
|
147
183
|
);
|
|
148
184
|
return {
|
|
149
185
|
prepend,
|
|
@@ -158,9 +194,9 @@ class IncrementalBundler {
|
|
|
158
194
|
onProgress: null,
|
|
159
195
|
shallow: false,
|
|
160
196
|
lazy: false,
|
|
161
|
-
}
|
|
197
|
+
},
|
|
162
198
|
) {
|
|
163
|
-
const graphId =
|
|
199
|
+
const graphId = (0, _getGraphId.default)(entryFile, transformOptions, {
|
|
164
200
|
resolverOptions,
|
|
165
201
|
shallow: otherOptions.shallow,
|
|
166
202
|
lazy: otherOptions.lazy,
|
|
@@ -173,7 +209,7 @@ class IncrementalBundler {
|
|
|
173
209
|
entryFile,
|
|
174
210
|
transformOptions,
|
|
175
211
|
resolverOptions,
|
|
176
|
-
otherOptions
|
|
212
|
+
otherOptions,
|
|
177
213
|
);
|
|
178
214
|
return {
|
|
179
215
|
id: revisionId,
|
|
@@ -217,7 +253,7 @@ class IncrementalBundler {
|
|
|
217
253
|
this._revisionsById.delete(revision.id);
|
|
218
254
|
revision = {
|
|
219
255
|
...revision,
|
|
220
|
-
id:
|
|
256
|
+
id: _crypto.default.randomBytes(8).toString("hex"),
|
|
221
257
|
date: new Date(),
|
|
222
258
|
};
|
|
223
259
|
const revisionPromise = Promise.resolve(revision);
|
|
@@ -241,24 +277,24 @@ class IncrementalBundler {
|
|
|
241
277
|
}
|
|
242
278
|
async _getAbsoluteEntryFiles(entryFiles) {
|
|
243
279
|
const absoluteEntryFiles = entryFiles.map((entryFile) =>
|
|
244
|
-
|
|
280
|
+
_path.default.resolve(
|
|
245
281
|
this._config.server.unstable_serverRoot ?? this._config.projectRoot,
|
|
246
|
-
entryFile
|
|
247
|
-
)
|
|
282
|
+
entryFile,
|
|
283
|
+
),
|
|
248
284
|
);
|
|
249
285
|
await Promise.all(
|
|
250
286
|
absoluteEntryFiles.map(
|
|
251
287
|
(entryFile) =>
|
|
252
288
|
new Promise((resolve, reject) => {
|
|
253
|
-
|
|
289
|
+
_fs.default.realpath(entryFile, (err) => {
|
|
254
290
|
if (err) {
|
|
255
|
-
reject(new
|
|
291
|
+
reject(new _ResourceNotFoundError.default(entryFile));
|
|
256
292
|
} else {
|
|
257
293
|
resolve();
|
|
258
294
|
}
|
|
259
295
|
});
|
|
260
|
-
})
|
|
261
|
-
)
|
|
296
|
+
}),
|
|
297
|
+
),
|
|
262
298
|
);
|
|
263
299
|
return absoluteEntryFiles;
|
|
264
300
|
}
|
|
@@ -266,4 +302,4 @@ class IncrementalBundler {
|
|
|
266
302
|
await this._bundler.ready();
|
|
267
303
|
}
|
|
268
304
|
}
|
|
269
|
-
|
|
305
|
+
exports.default = IncrementalBundler;
|
|
@@ -9,27 +9,25 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
import type {DeltaResult, Graph, MixedOutput, Module} from './DeltaBundler';
|
|
15
13
|
import type {
|
|
16
14
|
Options as DeltaBundlerOptions,
|
|
17
15
|
ReadOnlyDependencies,
|
|
18
16
|
TransformInputOptions,
|
|
19
|
-
} from './DeltaBundler/types
|
|
17
|
+
} from './DeltaBundler/types';
|
|
20
18
|
import type {GraphId} from './lib/getGraphId';
|
|
21
|
-
import type {ResolverInputOptions} from './shared/types
|
|
19
|
+
import type {ResolverInputOptions} from './shared/types';
|
|
22
20
|
import type {ConfigT} from 'metro-config';
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
import Bundler from './Bundler';
|
|
23
|
+
import DeltaBundler from './DeltaBundler';
|
|
24
|
+
import ResourceNotFoundError from './IncrementalBundler/ResourceNotFoundError';
|
|
25
|
+
import getGraphId from './lib/getGraphId';
|
|
26
|
+
import getPrependedScripts from './lib/getPrependedScripts';
|
|
27
|
+
import * as transformHelpers from './lib/transformHelpers';
|
|
28
|
+
import crypto from 'crypto';
|
|
29
|
+
import fs from 'fs';
|
|
30
|
+
import path from 'path';
|
|
33
31
|
|
|
34
32
|
export opaque type RevisionId: string = string;
|
|
35
33
|
|
|
@@ -63,7 +61,7 @@ function revisionIdFromString(str: string): RevisionId {
|
|
|
63
61
|
return str;
|
|
64
62
|
}
|
|
65
63
|
|
|
66
|
-
class IncrementalBundler {
|
|
64
|
+
export default class IncrementalBundler {
|
|
67
65
|
_config: ConfigT;
|
|
68
66
|
_bundler: Bundler;
|
|
69
67
|
_deltaBundler: DeltaBundler<>;
|
|
@@ -366,5 +364,3 @@ class IncrementalBundler {
|
|
|
366
364
|
await this._bundler.ready();
|
|
367
365
|
}
|
|
368
366
|
}
|
|
369
|
-
|
|
370
|
-
module.exports = IncrementalBundler;
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.comparableCode = exports.codeFromAst = void 0;
|
|
7
|
+
exports.toEqualComparableCode = toEqualComparableCode;
|
|
8
|
+
exports.toMatchCodeFrameSnapshot = toMatchCodeFrameSnapshot;
|
|
9
|
+
var _generator = _interopRequireDefault(require("@babel/generator"));
|
|
10
|
+
var _jestSnapshot = require("jest-snapshot");
|
|
11
|
+
function _interopRequireDefault(e) {
|
|
12
|
+
return e && e.__esModule ? e : { default: e };
|
|
13
|
+
}
|
|
5
14
|
const generateOptions = {
|
|
6
15
|
concise: true,
|
|
7
16
|
sourceType: "module",
|
|
8
17
|
};
|
|
9
|
-
const codeFromAst = (ast) =>
|
|
18
|
+
const codeFromAst = (ast) => (0, _generator.default)(ast, generateOptions).code;
|
|
19
|
+
exports.codeFromAst = codeFromAst;
|
|
10
20
|
const comparableCode = (code) => code.trim().replace(/\s+/g, " ");
|
|
21
|
+
exports.comparableCode = comparableCode;
|
|
11
22
|
function toEqualComparableCode(received, expected) {
|
|
12
23
|
const comparableExpected = comparableCode(expected);
|
|
13
24
|
const pass = received === comparableExpected;
|
|
@@ -21,7 +32,7 @@ function toEqualComparableCode(received, expected) {
|
|
|
21
32
|
"toEqualComparableCode",
|
|
22
33
|
undefined,
|
|
23
34
|
undefined,
|
|
24
|
-
options
|
|
35
|
+
options,
|
|
25
36
|
) +
|
|
26
37
|
"\n\n" +
|
|
27
38
|
`Expected: not ${this.utils.printExpected(comparableExpected)}\n` +
|
|
@@ -32,14 +43,14 @@ function toEqualComparableCode(received, expected) {
|
|
|
32
43
|
received,
|
|
33
44
|
"expected",
|
|
34
45
|
"received",
|
|
35
|
-
this.expand
|
|
46
|
+
this.expand,
|
|
36
47
|
);
|
|
37
48
|
return (
|
|
38
49
|
this.utils.matcherHint(
|
|
39
50
|
"toEqualComparableCode",
|
|
40
51
|
undefined,
|
|
41
52
|
undefined,
|
|
42
|
-
options
|
|
53
|
+
options,
|
|
43
54
|
) +
|
|
44
55
|
"\n\n" +
|
|
45
56
|
diffString
|
|
@@ -56,15 +67,9 @@ function trimANSICodes(input) {
|
|
|
56
67
|
return input.replace(ANSI_PATTERN, "");
|
|
57
68
|
}
|
|
58
69
|
function toMatchCodeFrameSnapshot(received) {
|
|
59
|
-
return toMatchSnapshot.call(
|
|
70
|
+
return _jestSnapshot.toMatchSnapshot.call(
|
|
60
71
|
this,
|
|
61
72
|
trimANSICodes(received),
|
|
62
|
-
"toMatchCodeFrameSnapshot"
|
|
73
|
+
"toMatchCodeFrameSnapshot",
|
|
63
74
|
);
|
|
64
75
|
}
|
|
65
|
-
module.exports = {
|
|
66
|
-
codeFromAst,
|
|
67
|
-
comparableCode,
|
|
68
|
-
toEqualComparableCode,
|
|
69
|
-
toMatchCodeFrameSnapshot,
|
|
70
|
-
};
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.WRAP_NAME = void 0;
|
|
7
|
+
exports.jsonToCommonJS = jsonToCommonJS;
|
|
8
|
+
exports.wrapJson = wrapJson;
|
|
9
|
+
exports.wrapModule = wrapModule;
|
|
10
|
+
exports.wrapPolyfill = wrapPolyfill;
|
|
3
11
|
var _template = _interopRequireDefault(require("@babel/template"));
|
|
4
12
|
var _traverse = _interopRequireDefault(require("@babel/traverse"));
|
|
5
13
|
var t = _interopRequireWildcard(require("@babel/types"));
|
|
@@ -15,32 +23,24 @@ function _getRequireWildcardCache(e) {
|
|
|
15
23
|
function _interopRequireWildcard(e, r) {
|
|
16
24
|
if (!r && e && e.__esModule) return e;
|
|
17
25
|
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
18
|
-
return {
|
|
19
|
-
default: e,
|
|
20
|
-
};
|
|
26
|
+
return { default: e };
|
|
21
27
|
var t = _getRequireWildcardCache(r);
|
|
22
28
|
if (t && t.has(e)) return t.get(e);
|
|
23
|
-
var n = {
|
|
24
|
-
__proto__: null,
|
|
25
|
-
},
|
|
29
|
+
var n = { __proto__: null },
|
|
26
30
|
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
27
31
|
for (var u in e)
|
|
28
32
|
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
29
33
|
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
30
34
|
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
31
35
|
}
|
|
32
|
-
return (n.default = e), t && t.set(e, n), n;
|
|
36
|
+
return ((n.default = e), t && t.set(e, n), n);
|
|
33
37
|
}
|
|
34
38
|
function _interopRequireDefault(e) {
|
|
35
|
-
return e && e.__esModule
|
|
36
|
-
? e
|
|
37
|
-
: {
|
|
38
|
-
default: e,
|
|
39
|
-
};
|
|
39
|
+
return e && e.__esModule ? e : { default: e };
|
|
40
40
|
}
|
|
41
|
-
const WRAP_NAME = "$$_REQUIRE";
|
|
41
|
+
const WRAP_NAME = (exports.WRAP_NAME = "$$_REQUIRE");
|
|
42
42
|
const IIFE_PARAM = _template.default.expression(
|
|
43
|
-
"typeof globalThis !== 'undefined' ? globalThis : typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : this"
|
|
43
|
+
"typeof globalThis !== 'undefined' ? globalThis : typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : this",
|
|
44
44
|
);
|
|
45
45
|
function wrapModule(
|
|
46
46
|
fileAst,
|
|
@@ -49,12 +49,12 @@ function wrapModule(
|
|
|
49
49
|
dependencyMapName,
|
|
50
50
|
globalPrefix,
|
|
51
51
|
skipRequireRename,
|
|
52
|
-
{ unstable_useStaticHermesModuleFactory = false } = {}
|
|
52
|
+
{ unstable_useStaticHermesModuleFactory = false } = {},
|
|
53
53
|
) {
|
|
54
54
|
const params = buildParameters(
|
|
55
55
|
importDefaultName,
|
|
56
56
|
importAllName,
|
|
57
|
-
dependencyMapName
|
|
57
|
+
dependencyMapName,
|
|
58
58
|
);
|
|
59
59
|
const factory = functionFromProgram(fileAst.program, params);
|
|
60
60
|
const def = t.callExpression(t.identifier(`${globalPrefix}__d`), [
|
|
@@ -62,9 +62,9 @@ function wrapModule(
|
|
|
62
62
|
? t.callExpression(
|
|
63
63
|
t.memberExpression(
|
|
64
64
|
t.identifier("$SHBuiltin"),
|
|
65
|
-
t.identifier("moduleFactory")
|
|
65
|
+
t.identifier("moduleFactory"),
|
|
66
66
|
),
|
|
67
|
-
[t.identifier("_$$_METRO_MODULE_ID"), factory]
|
|
67
|
+
[t.identifier("_$$_METRO_MODULE_ID"), factory],
|
|
68
68
|
)
|
|
69
69
|
: factory,
|
|
70
70
|
]);
|
|
@@ -86,12 +86,12 @@ function jsonToCommonJS(source) {
|
|
|
86
86
|
function wrapJson(
|
|
87
87
|
source,
|
|
88
88
|
globalPrefix,
|
|
89
|
-
unstable_useStaticHermesModuleFactory = false
|
|
89
|
+
unstable_useStaticHermesModuleFactory = false,
|
|
90
90
|
) {
|
|
91
91
|
const moduleFactoryParameters = buildParameters(
|
|
92
92
|
"_importDefaultUnused",
|
|
93
93
|
"_importAllUnused",
|
|
94
|
-
"_dependencyMapUnused"
|
|
94
|
+
"_dependencyMapUnused",
|
|
95
95
|
);
|
|
96
96
|
const factory = [
|
|
97
97
|
`function(${moduleFactoryParameters.join(", ")}) {`,
|
|
@@ -110,7 +110,7 @@ function functionFromProgram(program, parameters) {
|
|
|
110
110
|
return t.functionExpression(
|
|
111
111
|
undefined,
|
|
112
112
|
parameters.map(makeIdentifier),
|
|
113
|
-
t.blockStatement(program.body, program.directives)
|
|
113
|
+
t.blockStatement(program.body, program.directives),
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
function makeIdentifier(name) {
|
|
@@ -134,7 +134,7 @@ function renameRequires(ast) {
|
|
|
134
134
|
const body = path.get("body.0.expression.arguments.0.body");
|
|
135
135
|
(0, _invariant.default)(
|
|
136
136
|
!Array.isArray(body),
|
|
137
|
-
"metro: Expected `body` to be a single path."
|
|
137
|
+
"metro: Expected `body` to be a single path.",
|
|
138
138
|
);
|
|
139
139
|
newRequireName = body.scope.generateUid(WRAP_NAME);
|
|
140
140
|
body.scope.rename("require", newRequireName);
|
|
@@ -142,10 +142,3 @@ function renameRequires(ast) {
|
|
|
142
142
|
});
|
|
143
143
|
return newRequireName;
|
|
144
144
|
}
|
|
145
|
-
module.exports = {
|
|
146
|
-
WRAP_NAME,
|
|
147
|
-
wrapJson,
|
|
148
|
-
jsonToCommonJS,
|
|
149
|
-
wrapModule,
|
|
150
|
-
wrapPolyfill,
|
|
151
|
-
};
|
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
* @flow strict-local
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
11
|
import type {FunctionExpression, Identifier, Program} from '@babel/types';
|
|
14
12
|
|
|
15
13
|
import template from '@babel/template';
|
|
@@ -162,11 +160,4 @@ function renameRequires(ast: BabelNodeFile): string {
|
|
|
162
160
|
return newRequireName;
|
|
163
161
|
}
|
|
164
162
|
|
|
165
|
-
|
|
166
|
-
WRAP_NAME,
|
|
167
|
-
|
|
168
|
-
wrapJson,
|
|
169
|
-
jsonToCommonJS,
|
|
170
|
-
wrapModule,
|
|
171
|
-
wrapPolyfill,
|
|
172
|
-
};
|
|
163
|
+
export {WRAP_NAME, wrapJson, jsonToCommonJS, wrapModule, wrapPolyfill};
|