UNPKG

@storm-stack/core

Version:

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

66 lines (61 loc) 2.48 kB
'use strict'; var chunkBI5CL7FJ_cjs = require('./chunk-BI5CL7FJ.cjs'); var chunkX2JNQCAO_cjs = require('./chunk-X2JNQCAO.cjs'); var chunk3ONWID2V_cjs = require('./chunk-3ONWID2V.cjs'); var defu = require('defu'); function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } var defu__default = /*#__PURE__*/_interopDefault(defu); async function resolveType(context, entry, options = {}) { const path = await chunkBI5CL7FJ_cjs.resolvePath(context, entry.file); if (!path || !context.vfs.existsSync(path)) { throw new Error(`Module not found: "${entry.file}". Please check the path and try again.`); } const result = await chunkX2JNQCAO_cjs.bundle(context, defu__default.default({ entry: [ path ], override: { write: false, sourcemap: false, splitting: false, treeShaking: false }, compiler: { reflectionLevel: "verbose" } }, options)); if (result.errors.length > 0) { throw new Error(`Failed to transpile ${entry.file}: ${result.errors.map((error) => error.text).join(", ")}`); } if (result.warnings.length > 0) { context.log("warn", `Warnings while transpiling ${entry.file}: ${result.warnings.map((warning) => warning.text).join(", ")}`); } if (!result.outputFiles || result.outputFiles.length === 0) { throw new Error(`No output files generated for ${entry.file}. Please check the configuration and try again.`); } const resolvedTypes = await Promise.all(result.outputFiles.map(async (outputFile) => { const resolved2 = await context.resolver.evalModule(outputFile.text, { filename: outputFile.path, forceTranspile: true }); let exportName = entry.name; if (!exportName) { exportName = "default"; } return resolved2[exportName] ?? resolved2[`__\u03A9${exportName}`]; })); const resolved = resolvedTypes.filter(Boolean)[0]; if (!resolved) { throw new Error(`No valid reflection types found in ${entry.file}${entry.name ? `#${entry.name}` : ""}. Please check the file and try again.`); } return resolved; } chunk3ONWID2V_cjs.__name(resolveType, "resolveType"); async function reflectType(context, entry, options = {}) { return (void 0)(await resolveType(context, entry, options)); } chunk3ONWID2V_cjs.__name(reflectType, "reflectType"); exports.reflectType = reflectType; exports.resolveType = resolveType; //# sourceMappingURL=chunk-LZ6FYLJ2.cjs.map //# sourceMappingURL=chunk-LZ6FYLJ2.cjs.map