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 (Check367a5f5db8 (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 (checkd74685fd1d (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:
parent
963c61d4d5
commit
0bbd9f042a
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,7 @@ function escapePath(pathname) {
|
|||
return '"' + pathname + '"';
|
||||
}
|
||||
|
||||
function launchDevTools(
|
||||
{port, projectRoots, useDeltaBundler},
|
||||
isChromeConnected,
|
||||
) {
|
||||
function launchDevTools({port, projectRoots}, isChromeConnected) {
|
||||
// Explicit config always wins
|
||||
var customDebugger = process.env.REACT_DEBUGGER;
|
||||
if (customDebugger) {
|
||||
|
@ -42,7 +39,7 @@ function launchDevTools(
|
|||
});
|
||||
} else if (!isChromeConnected()) {
|
||||
// Dev tools are not yet open; we need to open a session
|
||||
launchChromeDevTools(port, useDeltaBundler ? '#useDeltaBundler' : '');
|
||||
launchChromeDevTools(port);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,12 +17,15 @@ require('../../setupBabel')();
|
|||
* found when Flow v0.54 was deployed. To see the error delete this comment and
|
||||
* run Flow. */
|
||||
const ReactPackager = require('metro-bundler');
|
||||
|
||||
const HmrServer = require('metro-bundler/src/HmrServer');
|
||||
|
||||
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
|
||||
* found when Flow v0.54 was deployed. To see the error delete this comment and
|
||||
* run Flow. */
|
||||
const Terminal = require('metro-bundler/src/lib/Terminal');
|
||||
|
||||
const attachHMRServer = require('./util/attachHMRServer');
|
||||
const attachWebsocketServer = require('./util/attachWebsocketServer');
|
||||
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
|
||||
* found when Flow v0.54 was deployed. To see the error delete this comment and
|
||||
* run Flow. */
|
||||
|
@ -131,10 +134,10 @@ function runServer(
|
|||
: http.createServer(app);
|
||||
|
||||
serverInstance.listen(args.port, args.host, 511, function() {
|
||||
attachHMRServer({
|
||||
attachWebsocketServer({
|
||||
httpServer: serverInstance,
|
||||
path: '/hot',
|
||||
packagerServer,
|
||||
websocketServer: new HmrServer(packagerServer, reporter),
|
||||
});
|
||||
|
||||
wsProxy = webSocketProxy.attachToServer(serverInstance, '/debugger-proxy');
|
||||
|
@ -200,7 +203,6 @@ function getPackagerServer(args, config, reporter) {
|
|||
sourceExts: defaultSourceExts.concat(args.sourceExts),
|
||||
transformModulePath: transformModulePath,
|
||||
transformCache: TransformCaching.useTempDir(),
|
||||
useDeltaBundler: false,
|
||||
verbose: args.verbose,
|
||||
watch: !args.nonPersistent,
|
||||
workerPath: config.getWorkerPath(),
|
||||
|
|
|
@ -206,10 +206,6 @@
|
|||
connectToDebuggerProxy();
|
||||
|
||||
async function getBlobUrl(url) {
|
||||
if (window.location.hash.indexOf('useDeltaBundler') === -1) {
|
||||
return url;
|
||||
}
|
||||
|
||||
return await window.deltaUrlToBlobUrl(url.replace('.bundle', '.delta'));
|
||||
}
|
||||
})();
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
"graceful-fs": "^4.1.3",
|
||||
"inquirer": "^3.0.6",
|
||||
"lodash": "^4.16.6",
|
||||
"metro-bundler": "^0.20.0",
|
||||
"metro-bundler": "^0.21.0",
|
||||
"mime": "^1.3.4",
|
||||
"minimist": "^1.2.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
|
@ -216,4 +216,4 @@
|
|||
"shelljs": "^0.7.8",
|
||||
"sinon": "^2.2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue