Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Commit

Permalink
Update README.md to use Builder class
Browse files Browse the repository at this point in the history
  • Loading branch information
crisptrutski authored and guybedford committed Feb 12, 2015
1 parent d813f21 commit a31194f
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ Usage

```javascript
var path = require("path");
var builder = require('systemjs-builder');
var Builder = require('systemjs-builder');
var builder = new Builder();

builder.build('myModule', 'outfile.js', {
config: {
Expand Down Expand Up @@ -73,17 +74,15 @@ System.config({ ... });
Then we can load this config file through the builder:

```javascript
var builder = require('systemjs-builder');

// `builder.loadConfig` will load config from a file
builder.loadConfig('./cfg.js')
.then(function() {
// additional config can also be set through `builder.config`
builder.config({ baseURL: 'file:' + process.cwd() });

return builder.build('myModule', 'outfile.js');
});

```

Multiple config calls can be run, which will combine into the loader configuration.
Expand All @@ -96,7 +95,6 @@ To reset the loader state and configuration for a new build, run `builder.reset(
To make a bundle that is independent of the SystemJS loader entirely, we can make SFX bundles:

```javascript
var builder = require('systemjs-builder');
builder.buildSFX('myModule', 'outfile.js', options);
```

Expand All @@ -116,7 +114,6 @@ jquery.js
As well as an `options.config` parameter, it is also possible to specify minification and source maps options:

```javascript
var builder = require('systemjs-builder');
builder.build('myModule', 'outfile.js', { minify: true, sourceMaps: true, config: cfg });
```

Expand All @@ -129,7 +126,6 @@ Compile time with source maps can also be improved with the `lowResSourceMaps` o
If you want minification without mangling, you can set the config like this:

```javascript
var builder = require('systemjs-builder');
builder.build('myModule', 'outfile.js', { minify: true, mangle: false });
```

Expand Down Expand Up @@ -157,7 +153,8 @@ Tree operations include `addTrees`, `subtractTrees`, `intersectTrees` and `extra
In this example we build `app/core` excluding `app/corelibs`:

```javascript
var builder = require('systemjs-builder');
var Builder = require('systemjs-builder');
var builder = new Builder();

builder.config({
baseURL: '...',
Expand All @@ -168,7 +165,7 @@ In this example we build `app/core` excluding `app/corelibs`:

builder.trace('app/main')
.then(function(appTrace) {

return builder.trace('app/corelibs')
.then(function(coreTrace) {
return builder.subtractTrees(appTrace.tree, coreTrace.tree);
Expand All @@ -184,7 +181,8 @@ In this example we build `app/core` excluding `app/corelibs`:
In this example we build `app/first` and `app/second` creating a separate `app/shared` library:

```javascript
var builder = require('systemjs-builder');
var Builder = require('systemjs-builder');
var builder = new Builder();

builder.config({
// ...
Expand All @@ -195,7 +193,7 @@ In this example we build `app/first` and `app/second` creating a separate `app/s
builder.trace('app/first')
.then(function(trace) {
firstTree = trace.tree;

return builder.trace('app/second');
})
.then(function(trace) {
Expand All @@ -221,4 +219,4 @@ License
MIT

[travis-url]: https://travis-ci.org/systemjs/builder
[travis-image]: https://travis-ci.org/systemjs/builder.svg?branch=master
[travis-image]: https://travis-ci.org/systemjs/builder.svg?branch=master

0 comments on commit a31194f

Please sign in to comment.