Skip to content

Commit cbe8ac2

Browse files
committed
fix build.mjs
1 parent 28f2bc3 commit cbe8ac2

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

build.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { build } from "esbuild";
22
import { copyFileSync } from "fs";
3+
import { dirname, resolve } from "path";
4+
import { fileURLToPath } from "url";
5+
6+
const rootDir = dirname(fileURLToPath(import.meta.url));
37

48
const entries = [
59
{ entry: "src/index.js", base: "index", globalName: "__tc" },
@@ -11,6 +15,7 @@ const entries = [
1115
await Promise.all(
1216
entries.flatMap(({ entry, base, globalName }) => [
1317
build({
18+
absWorkingDir: rootDir,
1419
entryPoints: [entry],
1520
bundle: true,
1621
format: "esm",
@@ -19,6 +24,7 @@ await Promise.all(
1924
target: ["es2020"],
2025
}),
2126
build({
27+
absWorkingDir: rootDir,
2228
entryPoints: [entry],
2329
bundle: true,
2430
format: "iife",
@@ -36,6 +42,9 @@ await Promise.all(
3642
]),
3743
);
3844

39-
copyFileSync("src/index.d.ts", "index.d.ts");
45+
copyFileSync(
46+
resolve(rootDir, "src/index.d.ts"),
47+
resolve(rootDir, "index.d.ts"),
48+
);
4049

4150
console.log("Build complete");

0 commit comments

Comments
 (0)