Pass transformOptions to getShallowDependencies.

Summary:We weren't passing `transformOptions` to `getShallowDependencies`, and therefore, when this method was called on a module, it would bust the cache and cause a retransform of the file. This was resulting in a complete retransforming of all files when the HMR Client connected to the packager.
Closes https://github.com/facebook/react-native/pull/6843

Differential Revision: D3145306

Pulled By: martinbigio

fb-gh-sync-id: 3619c27801b2fc07b758fafed47fcc892bb8e6db
fbshipit-source-id: 3619c27801b2fc07b758fafed47fcc892bb8e6db
This commit is contained in:
Adam Miskiewicz 2016-04-06 11:36:57 -07:00 committed by Facebook Github Bot 0
parent 27e79ff0c3
commit 65b0f7c868
3 changed files with 38 additions and 6 deletions

View File

@ -426,8 +426,33 @@ class Bundler {
this._cache.invalidate(filePath);
}
getShallowDependencies(entryFile) {
return this._resolver.getShallowDependencies(entryFile);
getShallowDependencies({
entryFile,
platform,
dev = true,
minify = !dev,
hot = false,
generateSourceMaps = false,
}) {
return this.getTransformOptions(
entryFile,
{
dev,
platform,
hot,
generateSourceMaps,
projectRoots: this._projectRoots,
},
).then(transformSpecificOptions => {
const transformOptions = {
minify,
dev,
platform,
transform: transformSpecificOptions,
};
return this._resolver.getShallowDependencies(entryFile, transformOptions);
});
}
stat(filePath) {

View File

@ -120,8 +120,8 @@ class Resolver {
});
}
getShallowDependencies(entryFile) {
return this._depGraph.getShallowDependencies(entryFile);
getShallowDependencies(entryFile, transformOptions) {
return this._depGraph.getShallowDependencies(entryFile, transformOptions);
}
stat(filePath) {

View File

@ -254,8 +254,15 @@ class Server {
return this._bundler.hmrBundle(modules, host, port);
}
getShallowDependencies(entryFile) {
return this._bundler.getShallowDependencies(entryFile);
getShallowDependencies(options) {
return Promise.resolve().then(() => {
if (!options.platform) {
options.platform = getPlatformExtension(options.entryFile);
}
const opts = dependencyOpts(options);
return this._bundler.getShallowDependencies(opts);
});
}
getModuleForPath(entryFile) {