Module: lib/bundler

The Avenx bundler: resolve, link, shake, emit.

The boundary this file sits on

The compiler owns everything Avenx-specific — template compilation, declaration processing, expression handling, Atlas, scoped CSS, the shape of a generated component class. It hands the bundler modules: some virtual (the classes it just generated), the rest real files on disk.

The bundler owns everything module-specific — resolution, npm packages, the dependency graph, dead-code elimination, format interop, the final script and its source map. It knows nothing about components, bridges or pages, and it must stay that way: the moment the bundler needs to know what a .page.js is, the two halves have grown back together.

Why Avenx has its own

The same reason it has its own HTML tokenizer, its own expression parser and its own reference scanner: the build is dependency-free by policy. A bundler is a graph walk, a reachability analysis and a code generator, and each of those is a few hundred lines when it only has to serve one compiler.

Source:

Methods

(static) bundle(options) → {Object}

Bundles an application from one or more entry modules.

Parameters:
Name Type Description
options object

Bundle options.

Properties
Name Type Attributes Description
entries Array:.<string:>

Entry specifiers or absolute paths.

virtualModules Map:.<string:, string:> <optional>

Generated module id to source.

rootDir string

The project root, for relative paths.

treeShake boolean <optional>

Drop modules nothing needs. Default true.

entryNeeds Map:.<string:, Array:.<string:>> <optional>

Export names an entry's consumer requires, so a footer that reads the entry namespace keeps it.

minify boolean <optional>

Strip comments and indentation. Default false.

sourceMap boolean <optional>

Emit a source map. Default false.

banner string <optional>

Text before the bundle.

footer string <optional>

Text after the bundle.

file string <optional>

Output file name, used in the source map.

Source:
Throws:

When the application does not link.

Type
ResolveError | BindingError | EmitError | ModuleParseError
Returns:

The bundle and what it contains.

Type
Object