mirror of https://github.com/status-im/metro.git
Support passing multiple entryPoints to the public buildGraph() method
Reviewed By: mjesun Differential Revision: D7365288 fbshipit-source-id: 1d1b94858d2ad31307157839808b9a6c01c00365
This commit is contained in:
parent
d0fdca73cd
commit
d54a7044f2
|
@ -59,7 +59,10 @@ import type {MetroSourceMap} from 'metro-source-map';
|
|||
import type {TransformCache} from '../lib/TransformCaching';
|
||||
import type {Symbolicate} from './symbolicate/symbolicate';
|
||||
import type {AssetData} from '../Assets';
|
||||
import type {TransformedCode} from '../JSTransformer/worker';
|
||||
import type {
|
||||
CustomTransformOptions,
|
||||
TransformedCode,
|
||||
} from '../JSTransformer/worker';
|
||||
const {
|
||||
Logger: {createActionStartEntry, createActionEndEntry, log},
|
||||
} = require('metro-core');
|
||||
|
@ -73,6 +76,18 @@ type GraphInfo = {|
|
|||
+sequenceId: string,
|
||||
|};
|
||||
|
||||
type BuildGraphOptions = {|
|
||||
+assetPlugins: Array<string>,
|
||||
+customTransformOptions: CustomTransformOptions,
|
||||
+dev: boolean,
|
||||
+entryFiles: $ReadOnlyArray<string>,
|
||||
+hot: boolean,
|
||||
+minify: boolean,
|
||||
+onProgress: ?(doneCont: number, totalCount: number) => mixed,
|
||||
+platform: ?string,
|
||||
+type: 'module' | 'script',
|
||||
|};
|
||||
|
||||
type DeltaOptions = BundleOptions & {
|
||||
deltaBundleId: ?string,
|
||||
};
|
||||
|
@ -269,22 +284,19 @@ class Server {
|
|||
};
|
||||
}
|
||||
|
||||
async buildGraph(options: BundleOptions): Promise<Graph> {
|
||||
const entryPoint = getAbsolutePath(
|
||||
options.entryFile,
|
||||
this._opts.projectRoots,
|
||||
);
|
||||
|
||||
async buildGraph(options: BuildGraphOptions): Promise<Graph> {
|
||||
return await this._deltaBundler.buildGraph({
|
||||
assetPlugins: options.assetPlugins,
|
||||
customTransformOptions: options.customTransformOptions,
|
||||
dev: options.dev,
|
||||
entryPoints: [entryPoint],
|
||||
entryPoints: options.entryFiles.map(entryFile =>
|
||||
getAbsolutePath(entryFile, this._opts.projectRoots),
|
||||
),
|
||||
hot: options.hot,
|
||||
minify: options.minify,
|
||||
onProgress: options.onProgress,
|
||||
platform: options.platform,
|
||||
type: 'module',
|
||||
type: options.type,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1123,20 +1135,24 @@ class Server {
|
|||
return this._opts.projectRoots;
|
||||
}
|
||||
|
||||
static DEFAULT_BUNDLE_OPTIONS = {
|
||||
static DEFAULT_GRAPH_OPTIONS = {
|
||||
assetPlugins: [],
|
||||
customTransformOptions: Object.create(null),
|
||||
dev: true,
|
||||
entryModuleOnly: false,
|
||||
excludeSource: false,
|
||||
hot: false,
|
||||
inlineSourceMap: false,
|
||||
minify: false,
|
||||
onProgress: null,
|
||||
type: 'module',
|
||||
};
|
||||
|
||||
static DEFAULT_BUNDLE_OPTIONS = {
|
||||
...Server.DEFAULT_GRAPH_OPTIONS,
|
||||
entryModuleOnly: false,
|
||||
excludeSource: false,
|
||||
inlineSourceMap: false,
|
||||
runBeforeMainModule: [],
|
||||
runModule: true,
|
||||
sourceMapUrl: null,
|
||||
type: 'script',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ exports.runServer = async ({
|
|||
|
||||
type BuildGraphOptions = {|
|
||||
...PublicMetroOptions,
|
||||
entry: string,
|
||||
entries: $ReadOnlyArray<string>,
|
||||
dev?: boolean,
|
||||
onProgress?: (transformedFileCount: number, totalFileCount: number) => void,
|
||||
platform?: string,
|
||||
|
@ -287,10 +287,12 @@ type BuildGraphOptions = {|
|
|||
|
||||
type RunBuildOptions = {|
|
||||
...PublicMetroOptions,
|
||||
...BuildGraphOptions,
|
||||
entry: string,
|
||||
dev?: boolean,
|
||||
out: string,
|
||||
onBegin?: () => void,
|
||||
onComplete?: () => void,
|
||||
onProgress?: (transformedFileCount: number, totalFileCount: number) => void,
|
||||
optimize?: boolean,
|
||||
output?: {
|
||||
build: (
|
||||
|
@ -303,6 +305,7 @@ type RunBuildOptions = {|
|
|||
(...args: Array<string>) => void,
|
||||
) => Promise<mixed>,
|
||||
},
|
||||
platform?: string,
|
||||
sourceMap?: boolean,
|
||||
sourceMapUrl?: string,
|
||||
|};
|
||||
|
@ -377,7 +380,7 @@ exports.runBuild = async ({
|
|||
exports.buildGraph = async function({
|
||||
config,
|
||||
dev = false,
|
||||
entry,
|
||||
entries,
|
||||
onProgress,
|
||||
platform = `web`,
|
||||
...rest
|
||||
|
@ -390,10 +393,9 @@ exports.buildGraph = async function({
|
|||
|
||||
try {
|
||||
return await metroServer.buildGraph({
|
||||
...MetroServer.DEFAULT_BUNDLE_OPTIONS,
|
||||
bundleType: 'graph',
|
||||
...MetroServer.DEFAULT_GRAPH_OPTIONS,
|
||||
dev,
|
||||
entryFile: entry,
|
||||
entryFiles: entries,
|
||||
onProgress,
|
||||
platform,
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue