UNPKG

@storm-stack/core

Version:

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

66 lines (64 loc) 2.79 kB
import { resolverPlugin } from './chunk-NCYETMXO.js'; import { compilerPlugin } from './chunk-VBS6TPPO.js'; import { __name } from './chunk-43IZMM3W.js'; import { build } from '@storm-software/esbuild/build'; import { findFileExtension } from '@stryke/path/file-path-fns'; import { replacePath } from '@stryke/path/replace'; import { isFunction } from '@stryke/type-checks/is-function'; import defu from 'defu'; async function esbuild(context, override = {}) { const options = defu(override ?? {}, context.options.esbuild.override, { entry: context.entry.reduce((ret, entry) => { ret[entry.output || replacePath(entry.input.file, context.projectJson?.sourceRoot || context.options.projectRoot).replace(findFileExtension(entry.input.file) || "", "") || replacePath(entry.file, context.projectJson?.sourceRoot || context.options.projectRoot).replace(findFileExtension(entry.file) || "", "")] = entry.file; return ret; }, {}), assets: context.options.output.assets, outputPath: context.options.output.outputPath, mode: context.options.mode, platform: context.options.platform, projectRoot: context.options.projectRoot, sourceRoot: context.options.sourceRoot, tsconfig: context.tsconfig.tsconfigFilePath, tsconfigRaw: context.tsconfig.tsconfigJson, external: context.options.external, noExternal: context.options.noExternal, skipNodeModulesBundle: context.options.skipNodeModulesBundle }, context.options.esbuild, { banner: { js: context.options.mode !== "production" ? "\n// \u26A1 Built with Storm Stack \n" : " " }, reflectionLevel: "minimal", minify: context.options.mode !== "development", metafile: context.options.mode === "development", sourcemap: context.options.mode === "development", dts: context.options.projectType !== "application", noExternal: Array.from(context.vfs.runtimeIdMap.keys()) }); await build(defu({ config: false, clean: true, esbuildOptions(opts, ctx) { if (isFunction(options.esbuildOptions)) { options.esbuildOptions(opts, ctx); } opts.alias = defu(opts.alias ?? {}, Array.from(context.vfs.runtimeIdMap.keys()).reduce((ret, id) => { if (context.vfs.runtimeIdMap.has(id) && context.vfs.runtimeIdMap.get(id)) { ret[id] = context.vfs.runtimeIdMap.get(id); } return ret; }, {})); }, esbuildPlugins: [ resolverPlugin(context, { external: options.external, noExternal: options.noExternal, skipNodeModulesBundle: options.skipNodeModulesBundle }), compilerPlugin(context) ] }, options)); } __name(esbuild, "esbuild"); export { esbuild }; //# sourceMappingURL=chunk-OZQOMMUY.js.map //# sourceMappingURL=chunk-OZQOMMUY.js.map