mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-25 21:05:40 +08:00
Clean up Bundler
Summary: The bundler class had duplicated code and parts that were hard to follow, because functions accepted heterogenous arguments, leading to a lot of conditionals. This commit tries to remove duplication between build steps of different type of bundles, and by accepting less different types of arguments. These differences are now handled further up the call stack. public Reviewed By: sebmarkbage Differential Revision: D2905807 fb-gh-sync-id: ef85ea0d461a9a06a4a64480e014a5324c4ef532
This commit is contained in:
committed by
facebook-github-bot-7
parent
4937a4c5cd
commit
6b74535e97
@@ -137,10 +137,7 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
||||
}).then(response => {
|
||||
const module = packagerServer.getModuleForPath(filename);
|
||||
|
||||
return {
|
||||
modulesToUpdate: [module],
|
||||
resolutionResponse: response,
|
||||
};
|
||||
return response.copy({dependencies: [module]});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -170,13 +167,12 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
||||
client.dependenciesModulesCache = dependenciesModulesCache;
|
||||
client.shallowDependencies = shallowDependencies;
|
||||
|
||||
return {
|
||||
modulesToUpdate,
|
||||
resolutionResponse,
|
||||
};
|
||||
return resolutionResponse.copy({
|
||||
dependencies: modulesToUpdate
|
||||
});
|
||||
});
|
||||
})
|
||||
.then(({modulesToUpdate, resolutionResponse}) => {
|
||||
.then((resolutionResponse) => {
|
||||
if (!client) {
|
||||
return;
|
||||
}
|
||||
@@ -189,9 +185,8 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
||||
return packagerServer.buildBundleForHMR({
|
||||
entryFile: client.bundleEntry,
|
||||
platform: client.platform,
|
||||
modules: modulesToUpdate,
|
||||
resolutionResponse,
|
||||
})
|
||||
});
|
||||
})
|
||||
.then(bundle => {
|
||||
if (!client || !bundle || bundle.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user