From aad55f47f1e6348fa3d246697d7503985eff4c06 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Mon, 4 Mar 2024 15:43:30 -0500 Subject: [PATCH] fix(build): adapt for ESM --- scripts/build.mjs | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/scripts/build.mjs b/scripts/build.mjs index ae38ce8a..396130d3 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -25,7 +25,6 @@ async function main() { platform: "neutral", format: "esm", ...sharedOptions, - sourcemap: false, }); // Remove the types file from the dist-src folder @@ -37,30 +36,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: "node14", - 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"); @@ -77,11 +52,15 @@ async function main() { JSON.stringify( { ...pkg, - files: ["dist-*/**", "bin/**"], - main: "dist-node/index.js", - module: "dist-web/index.js", + files: ["dist-*/**"], + main: "dist-src/index.js", types: "dist-types/index.d.ts", - source: "dist-src/index.js", + exports: { + ".": { + types: "./dist-types/index.d.ts", + import: "./dist-src/index.js", + } + }, sideEffects: false, }, null,