unbundle
Version:
`require()` and `import`/`export` in the browser, without the bundling
66 lines (51 loc) • 1.66 kB
Markdown
and ES2015 Modules syntax to load in the browser *without* bundling everything into a single file.
```
Usage: unbundle [options]
Options:
-i, --entry Starting file for the application. Defaults to package.json
"main" field.
-o, --destination Directory to write output. Defaults to "./public".
Nonexistent directories are automatically created.
-s, --silent Suppress log messages from output[boolean] [default: false]
-w, --watch Monitor files and rebuild on changes
[ ] [default: false]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Examples:
unbundle -i src/app.js -o dist Transpiles the app and its dependencies into
the "dist" directory.
```
`package.json`
```json
{
"main": "app.js"
}
```
`app.js`
```jsx
import React from 'react'
import ReactDOM from 'react-dom'
class MyComponent extends React.Component {
render () {
return <div>Hello World</div>
}
}
ReactDOM.render(<MyComponent />, document.body)
```
`public/index.html`
```html
<script src="system.js"></script>
<script>System.import('./app.js')</script>
```
Run the command:
```bash
unbundle
```
Serve up the generated files using your favourite static webserver. Ideally use a webserver with sufficiently intelligeny HTTP/2 Server Push support.
```bash
http-server -o
```
A browser opens to reveal your *hello world* masterpiece!
Unbundle transforms CommonJS