Core Script Plugin
A staticbolt core plugin that teaches the engine how to handle JavaScript and TypeScript files. The engine itself has no built-in knowledge of script files. This plugin extends the metadata system to support them by implementing loading, cloning, stringifying, and source resolution.
Supported extensions
.js, .mjs, .cjs, .jsx, .ts, .mts, .cts, .tsx
What this plugin provides
Loading. When the engine encounters a file with a supported extension, this plugin parses it into a Babel AST and returns a script metadata object. You can also load inline code directly by passing it alongside a file path.
Cloning. Produces a deep copy of a script metadata object, including a structural clone of the Babel AST. Changes to the copy do not affect the original.
Stringifying. Converts the Babel AST back to a code string using Babel's code generator. It can also format or minify the output, depending on the options passed.
Source resolution. Walks the AST to find every import, export, import(), and new URL statement and exposes them as readable and writable source references. Other plugins and the engine use those to rewrite import paths during rebasing and resolution.
Installation
The plugin ships as part of @staticbolt/core. You do not need to install anything else.
Usage
In your .staticbolt.ts configuration file:
import { defineConfig } from "@staticbolt/core";import { coreScriptPlugin } from "@staticbolt/core/plugins";
export default defineConfig({ plugins: [coreScriptPlugin()],});The default staticbolt pipeline already includes this plugin. Add it yourself only when you are assembling a custom pipeline and need to replace or reorder core plugins.