metro 0.82.4 → 0.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +18 -21
- package/src/DeltaBundler/DeltaCalculator.js +5 -1
- package/src/DeltaBundler/Graph.js +37 -10
- package/src/DeltaBundler/Graph.js.flow +49 -22
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +1 -0
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js +4 -1
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js.flow +5 -1
- package/src/DeltaBundler/Serializers/helpers/js.js +4 -0
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +6 -0
- package/src/DeltaBundler/Transformer.js +5 -2
- package/src/DeltaBundler/Transformer.js.flow +3 -2
- package/src/DeltaBundler/Worker.d.ts +7 -9
- package/src/DeltaBundler/Worker.flow.js.flow +2 -2
- package/src/DeltaBundler/WorkerFarm.js +2 -2
- package/src/DeltaBundler/WorkerFarm.js.flow +2 -6
- package/src/DeltaBundler/buildSubgraph.js +21 -15
- package/src/DeltaBundler/buildSubgraph.js.flow +21 -21
- package/src/DeltaBundler/getTransformCacheKey.js +1 -1
- package/src/DeltaBundler/getTransformCacheKey.js.flow +1 -1
- package/src/DeltaBundler/types.flow.js +5 -1
- package/src/DeltaBundler/types.flow.js.flow +7 -1
- package/src/ModuleGraph/worker/JsFileWrapping.js +39 -9
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +32 -5
- package/src/ModuleGraph/worker/collectDependencies.js.flow +7 -1
- package/src/Server/symbolicate.js +4 -2
- package/src/Server/symbolicate.js.flow +4 -2
- package/src/Server.d.ts +6 -1
- package/src/Server.js +51 -14
- package/src/Server.js.flow +75 -21
- package/src/commands/build.js +5 -1
- package/src/commands/serve.js +4 -1
- package/src/commands/serve.js.flow +4 -1
- package/src/index.d.ts +13 -7
- package/src/index.flow.js +9 -3
- package/src/index.flow.js.flow +69 -63
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js +5 -1
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js +5 -1
- package/src/integration_tests/basic_bundle/import-export/index.js +11 -3
- package/src/integration_tests/basic_bundle/optional-dependencies/index.js +20 -0
- package/src/integration_tests/basic_bundle/optional-dependencies/index.js.flow +34 -0
- package/src/integration_tests/basic_bundle/optional-dependencies/optional-b.js +3 -0
- package/src/integration_tests/basic_bundle/optional-dependencies/optional-b.js.flow +11 -0
- package/src/integration_tests/basic_bundle/optional-dependencies/optional-c.js +3 -0
- package/src/integration_tests/basic_bundle/optional-dependencies/optional-c.js.flow +11 -0
- package/src/integration_tests/basic_bundle/optional-dependencies/required-a.js +3 -0
- package/src/integration_tests/basic_bundle/optional-dependencies/required-a.js.flow +11 -0
- package/src/lib/RamBundleParser.js.flow +1 -0
- package/src/lib/contextModule.js +5 -1
- package/src/lib/contextModuleTemplates.js +6 -2
- package/src/lib/createWebsocketServer.js +5 -1
- package/src/lib/createWebsocketServer.js.flow +1 -0
- package/src/lib/formatBundlingError.js.flow +1 -1
- package/src/lib/getAppendScripts.js +5 -1
- package/src/lib/getGraphId.js +1 -1
- package/src/lib/getGraphId.js.flow +1 -1
- package/src/lib/getPrependedScripts.js +6 -2
- package/src/lib/getPrependedScripts.js.flow +2 -2
- package/src/lib/isResolvedDependency.js +9 -0
- package/src/lib/isResolvedDependency.js.flow +18 -0
- package/src/lib/transformHelpers.js +6 -6
- package/src/lib/transformHelpers.js.flow +1 -5
- package/src/node-haste/DependencyGraph/ModuleResolution.js +2 -1
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +6 -2
- package/src/node-haste/DependencyGraph/createFileMap.js +6 -2
- package/src/node-haste/DependencyGraph.js +1 -1
- package/src/node-haste/DependencyGraph.js.flow +5 -4
- package/src/node-haste/Module.js +5 -1
- package/src/node-haste/Package.js.flow +1 -1
- package/src/shared/output/RamBundle/util.js +5 -1
- package/src/shared/output/RamBundle/util.js.flow +3 -1
- package/src/shared/output/RamBundle.js.flow +2 -0
- package/src/shared/output/bundle.d.ts +5 -1
- package/src/shared/output/bundle.flow.js +8 -5
- package/src/shared/output/bundle.flow.js.flow +11 -5
- package/src/shared/types.d.ts +4 -0
- package/src/shared/types.flow.js.flow +12 -8
|
@@ -25,7 +25,7 @@ import type {ConfigT} from 'metro-config';
|
|
|
25
25
|
import type {Type} from 'metro-transform-worker';
|
|
26
26
|
|
|
27
27
|
import {getContextModuleTemplate} from './contextModuleTemplates';
|
|
28
|
-
import isAssetFile from 'metro-resolver/
|
|
28
|
+
import isAssetFile from 'metro-resolver/private/utils/isAssetFile';
|
|
29
29
|
|
|
30
30
|
type InlineRequiresRaw =
|
|
31
31
|
| $ReadOnly<{blockList: $ReadOnly<{[string]: true, ...}>, ...}>
|
|
@@ -113,10 +113,6 @@ async function calcTransformerOptions(
|
|
|
113
113
|
|
|
114
114
|
return {
|
|
115
115
|
...baseOptions,
|
|
116
|
-
inlinePlatform:
|
|
117
|
-
transform?.unstable_inlinePlatform != null
|
|
118
|
-
? transform.unstable_inlinePlatform
|
|
119
|
-
: true,
|
|
120
116
|
inlineRequires: transform?.inlineRequires || false,
|
|
121
117
|
experimentalImportSupport: transform?.experimentalImportSupport || false,
|
|
122
118
|
unstable_disableES6Transforms:
|
|
@@ -4,7 +4,7 @@ const { codeFrameColumns } = require("@babel/code-frame");
|
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const invariant = require("invariant");
|
|
6
6
|
const Resolver = require("metro-resolver");
|
|
7
|
-
const createDefaultContext = require("metro-resolver/
|
|
7
|
+
const createDefaultContext = require("metro-resolver/private/createDefaultContext");
|
|
8
8
|
const path = require("path");
|
|
9
9
|
const util = require("util");
|
|
10
10
|
class ModuleResolver {
|
|
@@ -231,6 +231,7 @@ function getArrayLowestItem(a) {
|
|
|
231
231
|
return lowest;
|
|
232
232
|
}
|
|
233
233
|
class UnableToResolveError extends Error {
|
|
234
|
+
type = "UnableToResolveError";
|
|
234
235
|
constructor(originModulePath, targetModuleName, message, options) {
|
|
235
236
|
super();
|
|
236
237
|
this.originModulePath = originModulePath;
|
|
@@ -25,13 +25,13 @@ import type {
|
|
|
25
25
|
Resolution,
|
|
26
26
|
ResolveAsset,
|
|
27
27
|
} from 'metro-resolver';
|
|
28
|
-
import type {PackageForModule, PackageJson} from 'metro-resolver/
|
|
28
|
+
import type {PackageForModule, PackageJson} from 'metro-resolver/private/types';
|
|
29
29
|
|
|
30
30
|
const {codeFrameColumns} = require('@babel/code-frame');
|
|
31
31
|
const fs = require('fs');
|
|
32
32
|
const invariant = require('invariant');
|
|
33
33
|
const Resolver = require('metro-resolver');
|
|
34
|
-
const createDefaultContext = require('metro-resolver/
|
|
34
|
+
const createDefaultContext = require('metro-resolver/private/createDefaultContext');
|
|
35
35
|
const path = require('path');
|
|
36
36
|
const util = require('util');
|
|
37
37
|
|
|
@@ -345,6 +345,10 @@ class UnableToResolveError extends Error {
|
|
|
345
345
|
* Original error that causes this error
|
|
346
346
|
*/
|
|
347
347
|
cause: ?Error;
|
|
348
|
+
/**
|
|
349
|
+
* Fixed type field in common with other Metro build errors.
|
|
350
|
+
*/
|
|
351
|
+
+type: 'UnableToResolveError' = 'UnableToResolveError';
|
|
348
352
|
|
|
349
353
|
constructor(
|
|
350
354
|
originModulePath: string,
|
|
@@ -12,10 +12,14 @@ function _getRequireWildcardCache(e) {
|
|
|
12
12
|
function _interopRequireWildcard(e, r) {
|
|
13
13
|
if (!r && e && e.__esModule) return e;
|
|
14
14
|
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
15
|
-
return {
|
|
15
|
+
return {
|
|
16
|
+
default: e,
|
|
17
|
+
};
|
|
16
18
|
var t = _getRequireWildcardCache(r);
|
|
17
19
|
if (t && t.has(e)) return t.get(e);
|
|
18
|
-
var n = {
|
|
20
|
+
var n = {
|
|
21
|
+
__proto__: null,
|
|
22
|
+
},
|
|
19
23
|
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
20
24
|
for (var u in e)
|
|
21
25
|
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
@@ -11,7 +11,7 @@ const {
|
|
|
11
11
|
Logger: { createActionStartEntry, createActionEndEntry, log },
|
|
12
12
|
PackageResolutionError,
|
|
13
13
|
} = require("metro-core");
|
|
14
|
-
const canonicalize = require("metro-core/
|
|
14
|
+
const canonicalize = require("metro-core/private/canonicalize");
|
|
15
15
|
const { InvalidPackageError } = require("metro-resolver");
|
|
16
16
|
const nullthrows = require("nullthrows");
|
|
17
17
|
const path = require("path");
|
|
@@ -23,6 +23,7 @@ import type MetroFileMap, {
|
|
|
23
23
|
HealthCheckResult,
|
|
24
24
|
WatcherStatus,
|
|
25
25
|
} from 'metro-file-map';
|
|
26
|
+
import type {FileSystemLookup} from 'metro-resolver';
|
|
26
27
|
|
|
27
28
|
import {DuplicateHasteCandidatesError} from 'metro-file-map';
|
|
28
29
|
|
|
@@ -36,7 +37,7 @@ const {
|
|
|
36
37
|
Logger: {createActionStartEntry, createActionEndEntry, log},
|
|
37
38
|
PackageResolutionError,
|
|
38
39
|
} = require('metro-core');
|
|
39
|
-
const canonicalize = require('metro-core/
|
|
40
|
+
const canonicalize = require('metro-core/private/canonicalize');
|
|
40
41
|
const {InvalidPackageError} = require('metro-resolver');
|
|
41
42
|
const nullthrows = require('nullthrows');
|
|
42
43
|
const path = require('path');
|
|
@@ -167,16 +168,16 @@ class DependencyGraph extends EventEmitter {
|
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
_createModuleResolver() {
|
|
170
|
-
const fileSystemLookup = (path: string) => {
|
|
171
|
+
const fileSystemLookup = (path: string): ReturnType<FileSystemLookup> => {
|
|
171
172
|
const result = this._fileSystem.lookup(path);
|
|
172
173
|
if (result.exists) {
|
|
173
174
|
return {
|
|
174
|
-
exists: true
|
|
175
|
+
exists: true,
|
|
175
176
|
realPath: result.realPath,
|
|
176
177
|
type: result.type,
|
|
177
178
|
};
|
|
178
179
|
}
|
|
179
|
-
return {exists: false
|
|
180
|
+
return {exists: false};
|
|
180
181
|
};
|
|
181
182
|
|
|
182
183
|
this._moduleResolver = new ModuleResolver({
|
package/src/node-haste/Module.js
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var _path = _interopRequireDefault(require("path"));
|
|
4
4
|
function _interopRequireDefault(e) {
|
|
5
|
-
return e && e.__esModule
|
|
5
|
+
return e && e.__esModule
|
|
6
|
+
? e
|
|
7
|
+
: {
|
|
8
|
+
default: e,
|
|
9
|
+
};
|
|
6
10
|
}
|
|
7
11
|
class Module {
|
|
8
12
|
constructor(file, moduleCache) {
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var _countLines = _interopRequireDefault(require("../../../lib/countLines"));
|
|
4
4
|
function _interopRequireDefault(e) {
|
|
5
|
-
return e && e.__esModule
|
|
5
|
+
return e && e.__esModule
|
|
6
|
+
? e
|
|
7
|
+
: {
|
|
8
|
+
default: e,
|
|
9
|
+
};
|
|
6
10
|
}
|
|
7
11
|
const invariant = require("invariant");
|
|
8
12
|
function lineToLineSourceMap(source, filename = "") {
|
|
@@ -83,7 +83,7 @@ function combineMaps(
|
|
|
83
83
|
moduleGroups: ?ModuleGroups,
|
|
84
84
|
options: ?CombineOptions,
|
|
85
85
|
): Array<IndexMapSection> {
|
|
86
|
-
const sections = [];
|
|
86
|
+
const sections: Array<IndexMapSection> = [];
|
|
87
87
|
|
|
88
88
|
let line = 0;
|
|
89
89
|
modules.forEach((moduleTransport: ModuleTransportLike) => {
|
|
@@ -121,6 +121,8 @@ function combineMaps(
|
|
|
121
121
|
'Random Access Bundle source maps cannot be built from raw mappings',
|
|
122
122
|
);
|
|
123
123
|
sections.push(
|
|
124
|
+
/* $FlowFixMe[incompatible-exact] Natural Inference rollout. See
|
|
125
|
+
* https://fburl.com/gdoc/y8dn025u */
|
|
124
126
|
Section(line, column, map || lineToLineSourceMap(code, name)),
|
|
125
127
|
);
|
|
126
128
|
if (offsets != null && id != null) {
|
|
@@ -8,15 +8,19 @@
|
|
|
8
8
|
* @oncall react_native
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import type {AssetData} from '../../Asset';
|
|
12
|
+
|
|
11
13
|
import Server from '../../Server';
|
|
12
|
-
import {OutputOptions, RequestOptions} from '../../shared/types';
|
|
14
|
+
import {BuildOptions, OutputOptions, RequestOptions} from '../../shared/types';
|
|
13
15
|
|
|
14
16
|
export function build(
|
|
15
17
|
packagerClient: Server,
|
|
16
18
|
requestOptions: RequestOptions,
|
|
19
|
+
buildOptions?: BuildOptions,
|
|
17
20
|
): Promise<{
|
|
18
21
|
code: string;
|
|
19
22
|
map: string;
|
|
23
|
+
assets?: ReadonlyArray<AssetData>;
|
|
20
24
|
}>;
|
|
21
25
|
|
|
22
26
|
export function save(
|
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
const relativizeSourceMapInline = require("../../lib/relativizeSourceMap");
|
|
4
4
|
const Server = require("../../Server");
|
|
5
5
|
const writeFile = require("./writeFile");
|
|
6
|
-
function buildBundle(packagerClient, requestOptions) {
|
|
7
|
-
return packagerClient.build(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
function buildBundle(packagerClient, requestOptions, buildOptions = {}) {
|
|
7
|
+
return packagerClient.build(
|
|
8
|
+
{
|
|
9
|
+
...Server.DEFAULT_BUNDLE_OPTIONS,
|
|
10
|
+
...requestOptions,
|
|
11
|
+
},
|
|
12
|
+
buildOptions
|
|
13
|
+
);
|
|
11
14
|
}
|
|
12
15
|
function relativateSerializedMap(map, sourceMapSourcesRoot) {
|
|
13
16
|
const sourceMap = JSON.parse(map);
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
import type {
|
|
14
|
+
import type {AssetData} from '../../Assets';
|
|
15
|
+
import type {BuildOptions, OutputOptions, RequestOptions} from '../types.flow';
|
|
15
16
|
import type {MixedSourceMap} from 'metro-source-map';
|
|
16
17
|
|
|
17
18
|
const relativizeSourceMapInline = require('../../lib/relativizeSourceMap');
|
|
@@ -21,15 +22,20 @@ const writeFile = require('./writeFile');
|
|
|
21
22
|
function buildBundle(
|
|
22
23
|
packagerClient: Server,
|
|
23
24
|
requestOptions: RequestOptions,
|
|
25
|
+
buildOptions?: BuildOptions = {},
|
|
24
26
|
): Promise<{
|
|
25
27
|
code: string,
|
|
26
28
|
map: string,
|
|
29
|
+
assets?: $ReadOnlyArray<AssetData>,
|
|
27
30
|
...
|
|
28
31
|
}> {
|
|
29
|
-
return packagerClient.build(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
return packagerClient.build(
|
|
33
|
+
{
|
|
34
|
+
...Server.DEFAULT_BUNDLE_OPTIONS,
|
|
35
|
+
...requestOptions,
|
|
36
|
+
},
|
|
37
|
+
buildOptions,
|
|
38
|
+
);
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
function relativateSerializedMap(
|
package/src/shared/types.d.ts
CHANGED
|
@@ -47,6 +47,10 @@ export interface BundleOptions {
|
|
|
47
47
|
readonly unstable_transformProfile: TransformProfile;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
export interface BuildOptions {
|
|
51
|
+
readonly withAssets?: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
50
54
|
export interface ResolverInputOptions {
|
|
51
55
|
readonly customResolverOptions?: CustomResolverOptions;
|
|
52
56
|
}
|
|
@@ -59,6 +59,10 @@ export type BundleOptions = {
|
|
|
59
59
|
+sourcePaths: SourcePathsMode,
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
+
export type BuildOptions = $ReadOnly<{
|
|
63
|
+
withAssets?: boolean,
|
|
64
|
+
}>;
|
|
65
|
+
|
|
62
66
|
export type ResolverInputOptions = $ReadOnly<{
|
|
63
67
|
customResolverOptions?: CustomResolverOptions,
|
|
64
68
|
dev: boolean,
|
|
@@ -80,14 +84,14 @@ export type GraphOptions = {
|
|
|
80
84
|
};
|
|
81
85
|
|
|
82
86
|
// Stricter representation of BundleOptions.
|
|
83
|
-
export type SplitBundleOptions = {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
87
|
+
export type SplitBundleOptions = $ReadOnly<{
|
|
88
|
+
entryFile: string,
|
|
89
|
+
resolverOptions: ResolverInputOptions,
|
|
90
|
+
transformOptions: TransformInputOptions,
|
|
91
|
+
serializerOptions: SerializerOptions,
|
|
92
|
+
graphOptions: GraphOptions,
|
|
93
|
+
onProgress: DeltaBundlerOptions<>['onProgress'],
|
|
94
|
+
}>;
|
|
91
95
|
|
|
92
96
|
export type ModuleGroups = {
|
|
93
97
|
groups: Map<number, Set<number>>,
|