UNPKG

@storm-stack/core

Version:

A build toolkit and runtime used by Storm Software in TypeScript applications

57 lines (55 loc) 2.06 kB
import { Engine } from './chunk-7U3POOTC.js'; import { getSourceFile } from './chunk-K4ZS2URJ.js'; import { createLog } from './chunk-RDCOIWVB.js'; import { __name } from './chunk-43IZMM3W.js'; import { getWorkspaceConfig } from '@storm-software/config-tools/get-config'; import { LogLevelLabel } from '@storm-software/config-tools/types'; import { createUnplugin } from 'unplugin'; var unpluginFactory = /* @__PURE__ */ __name((userConfig) => { const log = createLog("unplugin", userConfig); log(LogLevelLabel.TRACE, "Initializing Unplugin"); try { const inlineConfig = { ...userConfig, command: "build" }; let workspaceConfig; let engine; let context; async function buildStart() { log(LogLevelLabel.TRACE, "Build Starting"); workspaceConfig = await getWorkspaceConfig(); engine = new Engine(inlineConfig, workspaceConfig); log(LogLevelLabel.TRACE, "Initializing Storm Stack..."); context = await engine.init(inlineConfig); log(LogLevelLabel.TRACE, "Prepare Storm Stack project..."); await engine.prepare(inlineConfig); } __name(buildStart, "buildStart"); async function transform(code, id) { log(LogLevelLabel.TRACE, "Running Transform"); return context.compiler.getResult(getSourceFile(id, code), await context.compiler.compile(context, id, code)); } __name(transform, "transform"); async function writeBundle() { log(LogLevelLabel.TRACE, "Finalizing Storm Stack project..."); await engine.finalize(inlineConfig); } __name(writeBundle, "writeBundle"); return { name: "storm-stack", enforce: "pre", transform, buildStart, writeBundle }; } catch (error) { log(LogLevelLabel.ERROR, error); throw error; } }, "unpluginFactory"); var StormStack = /* @__PURE__ */ createUnplugin(unpluginFactory); var unplugin_default = StormStack; export { StormStack, unpluginFactory, unplugin_default }; //# sourceMappingURL=chunk-M75WBRNS.js.map //# sourceMappingURL=chunk-M75WBRNS.js.map