mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 12:45:37 +08:00
Add option to indicate bundle encoding
Summary: public To improve cold start performance we want to be able to avoid decoding the bundle at all. To make that happen we need to be able to generate a bundle encoded on `ucs2`. This diff adds support for indicating the encoding the Packager should use for bundling. Reviewed By: davidaurelio Differential Revision: D2582365 fb-gh-sync-id: 905384272a668910c57a1a2ca6d1b723c39233f8
This commit is contained in:
committed by
facebook-github-bot-0
parent
47e791fa3b
commit
15006cf0b4
@@ -41,10 +41,11 @@ describe('saveBundleAndMap', () => {
|
|||||||
saveBundleAndMap(
|
saveBundleAndMap(
|
||||||
codeWithMap,
|
codeWithMap,
|
||||||
'ios',
|
'ios',
|
||||||
bundleOutput
|
bundleOutput,
|
||||||
|
'utf8',
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(fs.writeFileSync.mock.calls[0]).toEqual([bundleOutput, code]);
|
expect(fs.writeFileSync.mock.calls[0]).toEqual([bundleOutput, code, 'utf8']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should save sourcemaps if required so', () => {
|
it('should save sourcemaps if required so', () => {
|
||||||
@@ -55,6 +56,7 @@ describe('saveBundleAndMap', () => {
|
|||||||
codeWithMap,
|
codeWithMap,
|
||||||
'ios',
|
'ios',
|
||||||
bundleOutput,
|
bundleOutput,
|
||||||
|
'utf8',
|
||||||
sourceMapOutput
|
sourceMapOutput
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ function buildBundle(args, config) {
|
|||||||
outputBundle,
|
outputBundle,
|
||||||
args.platform,
|
args.platform,
|
||||||
args['bundle-output'],
|
args['bundle-output'],
|
||||||
|
args['bundle-encoding'],
|
||||||
args['sourcemap-output'],
|
args['sourcemap-output'],
|
||||||
args['assets-dest']
|
args['assets-dest']
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ module.exports = [
|
|||||||
description: 'File name where to store the resulting bundle, ex. /tmp/groups.bundle',
|
description: 'File name where to store the resulting bundle, ex. /tmp/groups.bundle',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
|
}, {
|
||||||
|
command: 'bundle-encoding',
|
||||||
|
description: 'Encoding the bundle should be written in (https://nodejs.org/api/buffer.html#buffer_buffer).',
|
||||||
|
type: 'string',
|
||||||
|
default: 'utf8',
|
||||||
}, {
|
}, {
|
||||||
command: 'sourcemap-output',
|
command: 'sourcemap-output',
|
||||||
description: 'File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map',
|
description: 'File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map',
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ function saveBundleAndMap(
|
|||||||
codeWithMap,
|
codeWithMap,
|
||||||
platform,
|
platform,
|
||||||
bundleOutput,
|
bundleOutput,
|
||||||
|
encoding,
|
||||||
sourcemapOutput,
|
sourcemapOutput,
|
||||||
assetsDest
|
assetsDest
|
||||||
) {
|
) {
|
||||||
log('Writing bundle output to:', bundleOutput);
|
log('Writing bundle output to:', bundleOutput);
|
||||||
fs.writeFileSync(bundleOutput, sign(codeWithMap.code));
|
fs.writeFileSync(bundleOutput, sign(codeWithMap.code), encoding);
|
||||||
log('Done writing bundle output');
|
log('Done writing bundle output');
|
||||||
|
|
||||||
if (sourcemapOutput) {
|
if (sourcemapOutput) {
|
||||||
|
|||||||
Reference in New Issue
Block a user