From 8d38d315899e3423eeb21c413a15efc679a0ac62 Mon Sep 17 00:00:00 2001 From: wolfy1339 <4595477+wolfy1339@users.noreply.github.com> Date: Sun, 25 Feb 2024 14:53:54 -0500 Subject: [PATCH] fix(build): correctly output ESM (#423) --- scripts/build.mjs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/scripts/build.mjs b/scripts/build.mjs index 862e23a5..5d937709 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -43,7 +43,7 @@ async function main() { bundle: true, platform: "node", target: "node18", - format: "cjs", + format: "esm", ...sharedOptions, }), // Build an ESM browser bundle @@ -74,10 +74,22 @@ async function main() { { ...pkg, files: ["dist-*/**", "bin/**"], - main: "dist-node/index.js", - browser: "dist-web/index.js", - types: "dist-types/index.d.ts", - module: "dist-src/index.js", + exports: { + ".": { + node: { + types: "./dist-types/index.d.ts", + import: "./dist-node/index.js", + }, + browser: { + types: "./dist-types/web.d.ts", + import: "./dist-web/index.js", + }, + default: { + types: "./dist-types/index.d.ts", + import: "./dist-node/index.js", + }, + }, + }, sideEffects: false, }, null,