dressed
Version:
A sleek, serverless-ready Discord bot framework.
40 lines • 1.3 kB
JavaScript
var _a, _b;
import { build } from "esbuild";
import { readFileSync } from "node:fs";
let tsconfig = { compilerOptions: { paths: {} } };
try {
tsconfig = JSON.parse(readFileSync("tsconfig.json", "utf8"));
}
catch (_c) {
//pass
}
const paths = Object.keys((_b = (_a = tsconfig.compilerOptions) === null || _a === void 0 ? void 0 : _a.paths) !== null && _b !== void 0 ? _b : {}).map((p) => p.split("*")[0]);
export default async function bundleFile(file) {
await build({
entryPoints: [file.path],
outfile: file.outPath,
bundle: true,
minify: true,
platform: "node",
format: "esm",
write: true,
treeShaking: true,
jsx: "automatic",
plugins: [
{
name: "make-all-packages-external",
setup: (build) => {
const filter = /^[^./]|^\.[^./]|^\.\.[^/]/;
build.onResolve({ filter }, (args) => {
if (paths.some((p) => args.path.startsWith(p))) {
return { external: false };
}
return { external: true };
});
},
},
],
});
return file.outPath;
}
//# sourceMappingURL=bundle.js.map