@shadow-js/compiler
The 42 exports of @shadow-js/compiler: 4 functions, 1 class, 33 interfaces and 4 types.
Everything @shadow-js/compiler exports, from the TSDoc of its entry point.
Functions#
compile: Compiles the JSX in a module into calls to the ShadowJS runtime, with the fastest implementation this machine has: the Rust addon (about ten times faster on large apps), else the same code as WebAssembly, else the TypeScript implementation.compileAsync: Compiles a module without blocking the event loop: the Rust implementation runs on a worker thread of the process and the promise settles with what compile would have returned or thrown.getBackend: Tells which implementation compile uses on this machine, loading it if it was not loaded yet.validatePlugins: Checks a list of compiler plugins and returns it as a frozen copy.
Classes#
CompileError: Thrown by compile for source the compiler cannot or refuses to transform.
Interfaces#
BackendInfo: Which implementation runs the compiler.CallExpressionNode: A call such asf(a, b).CompileOptions: Options of compile.CompileResult: What compile returns.CompilerPlugin: A compiler plugin: a build-time function over the tree of one module.Diagnostic: A located problem in a source module, carried by CompileError (and typed forCompileResult.diagnostics).IdentifierNode: An identifier reference, binding or property name.ImportDeclarationNode: Animportdeclaration.JSXAttributeNode: A JSX attribute such asclass="a"oronClick={f}.JSXElementNode: A JSX element.JSXExpressionContainerNode: A{}container in JSX, as an attribute value or a child.JSXFragmentNode: A JSX fragment<>...</>.JSXIdentifierNode: A JSX tag name that is a plain word (div,Button).JSXMemberExpressionNode: A JSX tag name with a dot (Foo.Bar).JSXNamespacedNameNode: A JSX name with a namespace (xlink:href).JSXOpeningElementNode: The opening tag of a JSX element, with its attributes.JSXSpreadAttributeNode: A spread attribute{...props}.JSXTextNode: Text between JSX tags.LiteralNode: A string, number, boolean,null, bigint or regular expression literal.MemberExpressionNode: A member access such asa.bora[b].NodeFactory: Builds source text for the edits of a plugin.NodeMap: The node types with a typed interface, by name.ObjectExpressionNode: An object literal.PluginContext: What a plugin gets with the tree: facts about the compilation, reporting, the walk, and the edits.PluginDiagnostic: A finding of a plugin.PluginImport: An import a plugin adds to the modules it changes.PluginNode: A syntax tree node: ESTree plus the JSX nodes of the parser.PluginRange: A span of PluginContext.source: a PluginNode, or any object withstartandend.ProgramNode: The root of a module's tree.PropertyNode: Akey: valuemember of an object literal.TemplateElementNode: One chunk of a template literal.TemplateLiteralNode: A template literal such as`a${b}c`.VisitorEntry: Enter and leave callbacks for one node type.
Types#
PluginStage: When a plugin runs:"pre"on the tree of the source, before every compiler pass,"post"on the tree of the generated code.Target: Which kind of output compile produces:"dom"for browser rendering (also used to hydrate server markup) and"ssr"for server rendering to strings.Visit: A visitor function: called with the node and its parent (nullfor the node the walk started at).Visitor: What PluginContext.walk takes: a function or an enter/leave pair for the node types of NodeMap, and an untypedenterandleavefor every node.