metro 0.76.1 → 0.76.3
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 +21 -23
- package/src/DeltaBundler/Graph.js +6 -19
- package/src/DeltaBundler/Graph.js.flow +8 -15
- package/src/DeltaBundler/Serializers/baseJSBundle.js +1 -0
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +1 -0
- package/src/DeltaBundler/Serializers/helpers/js.js +22 -6
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +24 -6
- package/src/DeltaBundler/Serializers/helpers/processModules.js +2 -0
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -0
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +1 -0
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +1 -0
- package/src/DeltaBundler/types.d.ts +5 -3
- package/src/DeltaBundler/types.flow.js.flow +1 -1
- package/src/HmrServer.js +3 -3
- package/src/HmrServer.js.flow +5 -3
- package/src/IncrementalBundler.js +7 -6
- package/src/IncrementalBundler.js.flow +8 -6
- package/src/Server/symbolicate.js +33 -5
- package/src/Server/symbolicate.js.flow +40 -9
- package/src/Server.js +19 -11
- package/src/Server.js.flow +31 -16
- package/src/index.d.ts +16 -6
- package/src/index.flow.js +15 -2
- package/src/index.flow.js.flow +29 -4
- package/{types/lib/getGraphId.d.ts → src/integration_tests/basic_bundle/loadBundleAsyncForTest.js} +7 -2
- package/src/integration_tests/basic_bundle/loadBundleAsyncForTest.js.flow +20 -0
- package/src/integration_tests/execBundle.js +3 -0
- package/src/integration_tests/execBundle.js.flow +4 -1
- package/src/integration_tests/metro.config.js +5 -0
- package/src/lib/getGraphId.js +2 -7
- package/src/lib/getGraphId.js.flow +3 -3
- package/src/lib/getPrependedScripts.js +1 -2
- package/src/lib/getPrependedScripts.js.flow +1 -2
- package/src/lib/parseOptionsFromUrl.js +1 -0
- package/src/lib/parseOptionsFromUrl.js.flow +1 -0
- package/src/lib/splitBundleOptions.js +1 -0
- package/src/lib/splitBundleOptions.js.flow +1 -0
- package/src/lib/transformHelpers.js +1 -2
- package/src/lib/transformHelpers.js.flow +1 -2
- package/src/node-haste/DependencyGraph.js +6 -1
- package/src/node-haste/DependencyGraph.js.flow +7 -1
- package/src/shared/types.d.ts +2 -0
- package/src/shared/types.flow.js.flow +2 -1
- package/types/Asset.d.ts +0 -25
- package/types/Bundler.d.ts +0 -39
- package/types/DeltaBundler/Graph.d.ts +0 -40
- package/types/DeltaBundler/Serializers/getRamBundleInfo.d.ts +0 -18
- package/types/DeltaBundler/Worker.d.ts +0 -47
- package/types/DeltaBundler/types.d.ts +0 -167
- package/types/DeltaBundler.d.ts +0 -58
- package/types/IncrementalBundler.d.ts +0 -97
- package/types/ModuleGraph/worker/collectDependencies.d.ts +0 -27
- package/types/Server/MultipartResponse.d.ts +0 -31
- package/types/Server.d.ts +0 -113
- package/types/index.d.ts +0 -151
- package/types/lib/CountingSet.d.ts +0 -48
- package/types/lib/TerminalReporter.d.ts +0 -27
- package/types/lib/contextModule.d.ts +0 -22
- package/types/lib/reporting.d.ts +0 -140
- package/types/node-haste/DependencyGraph.d.ts +0 -59
- package/types/shared/output/bundle.d.ts +0 -31
- package/types/shared/types.d.ts +0 -138
package/src/lib/getGraphId.js
CHANGED
|
@@ -15,12 +15,7 @@ const canonicalize = require("metro-core/src/canonicalize");
|
|
|
15
15
|
function getGraphId(
|
|
16
16
|
entryFile,
|
|
17
17
|
options,
|
|
18
|
-
{
|
|
19
|
-
shallow,
|
|
20
|
-
experimentalImportBundleSupport,
|
|
21
|
-
unstable_allowRequireContext,
|
|
22
|
-
resolverOptions,
|
|
23
|
-
}
|
|
18
|
+
{ shallow, lazy, unstable_allowRequireContext, resolverOptions }
|
|
24
19
|
) {
|
|
25
20
|
return JSON.stringify(
|
|
26
21
|
{
|
|
@@ -35,7 +30,7 @@ function getGraphId(
|
|
|
35
30
|
unstable_disableES6Transforms: options.unstable_disableES6Transforms,
|
|
36
31
|
platform: options.platform != null ? options.platform : null,
|
|
37
32
|
type: options.type,
|
|
38
|
-
|
|
33
|
+
lazy,
|
|
39
34
|
unstable_allowRequireContext,
|
|
40
35
|
shallow,
|
|
41
36
|
unstable_transformProfile:
|
|
@@ -23,12 +23,12 @@ function getGraphId(
|
|
|
23
23
|
options: TransformInputOptions,
|
|
24
24
|
{
|
|
25
25
|
shallow,
|
|
26
|
-
|
|
26
|
+
lazy,
|
|
27
27
|
unstable_allowRequireContext,
|
|
28
28
|
resolverOptions,
|
|
29
29
|
}: $ReadOnly<{
|
|
30
30
|
shallow: boolean,
|
|
31
|
-
|
|
31
|
+
lazy: boolean,
|
|
32
32
|
unstable_allowRequireContext: boolean,
|
|
33
33
|
resolverOptions: ResolverInputOptions,
|
|
34
34
|
}>,
|
|
@@ -46,7 +46,7 @@ function getGraphId(
|
|
|
46
46
|
unstable_disableES6Transforms: options.unstable_disableES6Transforms,
|
|
47
47
|
platform: options.platform != null ? options.platform : null,
|
|
48
48
|
type: options.type,
|
|
49
|
-
|
|
49
|
+
lazy,
|
|
50
50
|
unstable_allowRequireContext,
|
|
51
51
|
shallow,
|
|
52
52
|
unstable_transformProfile:
|
|
@@ -57,8 +57,7 @@ async function getPrependedScripts(
|
|
|
57
57
|
config.transformer.unstable_allowRequireContext,
|
|
58
58
|
transformOptions,
|
|
59
59
|
onProgress: null,
|
|
60
|
-
|
|
61
|
-
config.server.experimentalImportBundleSupport,
|
|
60
|
+
lazy: false,
|
|
62
61
|
unstable_enablePackageExports:
|
|
63
62
|
config.resolver.unstable_enablePackageExports,
|
|
64
63
|
shallow: false,
|
|
@@ -67,8 +67,7 @@ async function getPrependedScripts(
|
|
|
67
67
|
config.transformer.unstable_allowRequireContext,
|
|
68
68
|
transformOptions,
|
|
69
69
|
onProgress: null,
|
|
70
|
-
|
|
71
|
-
config.server.experimentalImportBundleSupport,
|
|
70
|
+
lazy: false,
|
|
72
71
|
unstable_enablePackageExports:
|
|
73
72
|
config.resolver.unstable_enablePackageExports,
|
|
74
73
|
shallow: false,
|
|
@@ -45,6 +45,7 @@ module.exports = function parseOptionsFromUrl(requestUrl, platforms) {
|
|
|
45
45
|
excludeSource: getBoolean(query, "excludeSource", false),
|
|
46
46
|
hot: true,
|
|
47
47
|
inlineSourceMap: getBoolean(query, "inlineSourceMap", false),
|
|
48
|
+
lazy: getBoolean(query, "lazy", false),
|
|
48
49
|
minify: getBoolean(query, "minify", false),
|
|
49
50
|
modulesOnly: getBoolean(query, "modulesOnly", false),
|
|
50
51
|
onProgress: null,
|
|
@@ -60,6 +60,7 @@ module.exports = function parseOptionsFromUrl(
|
|
|
60
60
|
excludeSource: getBoolean(query, 'excludeSource', false),
|
|
61
61
|
hot: true,
|
|
62
62
|
inlineSourceMap: getBoolean(query, 'inlineSourceMap', false),
|
|
63
|
+
lazy: getBoolean(query, 'lazy', false),
|
|
63
64
|
minify: getBoolean(query, 'minify', false),
|
|
64
65
|
modulesOnly: getBoolean(query, 'modulesOnly', false),
|
|
65
66
|
onProgress: null,
|
|
@@ -67,8 +67,7 @@ async function calcTransformerOptions(
|
|
|
67
67
|
),
|
|
68
68
|
transformOptions: options,
|
|
69
69
|
onProgress: null,
|
|
70
|
-
|
|
71
|
-
config.server.experimentalImportBundleSupport,
|
|
70
|
+
lazy: false,
|
|
72
71
|
unstable_allowRequireContext:
|
|
73
72
|
config.transformer.unstable_allowRequireContext,
|
|
74
73
|
unstable_enablePackageExports:
|
|
@@ -85,8 +85,7 @@ async function calcTransformerOptions(
|
|
|
85
85
|
),
|
|
86
86
|
transformOptions: options,
|
|
87
87
|
onProgress: null,
|
|
88
|
-
|
|
89
|
-
config.server.experimentalImportBundleSupport,
|
|
88
|
+
lazy: false,
|
|
90
89
|
unstable_allowRequireContext:
|
|
91
90
|
config.transformer.unstable_allowRequireContext,
|
|
92
91
|
unstable_enablePackageExports:
|
|
@@ -105,8 +105,13 @@ class DependencyGraph extends EventEmitter {
|
|
|
105
105
|
_getClosestPackage(filePath) {
|
|
106
106
|
const parsedPath = path.parse(filePath);
|
|
107
107
|
const root = parsedPath.root;
|
|
108
|
-
let dir = parsedPath.dir;
|
|
108
|
+
let dir = path.join(parsedPath.dir, parsedPath.base);
|
|
109
109
|
do {
|
|
110
|
+
// If we've hit a node_modules directory, the closest package was not
|
|
111
|
+
// found (`filePath` was likely nonexistent).
|
|
112
|
+
if (path.basename(dir) === "node_modules") {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
110
115
|
const candidate = path.join(dir, "package.json");
|
|
111
116
|
if (this._fileSystem.exists(candidate)) {
|
|
112
117
|
return candidate;
|
|
@@ -152,8 +152,14 @@ class DependencyGraph extends EventEmitter {
|
|
|
152
152
|
_getClosestPackage(filePath: string): ?string {
|
|
153
153
|
const parsedPath = path.parse(filePath);
|
|
154
154
|
const root = parsedPath.root;
|
|
155
|
-
let dir = parsedPath.dir;
|
|
155
|
+
let dir = path.join(parsedPath.dir, parsedPath.base);
|
|
156
|
+
|
|
156
157
|
do {
|
|
158
|
+
// If we've hit a node_modules directory, the closest package was not
|
|
159
|
+
// found (`filePath` was likely nonexistent).
|
|
160
|
+
if (path.basename(dir) === 'node_modules') {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
157
163
|
const candidate = path.join(dir, 'package.json');
|
|
158
164
|
if (this._fileSystem.exists(candidate)) {
|
|
159
165
|
return candidate;
|
package/src/shared/types.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ export interface BundleOptions {
|
|
|
46
46
|
readonly excludeSource: boolean;
|
|
47
47
|
readonly hot: boolean;
|
|
48
48
|
readonly inlineSourceMap: boolean;
|
|
49
|
+
readonly lazy: boolean;
|
|
49
50
|
minify: boolean;
|
|
50
51
|
readonly modulesOnly: boolean;
|
|
51
52
|
onProgress?: (doneCont: number, totalCount: number) => unknown;
|
|
@@ -73,6 +74,7 @@ export interface SerializerOptions {
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
export interface GraphOptions {
|
|
77
|
+
readonly lazy: boolean;
|
|
76
78
|
readonly shallow: boolean;
|
|
77
79
|
}
|
|
78
80
|
|
|
@@ -50,6 +50,7 @@ export type BundleOptions = {
|
|
|
50
50
|
+excludeSource: boolean,
|
|
51
51
|
+hot: boolean,
|
|
52
52
|
+inlineSourceMap: boolean,
|
|
53
|
+
+lazy: boolean,
|
|
53
54
|
minify: boolean,
|
|
54
55
|
+modulesOnly: boolean,
|
|
55
56
|
onProgress: ?(doneCont: number, totalCount: number) => mixed,
|
|
@@ -60,7 +61,6 @@ export type BundleOptions = {
|
|
|
60
61
|
sourceUrl: ?string,
|
|
61
62
|
createModuleIdFactory?: () => (path: string) => number,
|
|
62
63
|
+unstable_transformProfile: TransformProfile,
|
|
63
|
-
...
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
export type ResolverInputOptions = $ReadOnly<{
|
|
@@ -77,6 +77,7 @@ export type SerializerOptions = {
|
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
export type GraphOptions = {
|
|
80
|
+
+lazy: boolean,
|
|
80
81
|
+shallow: boolean,
|
|
81
82
|
};
|
|
82
83
|
|
package/types/Asset.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @oncall react_native
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export interface AssetDataWithoutFiles {
|
|
12
|
-
readonly __packager_asset: boolean;
|
|
13
|
-
readonly fileSystemLocation: string;
|
|
14
|
-
readonly hash: string;
|
|
15
|
-
readonly height?: number;
|
|
16
|
-
readonly httpServerLocation: string;
|
|
17
|
-
readonly name: string;
|
|
18
|
-
readonly scales: number[];
|
|
19
|
-
readonly type: string;
|
|
20
|
-
readonly width?: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface AssetData extends AssetDataWithoutFiles {
|
|
24
|
-
readonly files: string[];
|
|
25
|
-
}
|
package/types/Bundler.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @oncall react_native
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {TransformResultWithSource} from './DeltaBundler';
|
|
12
|
-
import type {TransformOptions} from './DeltaBundler/Worker';
|
|
13
|
-
import type DependencyGraph from './node-haste/DependencyGraph';
|
|
14
|
-
import type {ConfigT} from 'metro-config';
|
|
15
|
-
import type {EventEmitter} from 'events';
|
|
16
|
-
|
|
17
|
-
export interface BundlerOptions {
|
|
18
|
-
readonly hasReducedPerformance?: boolean;
|
|
19
|
-
readonly watch?: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default class Bundler {
|
|
23
|
-
constructor(config: ConfigT, options?: BundlerOptions);
|
|
24
|
-
|
|
25
|
-
getWatcher(): EventEmitter;
|
|
26
|
-
|
|
27
|
-
end(): Promise<void>;
|
|
28
|
-
|
|
29
|
-
getDependencyGraph(): Promise<DependencyGraph>;
|
|
30
|
-
|
|
31
|
-
transformFile(
|
|
32
|
-
filePath: string,
|
|
33
|
-
transformOptions: TransformOptions,
|
|
34
|
-
/** Optionally provide the file contents, this can be used to provide virtual contents for a file. */
|
|
35
|
-
fileBuffer?: Buffer,
|
|
36
|
-
): Promise<TransformResultWithSource<void>>;
|
|
37
|
-
|
|
38
|
-
ready(): Promise<void>;
|
|
39
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @oncall react_native
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {
|
|
12
|
-
Dependencies,
|
|
13
|
-
GraphInputOptions,
|
|
14
|
-
MixedOutput,
|
|
15
|
-
Module,
|
|
16
|
-
Options,
|
|
17
|
-
TransformInputOptions,
|
|
18
|
-
} from './types';
|
|
19
|
-
|
|
20
|
-
export interface Result<T> {
|
|
21
|
-
added: Map<string, Module<T>>;
|
|
22
|
-
modified: Map<string, Module<T>>;
|
|
23
|
-
deleted: Set<string>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export class Graph<T = MixedOutput> {
|
|
27
|
-
entryPoints: ReadonlySet<string>;
|
|
28
|
-
transformOptions: TransformInputOptions;
|
|
29
|
-
dependencies: Dependencies<T>;
|
|
30
|
-
constructor(options: GraphInputOptions);
|
|
31
|
-
traverseDependencies(
|
|
32
|
-
paths: ReadonlyArray<string>,
|
|
33
|
-
options: Options<T>,
|
|
34
|
-
): Promise<Result<T>>;
|
|
35
|
-
initialTraverseDependencies(options: Options<T>): Promise<Result<T>>;
|
|
36
|
-
markModifiedContextModules(
|
|
37
|
-
filePath: string,
|
|
38
|
-
modifiedPaths: Set<string>,
|
|
39
|
-
): void;
|
|
40
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @oncall react_native
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import {ModuleTransportLike} from '../../shared/types';
|
|
12
|
-
|
|
13
|
-
export interface RamBundleInfo {
|
|
14
|
-
getDependencies: (filePath: string) => Set<string>;
|
|
15
|
-
startupModules: Readonly<ModuleTransportLike>;
|
|
16
|
-
lazyModules: Readonly<ModuleTransportLike>;
|
|
17
|
-
groups: Map<number, Set<number>>;
|
|
18
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @oncall react_native
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {
|
|
12
|
-
JsTransformerConfig,
|
|
13
|
-
JsTransformOptions,
|
|
14
|
-
} from 'metro-transform-worker';
|
|
15
|
-
import type {TransformResult} from './types';
|
|
16
|
-
|
|
17
|
-
type LogEntry = unknown;
|
|
18
|
-
|
|
19
|
-
export type TransformOptions = JsTransformOptions;
|
|
20
|
-
|
|
21
|
-
declare function transform(
|
|
22
|
-
filename: string,
|
|
23
|
-
transformOptions: JsTransformOptions,
|
|
24
|
-
projectRoot: string,
|
|
25
|
-
transformerConfig: TransformerConfig,
|
|
26
|
-
fileBuffer?: Buffer,
|
|
27
|
-
): Promise<Data>;
|
|
28
|
-
|
|
29
|
-
export interface Worker {
|
|
30
|
-
readonly transform: typeof transform;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface TransformerConfig {
|
|
34
|
-
transformerPath: string;
|
|
35
|
-
transformerConfig: JsTransformerConfig;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
interface Data {
|
|
39
|
-
readonly result: TransformResult<void>;
|
|
40
|
-
readonly sha1: string;
|
|
41
|
-
readonly transformFileStartLogEntry: LogEntry;
|
|
42
|
-
readonly transformFileEndLogEntry: LogEntry;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
declare const worker: Worker;
|
|
46
|
-
|
|
47
|
-
export default worker;
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @oncall react_native
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {SourceLocation} from '@babel/code-frame';
|
|
12
|
-
import type {JsTransformOptions} from 'metro-transform-worker';
|
|
13
|
-
import type {RequireContextParams} from '../ModuleGraph/worker/collectDependencies';
|
|
14
|
-
import type {RequireContext} from '../lib/contextModule';
|
|
15
|
-
import type CountingSet from '../lib/CountingSet';
|
|
16
|
-
import type {Graph} from './Graph';
|
|
17
|
-
|
|
18
|
-
export interface MixedOutput {
|
|
19
|
-
readonly data: {code: string};
|
|
20
|
-
readonly type: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type AsyncDependencyType = 'async' | 'prefetch';
|
|
24
|
-
|
|
25
|
-
export interface TransformResultDependency {
|
|
26
|
-
/**
|
|
27
|
-
* The literal name provided to a require or import call. For example 'foo' in
|
|
28
|
-
* case of `require('foo')`.
|
|
29
|
-
*/
|
|
30
|
-
readonly name: string;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Extra data returned by the dependency extractor.
|
|
34
|
-
*/
|
|
35
|
-
readonly data: {
|
|
36
|
-
/**
|
|
37
|
-
* A locally unique key for this dependency within the current module.
|
|
38
|
-
*/
|
|
39
|
-
readonly key: string;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* If not null, this dependency is due to a dynamic `import()` or `__prefetchImport()` call.
|
|
43
|
-
*/
|
|
44
|
-
readonly asyncType: AsyncDependencyType | null;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* The condition for splitting on this dependency edge.
|
|
48
|
-
*/
|
|
49
|
-
readonly splitCondition?: {
|
|
50
|
-
readonly mobileConfigName: string;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* The dependency is enclosed in a try/catch block.
|
|
55
|
-
*/
|
|
56
|
-
readonly isOptional?: boolean;
|
|
57
|
-
|
|
58
|
-
readonly locs: ReadonlyArray<SourceLocation>;
|
|
59
|
-
|
|
60
|
-
/** Context for requiring a collection of modules. */
|
|
61
|
-
readonly contextParams?: RequireContextParams;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface Dependency {
|
|
66
|
-
readonly absolutePath: string;
|
|
67
|
-
readonly data: TransformResultDependency;
|
|
68
|
-
[key: string]: unknown;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface Module<T = MixedOutput> {
|
|
72
|
-
readonly dependencies: Map<string, Dependency>;
|
|
73
|
-
readonly inverseDependencies: CountingSet<string>;
|
|
74
|
-
readonly output: ReadonlyArray<T>;
|
|
75
|
-
readonly path: string;
|
|
76
|
-
readonly getSource: () => Buffer;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export type Dependencies<T = MixedOutput> = Map<string, Module<T>>;
|
|
80
|
-
export type ReadOnlyDependencies<T = MixedOutput> = ReadonlyMap<
|
|
81
|
-
string,
|
|
82
|
-
Module<T>
|
|
83
|
-
>;
|
|
84
|
-
|
|
85
|
-
export type TransformInputOptions = Omit<
|
|
86
|
-
JsTransformOptions,
|
|
87
|
-
'inlinePlatform' | 'inlineRequires'
|
|
88
|
-
>;
|
|
89
|
-
|
|
90
|
-
export type GraphInputOptions = Readonly<{
|
|
91
|
-
entryPoints: ReadonlySet<string>;
|
|
92
|
-
// Unused in core but useful for custom serializers / experimentalSerializerHook
|
|
93
|
-
transformOptions: TransformInputOptions;
|
|
94
|
-
}>;
|
|
95
|
-
|
|
96
|
-
export interface ReadOnlyGraph<T = MixedOutput> {
|
|
97
|
-
readonly entryPoints: ReadonlySet<string>;
|
|
98
|
-
// Unused in core but useful for custom serializers / experimentalSerializerHook
|
|
99
|
-
readonly transformOptions: Readonly<TransformInputOptions>;
|
|
100
|
-
readonly dependencies: ReadOnlyDependencies<T>;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export type {Graph};
|
|
104
|
-
|
|
105
|
-
export interface TransformResult<T = MixedOutput> {
|
|
106
|
-
dependencies: ReadonlyArray<TransformResultDependency>;
|
|
107
|
-
output: ReadonlyArray<T>;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export interface TransformResultWithSource<T = MixedOutput>
|
|
111
|
-
extends TransformResult<T> {
|
|
112
|
-
getSource: () => Buffer;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export type TransformFn<T = MixedOutput> = (
|
|
116
|
-
modulePath: string,
|
|
117
|
-
requireContext: RequireContext | null,
|
|
118
|
-
) => Promise<TransformResultWithSource<T>>;
|
|
119
|
-
|
|
120
|
-
export interface AllowOptionalDependenciesWithOptions {
|
|
121
|
-
readonly exclude: string[];
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export type AllowOptionalDependencies =
|
|
125
|
-
| boolean
|
|
126
|
-
| AllowOptionalDependenciesWithOptions;
|
|
127
|
-
|
|
128
|
-
export interface BundlerResolution {
|
|
129
|
-
readonly type: 'sourceFile';
|
|
130
|
-
readonly filePath: string;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export interface Options<T = MixedOutput> {
|
|
134
|
-
readonly resolve: (from: string, to: string) => string;
|
|
135
|
-
readonly transform: TransformFn<T>;
|
|
136
|
-
readonly transformOptions: TransformInputOptions;
|
|
137
|
-
readonly onProgress:
|
|
138
|
-
| ((numProcessed: number, total: number) => unknown)
|
|
139
|
-
| null;
|
|
140
|
-
readonly experimentalImportBundleSupport: boolean;
|
|
141
|
-
readonly unstable_allowRequireContext: boolean;
|
|
142
|
-
readonly shallow: boolean;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export interface DeltaResult<T = MixedOutput> {
|
|
146
|
-
readonly added: Map<string, Module<T>>;
|
|
147
|
-
readonly modified: Map<string, Module<T>>;
|
|
148
|
-
readonly deleted: Set<string>;
|
|
149
|
-
readonly reset: boolean;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export interface SerializerOptions<T = MixedOutput> {
|
|
153
|
-
readonly asyncRequireModulePath: string;
|
|
154
|
-
readonly createModuleId: (filePath: string) => number;
|
|
155
|
-
readonly dev: boolean;
|
|
156
|
-
readonly getRunModuleStatement: (moduleId: string | number) => string;
|
|
157
|
-
readonly includeAsyncPaths: boolean;
|
|
158
|
-
readonly inlineSourceMap?: boolean;
|
|
159
|
-
readonly modulesOnly: boolean;
|
|
160
|
-
readonly processModuleFilter: (module: Module<T>) => boolean;
|
|
161
|
-
readonly projectRoot: string;
|
|
162
|
-
readonly runBeforeMainModule: ReadonlyArray<string>;
|
|
163
|
-
readonly runModule: boolean;
|
|
164
|
-
readonly serverRoot: string;
|
|
165
|
-
readonly sourceMapUrl?: string;
|
|
166
|
-
readonly sourceUrl?: string;
|
|
167
|
-
}
|
package/types/DeltaBundler.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @oncall react_native
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {
|
|
12
|
-
DeltaResult,
|
|
13
|
-
Graph,
|
|
14
|
-
MixedOutput,
|
|
15
|
-
Options,
|
|
16
|
-
ReadOnlyGraph,
|
|
17
|
-
} from './DeltaBundler/types';
|
|
18
|
-
import type {EventEmitter} from 'events';
|
|
19
|
-
|
|
20
|
-
export type {
|
|
21
|
-
DeltaResult,
|
|
22
|
-
Graph,
|
|
23
|
-
Dependencies,
|
|
24
|
-
MixedOutput,
|
|
25
|
-
Module,
|
|
26
|
-
ReadOnlyGraph,
|
|
27
|
-
TransformFn,
|
|
28
|
-
TransformResult,
|
|
29
|
-
TransformResultDependency,
|
|
30
|
-
TransformResultWithSource,
|
|
31
|
-
} from './DeltaBundler/types';
|
|
32
|
-
|
|
33
|
-
export default class DeltaBundler<T = MixedOutput> {
|
|
34
|
-
constructor(changeEventSource: EventEmitter);
|
|
35
|
-
end(): void;
|
|
36
|
-
getDependencies(
|
|
37
|
-
entryPoints: ReadonlyArray<string>,
|
|
38
|
-
options: Options<T>,
|
|
39
|
-
): Promise<ReadOnlyGraph<T>['dependencies']>;
|
|
40
|
-
buildGraph(
|
|
41
|
-
entryPoints: ReadonlyArray<string>,
|
|
42
|
-
options: Options<T>,
|
|
43
|
-
): Promise<Graph<T>>;
|
|
44
|
-
|
|
45
|
-
getDelta(
|
|
46
|
-
graph: Graph<T>,
|
|
47
|
-
{
|
|
48
|
-
reset,
|
|
49
|
-
shallow,
|
|
50
|
-
}: {
|
|
51
|
-
reset: boolean;
|
|
52
|
-
shallow: boolean;
|
|
53
|
-
},
|
|
54
|
-
): Promise<DeltaResult<T>>;
|
|
55
|
-
|
|
56
|
-
listen(graph: Graph<T>, callback: () => Promise<void>): () => void;
|
|
57
|
-
endGraph(graph: Graph<T>): void;
|
|
58
|
-
}
|