@storm-stack/core
Version:
A build toolkit and runtime used by Storm Software in TypeScript applications
1 lines • 5.44 kB
Source Map (JSON)
{"version":3,"sources":["../../src/unplugin/index.ts"],"names":["unpluginFactory","userConfig","log","createLog","LogLevelLabel","TRACE","inlineConfig","command","workspaceConfig","engine","context","buildStart","getWorkspaceConfig","Engine","init","prepare","transform","code","id","compiler","getResult","getSourceFile","compile","writeBundle","finalize","name","enforce","error","ERROR","StormStack"],"mappings":";;;;;;;;;;AAqCO,IAAMA,eAAAA,6CACXC,UAAAA,KAAAA;AAEA,EAAA,MAAMC,GAAAA,GAAMC,2BAAAA,CAAU,UAAA,EAAYF,UAAAA,CAAAA;AAClCC,EAAAA,GAAAA,CAAIE,mBAAAA,CAAcC,OAAO,uBAAA,CAAA;AAEzB,EAAA,IAAI;AACF,IAAA,MAAMC,YAAAA,GAAe;MACnB,GAAGL,UAAAA;MACHM,OAAAA,EAAS;AACX,KAAA;AAEA,IAAA,IAAIC,eAAAA;AACJ,IAAA,IAAIC,MAAAA;AACJ,IAAA,IAAIC,OAAAA;AAEJ,IAAA,eAAeC,UAAAA,GAAAA;AACbT,MAAAA,GAAAA,CAAIE,mBAAAA,CAAcC,OAAO,gBAAA,CAAA;AAEzBG,MAAAA,eAAAA,GAAkB,MAAMI,4BAAAA,EAAAA;AAExBH,MAAAA,MAAAA,GAAS,IAAII,wBAAAA,CAAOP,YAAAA,EAAcE,eAAAA,CAAAA;AAElCN,MAAAA,GAAAA,CAAIE,mBAAAA,CAAcC,OAAO,6BAAA,CAAA;AACzBK,MAAAA,OAAAA,GAAU,MAAMD,MAAAA,CAAOK,IAAAA,CAAKR,YAAAA,CAAAA;AAE5BJ,MAAAA,GAAAA,CAAIE,mBAAAA,CAAcC,OAAO,gCAAA,CAAA;AACzB,MAAA,MAAMI,MAAAA,CAAOM,QAAQT,YAAAA,CAAAA;AACvB,IAAA;AAZeK,IAAAA,wBAAAA,CAAAA,UAAAA,EAAAA,YAAAA,CAAAA;AAcf,IAAA,eAAeK,SAAAA,CACbC,MACAC,EAAAA,EAAU;AAEVhB,MAAAA,GAAAA,CAAIE,mBAAAA,CAAcC,OAAO,mBAAA,CAAA;AAEzB,MAAA,OAAOK,OAAAA,CAAQS,QAAAA,CAASC,SAAAA,CACtBC,+BAAAA,CAAcH,IAAID,IAAAA,CAAAA,EAClB,MAAMP,OAAAA,CAAQS,QAAAA,CAASG,OAAAA,CAAQZ,OAAAA,EAASQ,EAAAA,EAAID,IAAAA,CAAAA,CAAAA;AAEhD,IAAA;AAVeD,IAAAA,wBAAAA,CAAAA,SAAAA,EAAAA,WAAAA,CAAAA;AAYf,IAAA,eAAeO,WAAAA,GAAAA;AACbrB,MAAAA,GAAAA,CAAIE,mBAAAA,CAAcC,OAAO,mCAAA,CAAA;AACzB,MAAA,MAAMI,MAAAA,CAAOe,SAASlB,YAAAA,CAAAA;AACxB,IAAA;AAHeiB,IAAAA,wBAAAA,CAAAA,WAAAA,EAAAA,aAAAA,CAAAA;AAKf,IAAA,OAAO;MACLE,IAAAA,EAAM,aAAA;MACNC,OAAAA,EAAS,KAAA;AACTV,MAAAA,SAAAA;AACAL,MAAAA,UAAAA;AACAY,MAAAA;AACF,KAAA;AACF,EAAA,CAAA,CAAA,OAASI,KAAAA,EAAO;AACdzB,IAAAA,GAAAA,CAAIE,mBAAAA,CAAcwB,OAAOD,KAAAA,CAAAA;AAEzB,IAAA,MAAMA,KAAAA;AACR,EAAA;AACF,CAAA,EA3D0D,iBAAA;AA6DnD,IAAME,UAAAA,2CACoB7B,eAAAA;AAEjC,IAAA,gBAAA,GAAe6B","file":"chunk-OJWHTS4R.cjs","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Storm Stack\n\n This code was released as part of the Storm Stack project. Storm Stack\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/storm-stack.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/storm-stack\n Documentation: https://docs.stormsoftware.com/projects/storm-stack\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport type {\n TransformResult,\n UnpluginBuildContext,\n UnpluginFactory,\n UnpluginInstance\n} from \"unplugin\";\nimport { createUnplugin } from \"unplugin\";\nimport { Engine } from \"../base/engine\";\nimport { createLog } from \"../lib/logger\";\nimport { getSourceFile } from \"../lib/utilities/source-file\";\nimport type { BuildInlineConfig, Context, WorkspaceConfig } from \"../types\";\nimport type { UserConfig } from \"../types/config\";\n\nexport type StormStackUnpluginFactory = UnpluginFactory<UserConfig>;\n\nexport type StormStackUnpluginInstance = UnpluginInstance<UserConfig>;\n\nexport const unpluginFactory: StormStackUnpluginFactory = (\n userConfig: UserConfig\n) => {\n const log = createLog(\"unplugin\", userConfig);\n log(LogLevelLabel.TRACE, \"Initializing Unplugin\");\n\n try {\n const inlineConfig = {\n ...userConfig,\n command: \"build\"\n } as BuildInlineConfig;\n\n let workspaceConfig!: WorkspaceConfig;\n let engine!: Engine;\n let context!: Context;\n\n async function buildStart(this: UnpluginBuildContext): Promise<void> {\n log(LogLevelLabel.TRACE, \"Build Starting\");\n\n workspaceConfig = await getWorkspaceConfig();\n\n engine = new Engine(inlineConfig, workspaceConfig);\n\n log(LogLevelLabel.TRACE, \"Initializing Storm Stack...\");\n context = await engine.init(inlineConfig);\n\n log(LogLevelLabel.TRACE, \"Prepare Storm Stack project...\");\n await engine.prepare(inlineConfig);\n }\n\n async function transform(\n code: string,\n id: string\n ): Promise<TransformResult> {\n log(LogLevelLabel.TRACE, \"Running Transform\");\n\n return context.compiler.getResult(\n getSourceFile(id, code),\n await context.compiler.compile(context, id, code)\n );\n }\n\n async function writeBundle(): Promise<void> {\n log(LogLevelLabel.TRACE, \"Finalizing Storm Stack project...\");\n await engine.finalize(inlineConfig);\n }\n\n return {\n name: \"storm-stack\",\n enforce: \"pre\",\n transform,\n buildStart,\n writeBundle\n };\n } catch (error) {\n log(LogLevelLabel.ERROR, error);\n\n throw error;\n }\n};\n\nexport const StormStack: StormStackUnpluginInstance =\n /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default StormStack;\n"]}