https://github.com/jamen/pull-bundle-js
Bundle JS files inside pull-stream
https://github.com/jamen/pull-bundle-js
Last synced: 9 months ago
JSON representation
Bundle JS files inside pull-stream
- Host: GitHub
- URL: https://github.com/jamen/pull-bundle-js
- Owner: jamen
- License: mit
- Created: 2017-05-08T09:44:46.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-07T23:26:43.000Z (almost 9 years ago)
- Last Synced: 2024-04-29T11:42:29.415Z (about 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 27.3 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# pull-bundle-js
> Bundle JS files inside pull-stream with Browserify
Bundles the [js pull-stream files](https://github.com/jamen/pull-files) using [Browserify](https://github.com/substack/node-browserify)
```js
var pull = require('pull-stream')
var { read, write } = require('pull-files')
var bundle = require('pull-bundle-js')
pull(
read([ 'index.js', 'lib/**/*.js' ], { cwd: __dirname }),
bundle('app.js', ['babelify', 'es2040']),
write('out', err => {
// finished
})
)
```
## Install
```sh
npm i pull-bundle-js
```
## Usage
### `bundle(path?, options?)`
Bundles commonjs files using [Browserify](https://github.com/substack/node-browserify) to use commonjs modules and several Node.js built-ins on the browser
The `options` are passed to [`browserify(options)`](https://www.npmjs.com/package/browserify#browserifyfiles--opts), in addition to:
- `path`: Path of the resulting bundle. Optional if the path will never be used (e.g. goes into HTML directly after)
- `strict`: Only allow files with `.js` to pass through. Defaults to `false`
You can also pass `options` as an array as a shorthand for `transforms: [ ...options ]`
## Also see
- [`pull-files`](https://npmjs.com/pull-files) for reading and writing files
- [`pull-bundle-html`](https://github.com/jamen/pull-bundle-html) put your JS and CSS into a boilerplate HTML file
- [`pull-minify-js`](https://github.com/jamen/pull-minify-js) to minify it