Skip to content

Commit 15006cf

Browse files
martinbigiofacebook-github-bot-0
authored andcommitted
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
1 parent 47e791f commit 15006cf

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

local-cli/bundle/__tests__/saveBundleAndMap-test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ describe('saveBundleAndMap', () => {
4141
saveBundleAndMap(
4242
codeWithMap,
4343
'ios',
44-
bundleOutput
44+
bundleOutput,
45+
'utf8',
4546
);
4647

47-
expect(fs.writeFileSync.mock.calls[0]).toEqual([bundleOutput, code]);
48+
expect(fs.writeFileSync.mock.calls[0]).toEqual([bundleOutput, code, 'utf8']);
4849
});
4950

5051
it('should save sourcemaps if required so', () => {
@@ -55,6 +56,7 @@ describe('saveBundleAndMap', () => {
5556
codeWithMap,
5657
'ios',
5758
bundleOutput,
59+
'utf8',
5860
sourceMapOutput
5961
);
6062

local-cli/bundle/buildBundle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ function buildBundle(args, config) {
4949
outputBundle,
5050
args.platform,
5151
args['bundle-output'],
52+
args['bundle-encoding'],
5253
args['sourcemap-output'],
5354
args['assets-dest']
5455
));

local-cli/bundle/bundleCommandLineArgs.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ module.exports = [
3232
description: 'File name where to store the resulting bundle, ex. /tmp/groups.bundle',
3333
type: 'string',
3434
required: true,
35+
}, {
36+
command: 'bundle-encoding',
37+
description: 'Encoding the bundle should be written in (https://nodejs.org/api/buffer.html#buffer_buffer).',
38+
type: 'string',
39+
default: 'utf8',
3540
}, {
3641
command: 'sourcemap-output',
3742
description: 'File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map',

local-cli/bundle/saveBundleAndMap.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ function saveBundleAndMap(
2020
codeWithMap,
2121
platform,
2222
bundleOutput,
23+
encoding,
2324
sourcemapOutput,
2425
assetsDest
2526
) {
2627
log('Writing bundle output to:', bundleOutput);
27-
fs.writeFileSync(bundleOutput, sign(codeWithMap.code));
28+
fs.writeFileSync(bundleOutput, sign(codeWithMap.code), encoding);
2829
log('Done writing bundle output');
2930

3031
if (sourcemapOutput) {

0 commit comments

Comments
 (0)