metro 0.83.2 → 0.83.4
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 +25 -23
- package/src/Assets.js +50 -30
- package/src/Assets.js.flow +26 -15
- package/src/Bundler/util.js +33 -22
- package/src/Bundler/util.js.flow +2 -2
- package/src/Bundler.js +5 -1
- package/src/Bundler.js.flow +1 -1
- package/src/DeltaBundler/DeltaCalculator.js +9 -5
- package/src/DeltaBundler/DeltaCalculator.js.flow +8 -8
- package/src/DeltaBundler/Graph.js +21 -17
- package/src/DeltaBundler/Graph.js.flow +30 -30
- package/src/DeltaBundler/Serializers/baseJSBundle.js +5 -1
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +1 -1
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getAssets.js +5 -1
- package/src/DeltaBundler/Serializers/getAssets.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js +5 -1
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +8 -8
- package/src/DeltaBundler/Serializers/helpers/js.js +33 -22
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +6 -6
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +33 -22
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +5 -5
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +5 -1
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -6
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +2 -2
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -2
- package/src/DeltaBundler/Transformer.js +5 -1
- package/src/DeltaBundler/Transformer.js.flow +3 -3
- package/src/DeltaBundler/Worker.flow.js +5 -1
- package/src/DeltaBundler/Worker.flow.js.flow +1 -1
- package/src/DeltaBundler/WorkerFarm.js +1 -1
- package/src/DeltaBundler/WorkerFarm.js.flow +26 -13
- package/src/DeltaBundler/buildSubgraph.js +9 -5
- package/src/DeltaBundler/buildSubgraph.js.flow +8 -8
- package/src/DeltaBundler/getTransformCacheKey.js +5 -1
- package/src/DeltaBundler/types.js +5 -1
- package/src/DeltaBundler/types.js.flow +36 -34
- package/src/DeltaBundler.js +5 -1
- package/src/DeltaBundler.js.flow +2 -2
- package/src/HmrServer.js +42 -30
- package/src/HmrServer.js.flow +17 -12
- package/src/IncrementalBundler.js +37 -22
- package/src/IncrementalBundler.js.flow +13 -9
- package/src/ModuleGraph/worker/JsFileWrapping.js +33 -22
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +10 -5
- package/src/ModuleGraph/worker/collectDependencies.js +33 -22
- package/src/ModuleGraph/worker/collectDependencies.js.flow +27 -21
- package/src/ModuleGraph/worker/generateImportNames.js +5 -1
- package/src/ModuleGraph/worker/generateImportNames.js.flow +4 -2
- package/src/ModuleGraph/worker/importLocationsPlugin.js.flow +7 -3
- package/src/Server/MultipartResponse.js +5 -1
- package/src/Server/MultipartResponse.js.flow +1 -1
- package/src/Server/symbolicate.js.flow +4 -4
- package/src/Server.js +112 -40
- package/src/Server.js.flow +110 -47
- package/src/cli/parseKeyValueParamArray.js.flow +1 -1
- package/src/cli-utils.js +5 -1
- package/src/cli-utils.js.flow +2 -2
- package/src/commands/build.js +5 -1
- package/src/commands/build.js.flow +11 -10
- package/src/commands/dependencies.js +5 -1
- package/src/commands/dependencies.js.flow +8 -4
- package/src/commands/serve.js +2 -0
- package/src/commands/serve.js.flow +14 -9
- package/src/index.flow.js +38 -27
- package/src/index.flow.js.flow +25 -20
- package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +1 -1
- package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js +5 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import-with-escapes.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require-with-embedded-comment.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-specifier-with-escapes.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js +5 -1
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-require.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/index.js +33 -22
- package/src/integration_tests/basic_bundle/import-export/index.js.flow +3 -3
- package/src/integration_tests/basic_bundle/import-export/utils.js.flow +2 -2
- package/src/integration_tests/basic_bundle/loadBundleAsyncForTest.js.flow +1 -1
- package/src/integration_tests/basic_bundle/optional-dependencies/index.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/conflict.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/empty.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/matching.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-eager.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-lazy.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-sync.js.flow +2 -2
- package/src/integration_tests/basic_bundle/require-context/utils.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js.flow +1 -1
- package/src/integration_tests/execBundle.js +5 -1
- package/src/integration_tests/execBundle.js.flow +1 -1
- package/src/lib/BatchProcessor.js +10 -3
- package/src/lib/BatchProcessor.js.flow +10 -7
- package/src/lib/CountingSet.js.flow +4 -4
- package/src/lib/JsonReporter.js +5 -3
- package/src/lib/JsonReporter.js.flow +19 -17
- package/src/lib/RamBundleParser.js +5 -1
- package/src/lib/RamBundleParser.js.flow +1 -1
- package/src/lib/TerminalReporter.js +39 -28
- package/src/lib/TerminalReporter.js.flow +15 -15
- package/src/lib/contextModule.js +5 -1
- package/src/lib/contextModule.js.flow +1 -1
- package/src/lib/contextModuleTemplates.js +28 -21
- package/src/lib/countLines.js +4 -3
- package/src/lib/countLines.js.flow +3 -4
- package/src/lib/createWebsocketServer.js +14 -3
- package/src/lib/createWebsocketServer.js.flow +16 -9
- package/src/lib/debounceAsyncQueue.js.flow +1 -1
- package/src/lib/formatBundlingError.js +5 -1
- package/src/lib/formatBundlingError.js.flow +1 -1
- package/src/lib/getAppendScripts.js +5 -1
- package/src/lib/getAppendScripts.js.flow +4 -4
- package/src/lib/getGraphId.js +5 -1
- package/src/lib/getGraphId.js.flow +1 -1
- package/src/lib/getPreludeCode.js +4 -0
- package/src/lib/getPreludeCode.js.flow +10 -3
- package/src/lib/getPrependedScripts.js +44 -23
- package/src/lib/getPrependedScripts.js.flow +10 -3
- package/src/lib/logToConsole.js +5 -1
- package/src/lib/logToConsole.js.flow +2 -2
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +33 -22
- package/src/lib/parseCustomResolverOptions.js.flow +2 -2
- package/src/lib/parseCustomTransformOptions.js.flow +1 -1
- package/src/lib/parseJsonBody.js.flow +11 -1
- package/src/lib/pathUtils.js +28 -21
- package/src/lib/pathUtils.js.flow +1 -1
- package/src/lib/relativizeSourceMap.js +5 -1
- package/src/lib/reporting.js +5 -1
- package/src/lib/reporting.js.flow +4 -4
- package/src/lib/transformHelpers.js +16 -10
- package/src/lib/transformHelpers.js.flow +17 -15
- package/src/node-haste/DependencyGraph/ModuleResolution.js +56 -43
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +35 -32
- package/src/node-haste/DependencyGraph/createFileMap.js +64 -39
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +44 -18
- package/src/node-haste/DependencyGraph.js +45 -32
- package/src/node-haste/DependencyGraph.js.flow +35 -37
- package/src/node-haste/Package.js +5 -1
- package/src/node-haste/PackageCache.js +5 -1
- package/src/node-haste/lib/AssetPaths.js +7 -3
- package/src/node-haste/lib/AssetPaths.js.flow +4 -4
- package/src/node-haste/lib/parsePlatformFilePath.js +11 -7
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +4 -4
- package/src/shared/output/RamBundle/as-assets.js +5 -1
- package/src/shared/output/RamBundle/as-assets.js.flow +6 -6
- package/src/shared/output/RamBundle/as-indexed-file.js +5 -1
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +5 -5
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +5 -5
- package/src/shared/output/RamBundle/util.js +5 -1
- package/src/shared/output/RamBundle/util.js.flow +5 -5
- package/src/shared/output/RamBundle/write-sourcemap.js +5 -1
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
- package/src/shared/output/RamBundle.js +5 -1
- package/src/shared/output/RamBundle.js.flow +1 -1
- package/src/shared/output/bundle.flow.js +5 -1
- package/src/shared/output/bundle.flow.js.flow +3 -3
- package/src/shared/output/meta.js +7 -3
- package/src/shared/output/meta.js.flow +1 -1
- package/src/shared/output/writeFile.js +13 -4
- package/src/shared/output/writeFile.js.flow +8 -2
- package/src/shared/types.js.flow +20 -5
- package/src/Asset.d.ts +0 -25
- package/src/Bundler.d.ts +0 -39
- package/src/DeltaBundler/Graph.d.ts +0 -40
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +0 -26
- package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +0 -18
- package/src/DeltaBundler/Worker.d.ts +0 -45
- package/src/DeltaBundler/types.d.ts +0 -166
- package/src/DeltaBundler.d.ts +0 -58
- package/src/IncrementalBundler.d.ts +0 -98
- package/src/ModuleGraph/test-helpers.js +0 -75
- package/src/ModuleGraph/worker/collectDependencies.d.ts +0 -27
- package/src/Server/MultipartResponse.d.ts +0 -31
- package/src/Server/symbolicate.d.ts +0 -31
- package/src/Server.d.ts +0 -118
- package/src/index.d.ts +0 -193
- package/src/lib/CountingSet.d.ts +0 -48
- package/src/lib/TerminalReporter.d.ts +0 -27
- package/src/lib/contextModule.d.ts +0 -22
- package/src/lib/getGraphId.d.ts +0 -11
- package/src/lib/reporting.d.ts +0 -144
- package/src/node-haste/DependencyGraph.d.ts +0 -62
- package/src/shared/output/bundle.d.ts +0 -35
- package/src/shared/types.d.ts +0 -130
|
@@ -19,31 +19,42 @@ var transformHelpers = _interopRequireWildcard(
|
|
|
19
19
|
var _crypto = _interopRequireDefault(require("crypto"));
|
|
20
20
|
var _fs = _interopRequireDefault(require("fs"));
|
|
21
21
|
var _path = _interopRequireDefault(require("path"));
|
|
22
|
-
function
|
|
23
|
-
if ("function"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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]);
|
|
22
|
+
function _interopRequireWildcard(e, t) {
|
|
23
|
+
if ("function" == typeof WeakMap)
|
|
24
|
+
var r = new WeakMap(),
|
|
25
|
+
n = new WeakMap();
|
|
26
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
27
|
+
if (!t && e && e.__esModule) return e;
|
|
28
|
+
var o,
|
|
29
|
+
i,
|
|
30
|
+
f = {
|
|
31
|
+
__proto__: null,
|
|
32
|
+
default: e,
|
|
33
|
+
};
|
|
34
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
35
|
+
return f;
|
|
36
|
+
if ((o = t ? n : r)) {
|
|
37
|
+
if (o.has(e)) return o.get(e);
|
|
38
|
+
o.set(e, f);
|
|
42
39
|
}
|
|
43
|
-
|
|
40
|
+
for (const t in e)
|
|
41
|
+
"default" !== t &&
|
|
42
|
+
{}.hasOwnProperty.call(e, t) &&
|
|
43
|
+
((i =
|
|
44
|
+
(o = Object.defineProperty) &&
|
|
45
|
+
Object.getOwnPropertyDescriptor(e, t)) &&
|
|
46
|
+
(i.get || i.set)
|
|
47
|
+
? o(f, t, i)
|
|
48
|
+
: (f[t] = e[t]));
|
|
49
|
+
return f;
|
|
50
|
+
})(e, t);
|
|
44
51
|
}
|
|
45
52
|
function _interopRequireDefault(e) {
|
|
46
|
-
return e && e.__esModule
|
|
53
|
+
return e && e.__esModule
|
|
54
|
+
? e
|
|
55
|
+
: {
|
|
56
|
+
default: e,
|
|
57
|
+
};
|
|
47
58
|
}
|
|
48
59
|
function createRevisionId() {
|
|
49
60
|
return _crypto.default.randomBytes(8).toString("hex");
|
|
@@ -108,6 +119,8 @@ class IncrementalBundler {
|
|
|
108
119
|
this._config.transformer.unstable_allowRequireContext,
|
|
109
120
|
unstable_enablePackageExports:
|
|
110
121
|
this._config.resolver.unstable_enablePackageExports,
|
|
122
|
+
unstable_incrementalResolution:
|
|
123
|
+
this._config.resolver.unstable_incrementalResolution,
|
|
111
124
|
shallow: otherOptions.shallow,
|
|
112
125
|
});
|
|
113
126
|
this._config.serializer.experimentalSerializerHook(graph, {
|
|
@@ -152,6 +165,8 @@ class IncrementalBundler {
|
|
|
152
165
|
this._config.transformer.unstable_allowRequireContext,
|
|
153
166
|
unstable_enablePackageExports:
|
|
154
167
|
this._config.resolver.unstable_enablePackageExports,
|
|
168
|
+
unstable_incrementalResolution:
|
|
169
|
+
this._config.resolver.unstable_incrementalResolution,
|
|
155
170
|
shallow: otherOptions.shallow,
|
|
156
171
|
},
|
|
157
172
|
);
|
|
@@ -33,7 +33,7 @@ export opaque type RevisionId: string = string;
|
|
|
33
33
|
|
|
34
34
|
export type OutputGraph = Graph<>;
|
|
35
35
|
|
|
36
|
-
type OtherOptions =
|
|
36
|
+
type OtherOptions = Readonly<{
|
|
37
37
|
onProgress: DeltaBundlerOptions<>['onProgress'],
|
|
38
38
|
shallow: boolean,
|
|
39
39
|
lazy: boolean,
|
|
@@ -45,10 +45,10 @@ export type GraphRevision = {
|
|
|
45
45
|
+date: Date,
|
|
46
46
|
+graphId: GraphId,
|
|
47
47
|
+graph: OutputGraph,
|
|
48
|
-
+prepend:
|
|
48
|
+
+prepend: ReadonlyArray<Module<>>,
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
export type IncrementalBundlerOptions =
|
|
51
|
+
export type IncrementalBundlerOptions = Readonly<{
|
|
52
52
|
hasReducedPerformance?: boolean,
|
|
53
53
|
watch?: boolean,
|
|
54
54
|
}>;
|
|
@@ -99,7 +99,7 @@ export default class IncrementalBundler {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
async buildGraphForEntries(
|
|
102
|
-
entryFiles:
|
|
102
|
+
entryFiles: ReadonlyArray<string>,
|
|
103
103
|
transformOptions: TransformInputOptions,
|
|
104
104
|
resolverOptions: ResolverInputOptions,
|
|
105
105
|
otherOptions?: OtherOptions = {
|
|
@@ -131,6 +131,8 @@ export default class IncrementalBundler {
|
|
|
131
131
|
this._config.transformer.unstable_allowRequireContext,
|
|
132
132
|
unstable_enablePackageExports:
|
|
133
133
|
this._config.resolver.unstable_enablePackageExports,
|
|
134
|
+
unstable_incrementalResolution:
|
|
135
|
+
this._config.resolver.unstable_incrementalResolution,
|
|
134
136
|
shallow: otherOptions.shallow,
|
|
135
137
|
});
|
|
136
138
|
|
|
@@ -145,7 +147,7 @@ export default class IncrementalBundler {
|
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
async getDependencies(
|
|
148
|
-
entryFiles:
|
|
150
|
+
entryFiles: ReadonlyArray<string>,
|
|
149
151
|
transformOptions: TransformInputOptions,
|
|
150
152
|
resolverOptions: ResolverInputOptions,
|
|
151
153
|
otherOptions?: OtherOptions = {
|
|
@@ -179,6 +181,8 @@ export default class IncrementalBundler {
|
|
|
179
181
|
this._config.transformer.unstable_allowRequireContext,
|
|
180
182
|
unstable_enablePackageExports:
|
|
181
183
|
this._config.resolver.unstable_enablePackageExports,
|
|
184
|
+
unstable_incrementalResolution:
|
|
185
|
+
this._config.resolver.unstable_incrementalResolution,
|
|
182
186
|
shallow: otherOptions.shallow,
|
|
183
187
|
},
|
|
184
188
|
);
|
|
@@ -195,7 +199,7 @@ export default class IncrementalBundler {
|
|
|
195
199
|
shallow: false,
|
|
196
200
|
lazy: false,
|
|
197
201
|
},
|
|
198
|
-
): Promise<{+graph: OutputGraph, +prepend:
|
|
202
|
+
): Promise<{+graph: OutputGraph, +prepend: ReadonlyArray<Module<>>}> {
|
|
199
203
|
const graph = await this.buildGraphForEntries(
|
|
200
204
|
[entryFile],
|
|
201
205
|
transformOptions,
|
|
@@ -330,8 +334,8 @@ export default class IncrementalBundler {
|
|
|
330
334
|
}
|
|
331
335
|
|
|
332
336
|
async _getAbsoluteEntryFiles(
|
|
333
|
-
entryFiles:
|
|
334
|
-
): Promise
|
|
337
|
+
entryFiles: ReadonlyArray<string>,
|
|
338
|
+
): Promise<ReadonlyArray<string>> {
|
|
335
339
|
const absoluteEntryFiles = entryFiles.map((entryFile: string) =>
|
|
336
340
|
path.resolve(
|
|
337
341
|
this._config.server.unstable_serverRoot ?? this._config.projectRoot,
|
|
@@ -342,7 +346,7 @@ export default class IncrementalBundler {
|
|
|
342
346
|
await Promise.all(
|
|
343
347
|
absoluteEntryFiles.map(
|
|
344
348
|
(entryFile: string) =>
|
|
345
|
-
new Promise((resolve: void => void, reject:
|
|
349
|
+
new Promise((resolve: void => void, reject: unknown => unknown) => {
|
|
346
350
|
// This should throw an error if the file doesn't exist.
|
|
347
351
|
// Using this instead of fs.exists to account for SimLinks.
|
|
348
352
|
fs.realpath(entryFile, err => {
|
|
@@ -12,31 +12,42 @@ var _template = _interopRequireDefault(require("@babel/template"));
|
|
|
12
12
|
var _traverse = _interopRequireDefault(require("@babel/traverse"));
|
|
13
13
|
var t = _interopRequireWildcard(require("@babel/types"));
|
|
14
14
|
var _invariant = _interopRequireDefault(require("invariant"));
|
|
15
|
-
function
|
|
16
|
-
if ("function"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
33
|
-
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
34
|
-
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
15
|
+
function _interopRequireWildcard(e, t) {
|
|
16
|
+
if ("function" == typeof WeakMap)
|
|
17
|
+
var r = new WeakMap(),
|
|
18
|
+
n = new WeakMap();
|
|
19
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
20
|
+
if (!t && e && e.__esModule) return e;
|
|
21
|
+
var o,
|
|
22
|
+
i,
|
|
23
|
+
f = {
|
|
24
|
+
__proto__: null,
|
|
25
|
+
default: e,
|
|
26
|
+
};
|
|
27
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
28
|
+
return f;
|
|
29
|
+
if ((o = t ? n : r)) {
|
|
30
|
+
if (o.has(e)) return o.get(e);
|
|
31
|
+
o.set(e, f);
|
|
35
32
|
}
|
|
36
|
-
|
|
33
|
+
for (const t in e)
|
|
34
|
+
"default" !== t &&
|
|
35
|
+
{}.hasOwnProperty.call(e, t) &&
|
|
36
|
+
((i =
|
|
37
|
+
(o = Object.defineProperty) &&
|
|
38
|
+
Object.getOwnPropertyDescriptor(e, t)) &&
|
|
39
|
+
(i.get || i.set)
|
|
40
|
+
? o(f, t, i)
|
|
41
|
+
: (f[t] = e[t]));
|
|
42
|
+
return f;
|
|
43
|
+
})(e, t);
|
|
37
44
|
}
|
|
38
45
|
function _interopRequireDefault(e) {
|
|
39
|
-
return e && e.__esModule
|
|
46
|
+
return e && e.__esModule
|
|
47
|
+
? e
|
|
48
|
+
: {
|
|
49
|
+
default: e,
|
|
50
|
+
};
|
|
40
51
|
}
|
|
41
52
|
const WRAP_NAME = (exports.WRAP_NAME = "$$_REQUIRE");
|
|
42
53
|
const IIFE_PARAM = _template.default.expression(
|
|
@@ -4,11 +4,16 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @format
|
|
8
7
|
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
File as BabelNodeFile,
|
|
13
|
+
FunctionExpression,
|
|
14
|
+
Identifier,
|
|
15
|
+
Program,
|
|
16
|
+
} from '@babel/types';
|
|
12
17
|
|
|
13
18
|
import template from '@babel/template';
|
|
14
19
|
import traverse from '@babel/traverse';
|
|
@@ -33,7 +38,7 @@ function wrapModule(
|
|
|
33
38
|
skipRequireRename: boolean,
|
|
34
39
|
{
|
|
35
40
|
unstable_useStaticHermesModuleFactory = false,
|
|
36
|
-
}:
|
|
41
|
+
}: Readonly<{unstable_useStaticHermesModuleFactory?: boolean}> = {},
|
|
37
42
|
): {
|
|
38
43
|
ast: BabelNodeFile,
|
|
39
44
|
requireName: string,
|
|
@@ -106,7 +111,7 @@ function wrapJson(
|
|
|
106
111
|
|
|
107
112
|
function functionFromProgram(
|
|
108
113
|
program: Program,
|
|
109
|
-
parameters:
|
|
114
|
+
parameters: ReadonlyArray<string>,
|
|
110
115
|
): FunctionExpression {
|
|
111
116
|
return t.functionExpression(
|
|
112
117
|
undefined,
|
|
@@ -123,7 +128,7 @@ function buildParameters(
|
|
|
123
128
|
importDefaultName: string,
|
|
124
129
|
importAllName: string,
|
|
125
130
|
dependencyMapName: string,
|
|
126
|
-
):
|
|
131
|
+
): ReadonlyArray<string> {
|
|
127
132
|
return [
|
|
128
133
|
'global',
|
|
129
134
|
'require',
|
|
@@ -12,31 +12,42 @@ var types = _types;
|
|
|
12
12
|
var _crypto = _interopRequireDefault(require("crypto"));
|
|
13
13
|
var _invariant = _interopRequireDefault(require("invariant"));
|
|
14
14
|
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
15
|
-
function
|
|
16
|
-
if ("function"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
33
|
-
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
34
|
-
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
15
|
+
function _interopRequireWildcard(e, t) {
|
|
16
|
+
if ("function" == typeof WeakMap)
|
|
17
|
+
var r = new WeakMap(),
|
|
18
|
+
n = new WeakMap();
|
|
19
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
20
|
+
if (!t && e && e.__esModule) return e;
|
|
21
|
+
var o,
|
|
22
|
+
i,
|
|
23
|
+
f = {
|
|
24
|
+
__proto__: null,
|
|
25
|
+
default: e,
|
|
26
|
+
};
|
|
27
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
28
|
+
return f;
|
|
29
|
+
if ((o = t ? n : r)) {
|
|
30
|
+
if (o.has(e)) return o.get(e);
|
|
31
|
+
o.set(e, f);
|
|
35
32
|
}
|
|
36
|
-
|
|
33
|
+
for (const t in e)
|
|
34
|
+
"default" !== t &&
|
|
35
|
+
{}.hasOwnProperty.call(e, t) &&
|
|
36
|
+
((i =
|
|
37
|
+
(o = Object.defineProperty) &&
|
|
38
|
+
Object.getOwnPropertyDescriptor(e, t)) &&
|
|
39
|
+
(i.get || i.set)
|
|
40
|
+
? o(f, t, i)
|
|
41
|
+
: (f[t] = e[t]));
|
|
42
|
+
return f;
|
|
43
|
+
})(e, t);
|
|
37
44
|
}
|
|
38
45
|
function _interopRequireDefault(e) {
|
|
39
|
-
return e && e.__esModule
|
|
46
|
+
return e && e.__esModule
|
|
47
|
+
? e
|
|
48
|
+
: {
|
|
49
|
+
default: e,
|
|
50
|
+
};
|
|
40
51
|
}
|
|
41
52
|
function collectDependencies(ast, options) {
|
|
42
53
|
const visited = new WeakSet();
|
|
@@ -4,12 +4,18 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @format
|
|
8
7
|
* @flow
|
|
8
|
+
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import type {ReadonlySourceLocation} from '../../shared/types';
|
|
11
12
|
import type {NodePath} from '@babel/traverse';
|
|
12
|
-
import type {
|
|
13
|
+
import type {
|
|
14
|
+
CallExpression,
|
|
15
|
+
File as BabelNodeFile,
|
|
16
|
+
Identifier,
|
|
17
|
+
StringLiteral,
|
|
18
|
+
} from '@babel/types';
|
|
13
19
|
import type {
|
|
14
20
|
AllowOptionalDependencies,
|
|
15
21
|
AsyncDependencyType,
|
|
@@ -24,12 +30,12 @@ import crypto from 'crypto';
|
|
|
24
30
|
import invariant from 'invariant';
|
|
25
31
|
import nullthrows from 'nullthrows';
|
|
26
32
|
|
|
27
|
-
type ImportDependencyOptions =
|
|
33
|
+
type ImportDependencyOptions = Readonly<{
|
|
28
34
|
asyncType: AsyncDependencyType,
|
|
29
35
|
isESMImport: boolean,
|
|
30
36
|
}>;
|
|
31
37
|
|
|
32
|
-
export type Dependency =
|
|
38
|
+
export type Dependency = Readonly<{
|
|
33
39
|
data: DependencyData,
|
|
34
40
|
name: string,
|
|
35
41
|
}>;
|
|
@@ -37,18 +43,18 @@ export type Dependency = $ReadOnly<{
|
|
|
37
43
|
// TODO: Convert to a Flow enum
|
|
38
44
|
export type ContextMode = 'sync' | 'eager' | 'lazy' | 'lazy-once';
|
|
39
45
|
|
|
40
|
-
type ContextFilter =
|
|
46
|
+
type ContextFilter = Readonly<{pattern: string, flags: string}>;
|
|
41
47
|
|
|
42
|
-
export type RequireContextParams =
|
|
48
|
+
export type RequireContextParams = Readonly<{
|
|
43
49
|
/* Should search for files recursively. Optional, default `true` when `require.context` is used */
|
|
44
50
|
recursive: boolean,
|
|
45
51
|
/* Filename filter pattern for use in `require.context`. Optional, default `.*` (any file) when `require.context` is used */
|
|
46
|
-
filter:
|
|
52
|
+
filter: Readonly<ContextFilter>,
|
|
47
53
|
/** Mode for resolving dynamic dependencies. Defaults to `sync` */
|
|
48
54
|
mode: ContextMode,
|
|
49
55
|
}>;
|
|
50
56
|
|
|
51
|
-
type DependencyData =
|
|
57
|
+
type DependencyData = Readonly<{
|
|
52
58
|
// A locally unique key for this dependency within the current module.
|
|
53
59
|
key: string,
|
|
54
60
|
// If null, then the dependency is synchronous.
|
|
@@ -60,19 +66,19 @@ type DependencyData = $ReadOnly<{
|
|
|
60
66
|
// and subpath imports.
|
|
61
67
|
isESMImport: boolean,
|
|
62
68
|
isOptional?: boolean,
|
|
63
|
-
locs:
|
|
69
|
+
locs: ReadonlyArray<ReadonlySourceLocation>,
|
|
64
70
|
/** Context for requiring a collection of modules. */
|
|
65
71
|
contextParams?: RequireContextParams,
|
|
66
72
|
}>;
|
|
67
73
|
|
|
68
74
|
export type MutableInternalDependency = {
|
|
69
75
|
...DependencyData,
|
|
70
|
-
locs: Array<
|
|
76
|
+
locs: Array<ReadonlySourceLocation>,
|
|
71
77
|
index: number,
|
|
72
78
|
name: string,
|
|
73
79
|
};
|
|
74
80
|
|
|
75
|
-
export type InternalDependency =
|
|
81
|
+
export type InternalDependency = Readonly<MutableInternalDependency>;
|
|
76
82
|
|
|
77
83
|
export type State = {
|
|
78
84
|
asyncRequireModulePathStringLiteral: ?StringLiteral,
|
|
@@ -85,26 +91,26 @@ export type State = {
|
|
|
85
91
|
allowOptionalDependencies: AllowOptionalDependencies,
|
|
86
92
|
/** Enable `require.context` statements which can be used to import multiple files in a directory. */
|
|
87
93
|
unstable_allowRequireContext: boolean,
|
|
88
|
-
unstable_isESMImportAtSource: ?(
|
|
94
|
+
unstable_isESMImportAtSource: ?(ReadonlySourceLocation) => boolean,
|
|
89
95
|
};
|
|
90
96
|
|
|
91
|
-
export type Options =
|
|
97
|
+
export type Options = Readonly<{
|
|
92
98
|
asyncRequireModulePath: string,
|
|
93
99
|
dependencyMapName: ?string,
|
|
94
100
|
dynamicRequires: DynamicRequiresBehavior,
|
|
95
|
-
inlineableCalls:
|
|
101
|
+
inlineableCalls: ReadonlyArray<string>,
|
|
96
102
|
keepRequireNames: boolean,
|
|
97
103
|
allowOptionalDependencies: AllowOptionalDependencies,
|
|
98
104
|
dependencyTransformer?: DependencyTransformer,
|
|
99
105
|
/** Enable `require.context` statements which can be used to import multiple files in a directory. */
|
|
100
106
|
unstable_allowRequireContext: boolean,
|
|
101
|
-
unstable_isESMImportAtSource?: ?(
|
|
107
|
+
unstable_isESMImportAtSource?: ?(ReadonlySourceLocation) => boolean,
|
|
102
108
|
}>;
|
|
103
109
|
|
|
104
|
-
export type CollectedDependencies =
|
|
110
|
+
export type CollectedDependencies = Readonly<{
|
|
105
111
|
ast: BabelNodeFile,
|
|
106
112
|
dependencyMapName: string,
|
|
107
|
-
dependencies:
|
|
113
|
+
dependencies: ReadonlyArray<Dependency>,
|
|
108
114
|
}>;
|
|
109
115
|
|
|
110
116
|
export interface DependencyTransformer {
|
|
@@ -562,7 +568,7 @@ function processRequireCall(
|
|
|
562
568
|
transformer.transformSyncRequire(path, dep, state);
|
|
563
569
|
}
|
|
564
570
|
|
|
565
|
-
function getNearestLocFromPath(path: NodePath<>): ?
|
|
571
|
+
function getNearestLocFromPath(path: NodePath<>): ?ReadonlySourceLocation {
|
|
566
572
|
let current: ?(NodePath<> | NodePath<BabelNode>) = path;
|
|
567
573
|
while (
|
|
568
574
|
current &&
|
|
@@ -582,7 +588,7 @@ function getNearestLocFromPath(path: NodePath<>): ?BabelSourceLocation {
|
|
|
582
588
|
);
|
|
583
589
|
}
|
|
584
590
|
|
|
585
|
-
export type ImportQualifier =
|
|
591
|
+
export type ImportQualifier = Readonly<{
|
|
586
592
|
name: string,
|
|
587
593
|
asyncType: AsyncDependencyType | null,
|
|
588
594
|
isESMImport: boolean,
|
|
@@ -732,11 +738,11 @@ const DefaultDependencyTransformer: DependencyTransformer = {
|
|
|
732
738
|
state: State,
|
|
733
739
|
): void {
|
|
734
740
|
const moduleIDExpression = createModuleIDExpression(dependency, state);
|
|
735
|
-
path.node.arguments =
|
|
741
|
+
path.node.arguments = [moduleIDExpression] as Array<
|
|
736
742
|
| BabelNodeExpression
|
|
737
743
|
| BabelNodeSpreadElement
|
|
738
744
|
| BabelNodeArgumentPlaceholder,
|
|
739
|
-
|
|
745
|
+
>;
|
|
740
746
|
// Always add the debug name argument last
|
|
741
747
|
if (state.keepRequireNames) {
|
|
742
748
|
path.node.arguments.push(types.stringLiteral(dependency.name));
|
|
@@ -7,7 +7,11 @@ exports.default = generateImportNames;
|
|
|
7
7
|
var _traverse = _interopRequireDefault(require("@babel/traverse"));
|
|
8
8
|
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
9
9
|
function _interopRequireDefault(e) {
|
|
10
|
-
return e && e.__esModule
|
|
10
|
+
return e && e.__esModule
|
|
11
|
+
? e
|
|
12
|
+
: {
|
|
13
|
+
default: e,
|
|
14
|
+
};
|
|
11
15
|
}
|
|
12
16
|
function generateImportNames(ast) {
|
|
13
17
|
let importDefault;
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @format
|
|
8
7
|
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import type {Node} from '@babel/types';
|
|
12
|
+
|
|
11
13
|
import traverse from '@babel/traverse';
|
|
12
14
|
import nullthrows from 'nullthrows';
|
|
13
15
|
|
|
@@ -15,7 +17,7 @@ import nullthrows from 'nullthrows';
|
|
|
15
17
|
* Select unused names for "metroImportDefault" and "metroImportAll", by
|
|
16
18
|
* calling "generateUid".
|
|
17
19
|
*/
|
|
18
|
-
export default function generateImportNames(ast:
|
|
20
|
+
export default function generateImportNames(ast: Node): {
|
|
19
21
|
importAll: string,
|
|
20
22
|
importDefault: string,
|
|
21
23
|
} {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import type {
|
|
12
|
+
import type {ReadonlySourceLocation} from '../../shared/types';
|
|
13
|
+
import type {PluginObj} from '@babel/core';
|
|
13
14
|
import typeof * as Types from '@babel/types';
|
|
14
15
|
import type {MetroBabelFileMetadata} from 'metro-babel-transformer';
|
|
15
16
|
|
|
@@ -17,7 +18,10 @@ type ImportDeclarationLocs = Set<string>;
|
|
|
17
18
|
|
|
18
19
|
type State = {
|
|
19
20
|
importDeclarationLocs: ImportDeclarationLocs,
|
|
20
|
-
file:
|
|
21
|
+
file: {
|
|
22
|
+
metadata?: MetroBabelFileMetadata,
|
|
23
|
+
...
|
|
24
|
+
},
|
|
21
25
|
...
|
|
22
26
|
};
|
|
23
27
|
|
|
@@ -78,7 +82,7 @@ function importLocationsPlugin({
|
|
|
78
82
|
// Very simple serialisation of a source location. This should remain opaque to
|
|
79
83
|
// the caller.
|
|
80
84
|
const MISSING_LOC = {line: -1, column: -1};
|
|
81
|
-
function locToKey(loc:
|
|
85
|
+
function locToKey(loc: ReadonlySourceLocation): string {
|
|
82
86
|
const {start = MISSING_LOC, end = MISSING_LOC} = loc;
|
|
83
87
|
return `${start.line},${start.column}:${end.line},${end.column}`;
|
|
84
88
|
}
|
|
@@ -6,7 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _accepts = _interopRequireDefault(require("accepts"));
|
|
8
8
|
function _interopRequireDefault(e) {
|
|
9
|
-
return e && e.__esModule
|
|
9
|
+
return e && e.__esModule
|
|
10
|
+
? e
|
|
11
|
+
: {
|
|
12
|
+
default: e,
|
|
13
|
+
};
|
|
10
14
|
}
|
|
11
15
|
const CRLF = "\r\n";
|
|
12
16
|
const BOUNDARY = "3beqjf3apnqeu3h5jqorms4i";
|
|
@@ -31,7 +31,7 @@ export type IntermediateStackFrame = {
|
|
|
31
31
|
collapse?: boolean,
|
|
32
32
|
...
|
|
33
33
|
};
|
|
34
|
-
export type StackFrameOutput =
|
|
34
|
+
export type StackFrameOutput = Readonly<IntermediateStackFrame>;
|
|
35
35
|
type ExplodedSourceMapModule = ExplodedSourceMap[number];
|
|
36
36
|
type Position = {+line1Based: number, column0Based: number};
|
|
37
37
|
|
|
@@ -57,11 +57,11 @@ function createFunctionNameGetter(
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export default async function symbolicate(
|
|
60
|
-
stack:
|
|
60
|
+
stack: ReadonlyArray<StackFrameInput>,
|
|
61
61
|
maps: Iterable<[string, ExplodedSourceMap]>,
|
|
62
62
|
config: ConfigT,
|
|
63
|
-
extraData:
|
|
64
|
-
): Promise
|
|
63
|
+
extraData: unknown,
|
|
64
|
+
): Promise<ReadonlyArray<StackFrameOutput>> {
|
|
65
65
|
const mapsByUrl = new Map<?string, ExplodedSourceMap>();
|
|
66
66
|
for (const [url, map] of maps) {
|
|
67
67
|
mapsByUrl.set(url, map);
|