mirror of https://github.com/status-im/metro.git
Metro HMR: Add file parameter to getShallowDependencies()
Reviewed By: jeanlauliac Differential Revision: D5687991 fbshipit-source-id: c2db3986c6a5ec81ed1350ded92dfcf1b529c2bc
This commit is contained in:
parent
679309987b
commit
50ef3138cf
|
@ -6,6 +6,7 @@
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
|
* @emails oncall+javascript_tools
|
||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -167,7 +168,9 @@ describe('Bundler', function() {
|
||||||
|
|
||||||
it('gets the list of dependencies from the resolver', function() {
|
it('gets the list of dependencies from the resolver', function() {
|
||||||
const entryFile = '/root/foo.js';
|
const entryFile = '/root/foo.js';
|
||||||
return bundler.getDependencies({entryFile, recursive: true}).then(() =>
|
return bundler
|
||||||
|
.getDependencies({entryFile, rootEntryFile: entryFile, recursive: true})
|
||||||
|
.then(() =>
|
||||||
// jest calledWith does not support jasmine.any
|
// jest calledWith does not support jasmine.any
|
||||||
expect(getDependencies.mock.calls[0].slice(0, -2)).toEqual([
|
expect(getDependencies.mock.calls[0].slice(0, -2)).toEqual([
|
||||||
'/root/foo.js',
|
'/root/foo.js',
|
||||||
|
|
|
@ -481,6 +481,7 @@ class Bundler {
|
||||||
if (!resolutionResponse) {
|
if (!resolutionResponse) {
|
||||||
resolutionResponse = this.getDependencies({
|
resolutionResponse = this.getDependencies({
|
||||||
entryFile,
|
entryFile,
|
||||||
|
rootEntryFile: entryFile,
|
||||||
dev,
|
dev,
|
||||||
platform,
|
platform,
|
||||||
hot,
|
hot,
|
||||||
|
@ -565,6 +566,7 @@ class Bundler {
|
||||||
|
|
||||||
getShallowDependencies({
|
getShallowDependencies({
|
||||||
entryFile,
|
entryFile,
|
||||||
|
rootEntryFile,
|
||||||
platform,
|
platform,
|
||||||
dev = true,
|
dev = true,
|
||||||
minify = !dev,
|
minify = !dev,
|
||||||
|
@ -572,13 +574,14 @@ class Bundler {
|
||||||
generateSourceMaps = false,
|
generateSourceMaps = false,
|
||||||
}: {
|
}: {
|
||||||
entryFile: string,
|
entryFile: string,
|
||||||
|
+rootEntryFile: string,
|
||||||
platform: ?string,
|
platform: ?string,
|
||||||
dev?: boolean,
|
dev?: boolean,
|
||||||
minify?: boolean,
|
minify?: boolean,
|
||||||
hot?: boolean,
|
hot?: boolean,
|
||||||
generateSourceMaps?: boolean,
|
generateSourceMaps?: boolean,
|
||||||
}): Promise<Array<Module>> {
|
}): Promise<Array<Module>> {
|
||||||
return this.getTransformOptions(entryFile, {
|
return this.getTransformOptions(rootEntryFile, {
|
||||||
enableBabelRCLookup: this._opts.enableBabelRCLookup,
|
enableBabelRCLookup: this._opts.enableBabelRCLookup,
|
||||||
dev,
|
dev,
|
||||||
generateSourceMaps,
|
generateSourceMaps,
|
||||||
|
@ -608,6 +611,7 @@ class Bundler {
|
||||||
recursive = true,
|
recursive = true,
|
||||||
generateSourceMaps = false,
|
generateSourceMaps = false,
|
||||||
isolateModuleIDs = false,
|
isolateModuleIDs = false,
|
||||||
|
rootEntryFile,
|
||||||
onProgress,
|
onProgress,
|
||||||
}: {
|
}: {
|
||||||
entryFile: string,
|
entryFile: string,
|
||||||
|
@ -618,10 +622,11 @@ class Bundler {
|
||||||
recursive?: boolean,
|
recursive?: boolean,
|
||||||
generateSourceMaps?: boolean,
|
generateSourceMaps?: boolean,
|
||||||
isolateModuleIDs?: boolean,
|
isolateModuleIDs?: boolean,
|
||||||
|
+rootEntryFile: string,
|
||||||
onProgress?: ?(finishedModules: number, totalModules: number) => mixed,
|
onProgress?: ?(finishedModules: number, totalModules: number) => mixed,
|
||||||
}): Promise<ResolutionResponse<Module, BundlingOptions>> {
|
}): Promise<ResolutionResponse<Module, BundlingOptions>> {
|
||||||
const bundlingOptions: BundlingOptions = await this.getTransformOptions(
|
const bundlingOptions: BundlingOptions = await this.getTransformOptions(
|
||||||
entryFile,
|
rootEntryFile,
|
||||||
{
|
{
|
||||||
enableBabelRCLookup: this._opts.enableBabelRCLookup,
|
enableBabelRCLookup: this._opts.enableBabelRCLookup,
|
||||||
dev,
|
dev,
|
||||||
|
@ -659,6 +664,7 @@ class Bundler {
|
||||||
}) {
|
}) {
|
||||||
return this.getDependencies({
|
return this.getDependencies({
|
||||||
entryFile,
|
entryFile,
|
||||||
|
rootEntryFile: entryFile,
|
||||||
dev,
|
dev,
|
||||||
platform,
|
platform,
|
||||||
minify,
|
minify,
|
||||||
|
@ -864,9 +870,11 @@ class Bundler {
|
||||||
|},
|
|},
|
||||||
): Promise<BundlingOptions> {
|
): Promise<BundlingOptions> {
|
||||||
const getDependencies = (entryFile: string) =>
|
const getDependencies = (entryFile: string) =>
|
||||||
this.getDependencies({...options, entryFile}).then(r =>
|
this.getDependencies({
|
||||||
r.dependencies.map(d => d.path),
|
...options,
|
||||||
);
|
entryFile,
|
||||||
|
rootEntryFile: entryFile,
|
||||||
|
}).then(r => r.dependencies.map(d => d.path));
|
||||||
|
|
||||||
const {dev, hot, platform} = options;
|
const {dev, hot, platform} = options;
|
||||||
const extraOptions: ExtraTransformOptions = this._getTransformOptions
|
const extraOptions: ExtraTransformOptions = this._getTransformOptions
|
||||||
|
|
|
@ -123,6 +123,7 @@ type DependencyOptions = {|
|
||||||
+minify: boolean,
|
+minify: boolean,
|
||||||
+platform: ?string,
|
+platform: ?string,
|
||||||
+recursive: boolean,
|
+recursive: boolean,
|
||||||
|
+rootEntryFile: string,
|
||||||
|};
|
|};
|
||||||
|
|
||||||
type BuildInfo = {|
|
type BuildInfo = {|
|
||||||
|
@ -340,9 +341,10 @@ class Server {
|
||||||
options.platform != null
|
options.platform != null
|
||||||
? options.platform
|
? options.platform
|
||||||
: parsePlatformFilePath(options.entryFile, this._platforms).platform;
|
: parsePlatformFilePath(options.entryFile, this._platforms).platform;
|
||||||
const {entryFile, dev, minify, hot} = options;
|
const {entryFile, dev, minify, hot, rootEntryFile} = options;
|
||||||
return this._bundler.getShallowDependencies({
|
return this._bundler.getShallowDependencies({
|
||||||
entryFile,
|
entryFile,
|
||||||
|
rootEntryFile,
|
||||||
platform,
|
platform,
|
||||||
dev,
|
dev,
|
||||||
minify,
|
minify,
|
||||||
|
@ -364,7 +366,7 @@ class Server {
|
||||||
options.platform != null
|
options.platform != null
|
||||||
? options.platform
|
? options.platform
|
||||||
: parsePlatformFilePath(options.entryFile, this._platforms).platform;
|
: parsePlatformFilePath(options.entryFile, this._platforms).platform;
|
||||||
const {entryFile, dev, minify, hot} = options;
|
const {entryFile, dev, minify, hot, rootEntryFile} = options;
|
||||||
return this._bundler.getDependencies({
|
return this._bundler.getDependencies({
|
||||||
entryFile,
|
entryFile,
|
||||||
platform,
|
platform,
|
||||||
|
@ -372,6 +374,7 @@ class Server {
|
||||||
minify,
|
minify,
|
||||||
hot,
|
hot,
|
||||||
generateSourceMaps: false,
|
generateSourceMaps: false,
|
||||||
|
rootEntryFile,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -634,6 +637,7 @@ class Server {
|
||||||
hot,
|
hot,
|
||||||
minify,
|
minify,
|
||||||
entryFile: options.entryFile,
|
entryFile: options.entryFile,
|
||||||
|
rootEntryFile: options.entryFile,
|
||||||
recursive: false,
|
recursive: false,
|
||||||
}),
|
}),
|
||||||
Promise.all(Array.from(outdated, this.getModuleForPath, this)),
|
Promise.all(Array.from(outdated, this.getModuleForPath, this)),
|
||||||
|
|
Loading…
Reference in New Issue