From 150991708a1b9deb095dc0e0224ee7f681004659 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Sun, 25 Feb 2024 13:28:36 -0500 Subject: [PATCH] fix(build): adapt for ESM --- scripts/build.mjs | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/scripts/build.mjs b/scripts/build.mjs index 668c39cdf..bf112bcd7 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -24,6 +24,7 @@ async function main() { bundle: false, platform: "neutral", format: "esm", + target: "es2022", ...sharedOptions, sourcemap: false, }); @@ -37,30 +38,6 @@ async function main() { await rm(typeFile); } - const entryPoints = ["./pkg/dist-src/index.js"]; - - await Promise.all([ - // Build the a CJS Node.js bundle - esbuild.build({ - entryPoints, - outdir: "pkg/dist-node", - bundle: true, - platform: "node", - target: "node18", - format: "cjs", - ...sharedOptions, - }), - // Build an ESM browser bundle - esbuild.build({ - entryPoints, - outdir: "pkg/dist-web", - bundle: true, - platform: "browser", - format: "esm", - ...sharedOptions, - }), - ]); - // Copy the README, LICENSE to the pkg folder await copyFile("LICENSE", "pkg/LICENSE"); await copyFile("README.md", "pkg/README.md"); @@ -78,10 +55,12 @@ async function main() { { ...pkg, files: ["dist-*/**", "bin/**"], - main: "dist-node/index.js", - module: "dist-web/index.js", - types: "dist-types/index.d.ts", - source: "dist-src/index.js", + exports: { + ".": { + types: "./dist-types/index.d.ts", + import: "./dist-bundle/index.js", + }, + }, sideEffects: false, }, null,