Skip to content

Commit f9d80a4

Browse files
davidaurelioFacebook Github Bot
authored and
Facebook Github Bot
committed
Bring back programmatic packager API
Summary: Brings back parts of the programmatic API removed in 7762f37. This is used by a few people. Also updates the docs accordingly. cc akaila Reviewed By: jeanlauliac Differential Revision: D4226348 fbshipit-source-id: e5c0794f9c5415f14b54d16c6f35f902eafc3064
1 parent 8016d83 commit f9d80a4

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

packager/README.md

+19-14
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,11 @@ ReactPackager is how you mainly interact with the API.
9090
var ReactPackager = require('./react-packager');
9191
```
9292

93-
### ReactPackager.middleware(options)
93+
### ReactPackager.buildBundle(serverOptions, bundleOptions)
9494

95-
Returns a function that can be used in a connect-like
96-
middleware. Takes the following options:
95+
Builds a bundle according to the provided options.
96+
97+
#### `serverOptions`
9798

9899
* `projectRoots` array (required): Is the roots where your JavaScript
99100
file will exist
@@ -109,21 +110,25 @@ middleware. Takes the following options:
109110
* `nonPersistent` boolean, defaults to false: Whether the server
110111
should be used as a persistent deamon to watch files and update
111112
itself
112-
* `assetRoots` array: Where should the packager look for assets
113113
* `getTransformOptionsModulePath` string: Path to module that exports a function
114114
that acts as a middleware for generating options to pass to the transformer
115-
based on the bundle and module being transformed.
116-
117-
### ReactPackager.buildPackageFromUrl(options, url)
118-
119-
Build a package from a url (see the `.bundle` endpoint). `options` is
120-
the same options that is passed to `ReactPackager.middleware`
115+
based on the bundle being built.
121116

122-
### ReactPackager.getDependencies(options, main)
117+
#### `bundleOptions`
123118

124-
Given an entry point module. Recursively collect all the dependent
125-
modules and return it as an array. `options` is the same options that
126-
is passed to `ReactPackager.middleware`
119+
* `entryFile` string (required): the entry file of the bundle, relative to one
120+
of the asset roots.
121+
* `dev` boolean (defaults to `true`): sets a global `__DEV__` variable
122+
which will effect how the React Native core libraries behave.
123+
* `minify` boolean: Whether to minify code and apply production optimizations.
124+
* `runModule` boolean (defaults to `true`): whether to require your entry
125+
point module.
126+
* `inlineSourceMap` boolean, defaults to false: whether to inline
127+
source maps.
128+
* `platform` string: The target platform for the build
129+
* `generateSourceMaps` boolean: Whether to generate source maps.
130+
* `sourceMapUrl` string: The url of the source map (will be appended to
131+
the bundle).
127132

128133
## Debugging
129134

packager/react-packager/index.js

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ const Logger = require('./src/Logger');
1515

1616
exports.createServer = createServer;
1717
exports.Logger = Logger;
18+
19+
exports.buildBundle = function(options, bundleOptions) {
20+
var server = createNonPersistentServer(options);
21+
return server.buildBundle(bundleOptions)
22+
.then(p => {
23+
server.end();
24+
return p;
25+
});
26+
};
27+
1828
exports.getOrderedDependencyPaths = function(options, bundleOptions) {
1929
var server = createNonPersistentServer(options);
2030
return server.getOrderedDependencyPaths(bundleOptions)

0 commit comments

Comments
 (0)