UNPKG

@storm-stack/core

Version:

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

1 lines 2.92 kB
{"version":3,"sources":["../../src/lib/typescript/transpile.ts"],"names":["transpile","context","id","code","options","transformer","createTransformer","declarationTransformer","createDeclarationTransformer","ts","transpileModule","compilerOptions","tsconfig","configFilePath","tsconfigFilePath","fileName","transformers","before","after"],"mappings":";;;;;;;;;;AAkCO,SAASA,UACdC,OAAAA,EACAC,EAAAA,EACAC,IAAAA,EACAC,OAAAA,GAA6B,EAAC,EAAC;AAE/B,EAAA,MAAMC,WAAAA,GAAcC,mCAAAA,CAAkBL,OAAAA,EAASG,OAAAA,CAAAA;AAC/C,EAAA,MAAMG,sBAAAA,GAAyBC,8CAAAA,CAA6BP,OAAAA,EAASG,OAAAA,CAAAA;AAErE,EAAA,OAAOK,mBAAAA,CAAGC,gBAAgBP,IAAAA,EAAM;IAC9BQ,eAAAA,EAAiB;AACf,MAAA,GAAGV,QAAQW,QAAAA,CAASR,OAAAA;AACpBS,MAAAA,cAAAA,EAAgBZ,QAAQW,QAAAA,CAASE;AACnC,KAAA;IACAC,QAAAA,EAAUb,EAAAA;IACVc,YAAAA,EAAc;MACZC,MAAAA,EAAQ;AAACZ,QAAAA;;MACTa,KAAAA,EAAO;AAACX,QAAAA;;AACV;GACF,CAAA;AACF;AApBgBP,wBAAAA,CAAAA,SAAAA,EAAAA,WAAAA,CAAAA","file":"chunk-3LKBNTVT.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 ts from \"typescript\";\nimport { TranspilerOptions } from \"../../types/compiler\";\nimport { Context } from \"../../types/context\";\nimport {\n createDeclarationTransformer,\n createTransformer\n} from \"../deepkit/transformer\";\n\n/**\n * Transpile TypeScript code using the provided context and options.\n *\n * @param context - The base context containing TypeScript configuration and options.\n * @param id - The identifier for the TypeScript file being transpiled.\n * @param code - The TypeScript code to be transpiled.\n * @returns The transpiled output.\n */\nexport function transpile(\n context: Context,\n id: string,\n code: string,\n options: TranspilerOptions = {}\n): ts.TranspileOutput {\n const transformer = createTransformer(context, options);\n const declarationTransformer = createDeclarationTransformer(context, options);\n\n return ts.transpileModule(code, {\n compilerOptions: {\n ...context.tsconfig.options,\n configFilePath: context.tsconfig.tsconfigFilePath\n },\n fileName: id,\n transformers: {\n before: [transformer],\n after: [declarationTransformer]\n }\n });\n}\n"]}