generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.mjs
29 lines (27 loc) · 958 Bytes
/
esbuild.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import * as path from "path";
import { fileURLToPath } from "url";
import * as esbuild from "esbuild";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const pkgName = process.argv[2] || path.basename(process.cwd());
const onResolvePlugin = {
name: "onResolve",
setup(build) {
if (pkgName === "main") {
build.onResolve({ filter: /^.\/$/ }, () => {
return { path: "./core", external: true };
});
} else {
build.onResolve({ filter: /^@octorelease\/[^\/]+$/ }, (args) => {
return { path: args.path.replace("@octorelease", "."), external: true };
});
}
},
};
await esbuild.build({
bundle: true,
entryPoints: [pkgName === "main" ? "src/main.ts" : "src/index.ts"],
logLevel: "info",
outfile: `${__dirname}/dist/${pkgName === "main" ? "index" : pkgName}.js`,
platform: "node",
plugins: [onResolvePlugin]
});