normalize-build

Higher-level builder for Normalize

Usage no npm install needed!

<script type="module">
  import normalizeBuild from 'https://cdn.skypack.dev/normalize-build';
</script>

README

Normalize Build

NPM version

Dependency Status License Downloads Gittip

High level builder for normalize using with normalize-builder and file-watch. The JS API is as close to nlz-build(1)'s API as possible.

  • Automatically includes the require() implementation
  • Automatically executes the entry point - require(boot)
  • Automatically watch for file changes and reuilbd

API

var Build = require('normalize-build')

var builder = Build(options)

builder = Build(options)

Pretty much all the same as the other libraries.

  • directory: 'repositories' - directory to install all the remote dependencies
  • agent - a normalize-agent instance

builder.add(entrypoint, options)

Add an entry point. Must be an absolute URI.

JavaScript options:

  • require: true - include the require() implementation
  • autorequire: true - automatically execute the entry point

builder.watch()

Run as a watcher. The process remains open, and the entry points will automatically rebuild on file changes.

var text = yield* builder.build(entrypoint)

Build a specific entry point. Returns the result as a string.

var results[] = yield* builder.build()

Without an entrypoint, .build() will build all the entry points in the order defined. If you forget, check .entrypoints.

Event: tree

Every time the tree is resolved.

build.on('tree', function (tree, ms) {
  console.log('built tree in: ' + ms + 'ms')
})

Event: <entrypoint>

Every time an entry point is built, an event by its name will be built.

build.on('/User/jong/index.js', function (js) {
  fs.writeFile('/User/jong/build/index.js', js)
})

Note

If you don't use .watch(), you should just use builder.build(), then options.agent.close() to close the connection to the server. Otherwise, the process will never exit.