build: move to esm (wip)

This commit is contained in:
Justineo
2024-04-16 13:02:13 +08:00
parent 002b2f2701
commit d00aa090a6
5 changed files with 25 additions and 19 deletions

13
scripts/utils.js Normal file
View File

@ -0,0 +1,13 @@
import { readFileSync } from "node:fs";
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
export function resolvePath(url, ...parts) {
return resolve(dirname(fileURLToPath(url)), ...parts);
}
export function getPackageMeta() {
return JSON.parse(
readFileSync(resolvePath(import.meta.url, "/package.json"), "utf8")
);
}