From 50cbc65e165ea27b4ed08ee7fc5a747a17d235da Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Sat, 3 Feb 2024 09:50:10 +0100 Subject: [PATCH] fix(build): refactor export targets for browser, node cjs, and node esm builds --- tools/publish-browser.js | 8 +++++--- tools/publish-node-cjs.js | 8 +++++--- tools/publish-node-esm.js | 8 +++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/tools/publish-browser.js b/tools/publish-browser.js index 9d36c3329c..913e6b0909 100755 --- a/tools/publish-browser.js +++ b/tools/publish-browser.js @@ -7,10 +7,12 @@ pkg.scripts = undefined pkg.imports = undefined pkg.description = undefined pkg.main = undefined -pkg.exports['.'].import = undefined -pkg.exports['.'].require = undefined pkg.keywords = undefined -pkg.exports['.'].node = pkg.exports['.'].browser +for (const exportPath of Object.keys(pkg.exports)) { + pkg.exports[exportPath].import = undefined + pkg.exports[exportPath].require = undefined + pkg.exports[exportPath].node = pkg.exports[exportPath].browser +} pkg.files.push('!dist/**/package.json') pkg.files.push('!dist/node/**/*') diff --git a/tools/publish-node-cjs.js b/tools/publish-node-cjs.js index dfe66a5c10..eb68800332 100755 --- a/tools/publish-node-cjs.js +++ b/tools/publish-node-cjs.js @@ -8,9 +8,11 @@ pkg.imports = undefined pkg.description = undefined pkg.browser = undefined pkg.deno = undefined -pkg.exports['.'].browser = undefined -pkg.exports['.'].deno = undefined -pkg.exports['.'].import = undefined +for (const exportPath of Object.keys(pkg.exports)) { + for (const runtime of ['browser', 'deno', 'import', 'bun', 'worker']) { + pkg.exports[exportPath][runtime] = undefined + } +} pkg.keywords = undefined pkg.files.push('!dist/browser/**/*') diff --git a/tools/publish-node-esm.js b/tools/publish-node-esm.js index 47be8ee13d..8531c81397 100755 --- a/tools/publish-node-esm.js +++ b/tools/publish-node-esm.js @@ -8,9 +8,11 @@ pkg.imports = undefined pkg.description = undefined pkg.browser = undefined pkg.deno = undefined -pkg.exports['.'].browser = undefined -pkg.exports['.'].deno = undefined -pkg.exports['.'].require = undefined +for (const exportPath of Object.keys(pkg.exports)) { + for (const runtime of ['browser', 'deno', 'require', 'bun', 'worker']) { + pkg.exports[exportPath][runtime] = undefined + } +} pkg.keywords = undefined pkg.files.push('!dist/**/package.json')