@storm-stack/core
Version:
A build toolkit and runtime used by Storm Software in TypeScript applications
39 lines (37 loc) • 1.68 kB
JavaScript
import { resolveESBuildOptions, resolveEsbuildEntryOptions } from './chunk-2IJX7TED.js';
import { transpilerPlugin } from './chunk-F552UJYX.js';
import { resolverPlugin } from './chunk-NCYETMXO.js';
import { compilerPlugin } from './chunk-VBS6TPPO.js';
import { __name } from './chunk-43IZMM3W.js';
import { LogLevelLabel } from '@storm-software/config-tools/types';
import { isString } from '@stryke/type-checks/is-string';
import defu from 'defu';
import { build } from 'esbuild';
async function bundle(context, bundleOptions = {}) {
const options = defu({
plugins: [
resolverPlugin(context, {
external: bundleOptions.external,
noExternal: bundleOptions.noExternal,
skipNodeModulesBundle: bundleOptions.skipNodeModulesBundle
}),
bundleOptions.compiler?.skipAllTransforms === true ? transpilerPlugin(context, bundleOptions.compiler) : compilerPlugin(context, bundleOptions.compiler)
].filter(Boolean)
}, resolveESBuildOptions(context, {
outdir: bundleOptions.outputPath,
entryPoints: resolveEsbuildEntryOptions(context, bundleOptions.entry ? Array.isArray(bundleOptions.entry) ? bundleOptions.entry : isString(bundleOptions.entry) ? [
bundleOptions.entry
] : Object.values(bundleOptions.entry) : []),
bundle: true
}, bundleOptions));
try {
return await build(options);
} catch (error) {
context.log(LogLevelLabel.ERROR, error?.message ? `An error occurred while bundling: ${error?.message}` : "An error occurred while bundling");
throw error;
}
}
__name(bundle, "bundle");
export { bundle };
//# sourceMappingURL=chunk-6BLGLCSK.js.map
//# sourceMappingURL=chunk-6BLGLCSK.js.map