From 1c925ceec9fbc0d0a08b2ccbc2ca712a2bf750c0 Mon Sep 17 00:00:00 2001 From: Abdelrahman Ashraf Date: Fri, 7 Feb 2025 23:10:54 +0700 Subject: [PATCH] chore(build): create bundler-free ESM distribution and add browser entry point (#468) --- .changeset/fuzzy-students-eat.md | 5 +++++ packages/react/package.json | 1 + packages/react/tsup.config.cjs | 16 ++++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 .changeset/fuzzy-students-eat.md diff --git a/.changeset/fuzzy-students-eat.md b/.changeset/fuzzy-students-eat.md new file mode 100644 index 00000000..995d7cb7 --- /dev/null +++ b/.changeset/fuzzy-students-eat.md @@ -0,0 +1,5 @@ +--- +'@lottiefiles/dotlottie-react': minor +--- + +chore(build): create bundler-free ESM distribution diff --git a/packages/react/package.json b/packages/react/package.json index b142c7e6..ce1ed5bb 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -17,6 +17,7 @@ "license": "MIT", "main": "dist/index.js", "module": "dist/index.js", + "browser": "dist/browser/index.js", "types": "dist/index.d.ts", "files": [ "dist" diff --git a/packages/react/tsup.config.cjs b/packages/react/tsup.config.cjs index 76733ccd..79fbfb83 100644 --- a/packages/react/tsup.config.cjs +++ b/packages/react/tsup.config.cjs @@ -1,6 +1,6 @@ const { defineConfig } = require('tsup'); -module.exports = defineConfig({ +const config = { bundle: true, metafile: false, splitting: false, @@ -15,4 +15,16 @@ module.exports = defineConfig({ target: ['es2020'], tsconfig: 'tsconfig.build.json', external: ['react'], -}); +}; + +module.exports = defineConfig([ + config, + // CDN build: Self-contained + { + ...config, + dts: false, + format: ['esm'], + noExternal: Object.keys(require('./package.json').dependencies), + outDir: 'dist/browser', + }, +]);