BREAKING: Bump metro-bundler to v0.21.0

Summary:
`metro-bundler` v0.21 contains a rewritten bundling mechanism, with simplified logic and much faster rebuild times, called delta bundler. This release contains a couple of breaking changes:

* Now, when using a custom transformer, the list of additional babel plugins to apply are passed to the `transform()` method. These are used in non-dev mode for optimization purposes (Check 367a5f5db8 (diff-40653f0c822ac59a5af13d5b4ab31d84) to see how to handle them from the transformer).
* Now, when using a custom transformer outputting `rawMappings`, the transformer does not need to call the `compactMappings` method before returning (check d74685fd1d (diff-40653f0c822ac59a5af13d5b4ab31d84) for more info).
* We've removed support for two config parameters: `postProcessModules` and `postProcessBundleSourcemap`.

Reviewed By: davidaurelio

Differential Revision: D6186035

fbshipit-source-id: 242c5c2a954c6b9b6f339d345f888eaa44704579
This commit is contained in:
Rafael Oleza
2017-11-08 09:07:41 -08:00
committed by Facebook Github Bot
parent 963c61d4d5
commit 0bbd9f042a
5 changed files with 28 additions and 42 deletions

View File

@@ -48,16 +48,7 @@ const {ASSET_REGISTRY_PATH} = require('../core/Constants');
import type {RequestOptions, OutputOptions} from './types.flow';
import type {ConfigT} from 'metro-bundler';
function saveBundle(output, bundle, args) {
return Promise.resolve(
/* $FlowFixMe(>=0.56.0 site=react_native_oss) This comment suppresses an
* error found when Flow v0.56 was deployed. To see the error delete this
* comment and run Flow. */
output.save(bundle, args, log)
).then(() => bundle);
}
function buildBundle(
async function buildBundle(
args: OutputOptions & {
assetsDest: mixed,
entryFile: string,
@@ -129,7 +120,6 @@ function buildBundle(
sourceExts: defaultSourceExts.concat(sourceExts),
transformCache: TransformCaching.useTempDir(),
transformModulePath: transformModulePath,
useDeltaBundler: false,
watch: false,
workerPath: config.getWorkerPath && config.getWorkerPath(),
};
@@ -138,26 +128,27 @@ function buildBundle(
shouldClosePackager = true;
}
const bundlePromise = output.build(packagerInstance, requestOpts)
.then(bundle => {
if (shouldClosePackager) {
packagerInstance.end();
}
return saveBundle(output, bundle, args);
});
const bundle = await output.build(packagerInstance, requestOpts);
await output.save(bundle, args, log);
// Save the assets of the bundle
const assets = bundlePromise
// TODO: Use the packager.getAssets() method to get the bundle assets.
// $FlowFixMe: This code is going away.
.then(bundle => bundle.getAssets && bundle.getAssets())
.then(outputAssets => outputAssets && saveAssets(
outputAssets,
args.platform,
args.assetsDest,
));
const outputAssets = await packagerInstance.getAssets({
...Server.DEFAULT_BUNDLE_OPTIONS,
...requestOpts,
});
// When we're done saving bundle output and the assets, we're done.
const assets = await saveAssets(
outputAssets,
args.platform,
args.assetsDest,
);
if (shouldClosePackager) {
packagerInstance.end();
}
return assets;
}