Skip to content

Commit a102e6f

Browse files
martinbigiofacebook-github-bot-9
authored andcommitted
Breaking change: Move bundle to private-cli
Summary: @​public We need to start using the `private-cli` for the new asset system. Note this is a breaking change! People will have to upgrade their workflows/scripts to start using the new cli. Otherwise we'd need to build a thin adapter that is aware of both APIs which is something we;d like to avoid. The major API changes are: - API is now `entry-file` based instead of `url` based. - /s/--out/--bundle-output - /s/--out/--sourcemap-output Also these parameters have no longer default values, you need to specify them. For instance, if you want to generate the sourcemaps you need to pass in the `--sourcemap-output` option Lastly, additional project roots or asset roots need to be specified on the `rn-cli.config.js`. Reviewed By: @frantic Differential Revision: D2533877 fb-gh-sync-id: a45f9095fdf9442a9106ea7bb6a6b7f651d25273
1 parent 793c356 commit a102e6f

File tree

7 files changed

+27
-18
lines changed

7 files changed

+27
-18
lines changed

breaking-changes.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Breaking Changes
2+
3+
## 0.14
4+
5+
- D2530161: Need to introduce rn-cli.config.js for existing projects
6+
- D2533877: `react-native bundle` API changes:
7+
- API is now `entry-file <path>` based instead of url based.
8+
- Need to specify which platform you're bundling for `--platform <ios|android>`.
9+
- Option `--out` has been renamed for `--bundle-output`.
10+
- Source maps are no longer automatically generated. Need to specify `--sourcemap-output <path>` option to indicate where to put the source maps.

breaking-changes.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

cli.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/**
22
* Copyright (c) 2015-present, Facebook, Inc.
33
* All rights reserved.
44
*
@@ -8,4 +8,8 @@
88
*/
99
'use strict';
1010

11+
require('./packager/babelRegisterOnly')([
12+
/private-cli\/src/
13+
]);
14+
1115
module.exports = require('./local-cli/cli.js');

local-cli/cli.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
'use strict';
66

7+
var bundle = require('../private-cli/src/bundle/bundle');
8+
var bundle_DEPRECATED = require('./bundle.js');
9+
var Config = require('../private-cli/src/util/Config');
710
var fs = require('fs');
8-
var spawn = require('child_process').spawn;
9-
var path = require('path');
1011
var generateAndroid = require('./generate-android.js');
1112
var init = require('./init.js');
1213
var install = require('./install.js');
13-
var bundle = require('./bundle.js');
1414
var newLibrary = require('./new-library.js');
1515
var runAndroid = require('./run-android.js');
1616
var runPackager = require('./run-packager.js');
@@ -51,7 +51,8 @@ function run() {
5151
install.init();
5252
break;
5353
case 'bundle':
54-
bundle.init(args);
54+
bundle(args, Config.get(__dirname)).done();
55+
// bundle_DEPRECATED.init(args);
5556
break;
5657
case 'new-library':
5758
newLibrary.init(args);

local-cli/generator/templates/rn-cli.config.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@ var blacklist = require('./node_modules/react-native/packager/blacklist');
44

55
var config = {
66
getProjectRoots() {
7-
return this._getRoots();
7+
return [__dirname];
88
},
99

1010
getAssetRoots() {
11-
return this._getRoots();
11+
// speficy where to look for assets
12+
return [];
1213
},
1314

14-
getBlacklistRE() {
15-
return blacklist('');
15+
getBlacklistRE(platform) {
16+
return blacklist(platform);
1617
},
1718

1819
getTransformModulePath() {
1920
return require.resolve('./node_modules/react-native/packager/transformer');
20-
},
21-
22-
_getRoots() {
23-
return [__dirname];
2421
}
2522
};
2623

private-cli/src/bundle/bundle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function _bundle(argv, config, resolve, reject) {
6363
const options = {
6464
projectRoots: config.getProjectRoots(),
6565
assetRoots: config.getAssetRoots(),
66-
blacklistRE: config.getBlacklistRE(),
66+
blacklistRE: config.getBlacklistRE(args.platform),
6767
transformModulePath: config.getTransformModulePath(),
6868
};
6969

private-cli/src/dependencies/dependencies.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function _dependencies(argv, config, resolve, reject) {
5050
const packageOpts = {
5151
projectRoots: config.getProjectRoots(),
5252
assetRoots: config.getAssetRoots(),
53-
blacklistRE: config.getBlacklistRE(),
53+
blacklistRE: config.getBlacklistRE(args.platform),
5454
transformModulePath: config.getTransformModulePath(),
5555
};
5656

0 commit comments

Comments
 (0)