transform before extracting dependencies

Summary:Make packager transform files before extracting their dependencies.

This allows us to extract dependencies added by transforms (and to avoid including them manually).

It also allows for better optimization and to get rid of the “whole program optimization” step:
This diff utilizes the new worker introduced in D2976677 / d94a567 – that means that minified builds inline the following variables:

- `__DEV__` → `false`
- `process.env.NODE_ENV` → `'production'`
- `Platform.OS` / `React.Platform.OS` → `'android'` / `'ios'`

and eliminates branches of conditionals with constant conditions. Dependency extraction happens only after that step, which means that production bundles don’t include any modules that are not used.

Fixes #4185

Reviewed By: martinbigio

Differential Revision: D2977169

fb-gh-sync-id: e6ce8dd29d1b49aec49b309201141f5b2709da1d
shipit-source-id: e6ce8dd29d1b49aec49b309201141f5b2709da1d
This commit is contained in:
David Aurelio
2016-03-08 09:50:14 -08:00
committed by Facebook Github Bot 0
parent 87c26885a3
commit 9d09efdd53
31 changed files with 622 additions and 2101 deletions

View File

@@ -17,14 +17,10 @@ function buildBundle(packagerClient, requestOptions) {
}
function createCodeWithMap(bundle, dev) {
if (!dev) {
return bundle.getMinifiedSourceAndMap(dev);
} else {
return {
code: bundle.getSource({dev}),
map: JSON.stringify(bundle.getSourceMap({dev})),
};
}
return {
code: bundle.getSource({dev}),
map: JSON.stringify(bundle.getSourceMap({dev})),
};
}
function saveBundleAndMap(bundle, options, log) {
@@ -53,7 +49,6 @@ function saveBundleAndMap(bundle, options, log) {
}
}
exports.build = buildBundle;
exports.save = saveBundleAndMap;
exports.formatName = 'bundle';