Compiles a single Avenx component file into a usable class.
Avenx component files are not JavaScript modules. A .component.js holds
<state>, <action> and template markup, and only means anything after the
compiler has turned it into a class. So a test cannot import one — which
is a problem for generated regression tests, whose whole purpose is to mount
the component a trace was recorded against.
This runs the same ComponentParser the build uses on one file and
evaluates the class it emits. Because it is the real compiler, a generated
test exercises the same code the application ships, not a hand-written
approximation of it.
Lives under tooling/ rather than testing/ because it reads from disk:
the house rule is that fs and path stay out of anything the browser
runtime can reach.
- Source:
Methods
(static) bridgeDependencies(filePath) → {Array:.<string:>}
Lists the bridges a component file imports.
A component that imports a bridge compiles to a class that references a binding the bundle supplies. Loading such a component outside a bundle means supplying those bindings, so a caller needs to know which are wanted.
Parameters:
| Name | Type | Description |
|---|---|---|
filePath |
string | Path to the component or page file. |
- Source:
Returns:
Bridge names, e.g. ['cart', 'auth'].
(static) classNameFor(filePath) → {string}
Derives the class name the compiler will emit for a component file.
Parameters:
| Name | Type | Description |
|---|---|---|
filePath |
string | Path to the component or page file. |
- Source:
Returns:
The PascalCase class name.
- Type
- string
(static) loadComponent(filePath, optionsopt) → {function}
Compiles a component or page file and returns the class.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
filePath |
string | Absolute or cwd-relative path to the file. |
|||||||||||||||||
options |
object |
<optional> |
Compilation options. Properties
|
- Source:
Throws:
-
When the file does not exist, does not compile to a class, or imports a bridge that was not supplied.
- Type
- Error
Returns:
The compiled component or page class.
- Type
- function