From fdc825da5780e6a2144f8fa0c3b0f5065e09839c Mon Sep 17 00:00:00 2001 From: Nhat Khanh Date: Mon, 7 Aug 2023 22:40:37 +0700 Subject: [PATCH] fix(build): use exports map (#19) --- package.json | 9 ++++++--- rollup.config.js | 11 ++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index e52a941..e838936 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,13 @@ "name": "@minswap/sdk", "version": "0.2.0-beta", "description": "Query Minswap data and build transactions", - "main": "./build/index.js", - "module": "./build/index.es.js", - "types": "./build/index.d.ts", "type": "module", + "exports": { + ".": { + "types": "./build/index.d.ts", + "import": "./build/index.es.js" + } + }, "files": [ "build" ], diff --git a/rollup.config.js b/rollup.config.js index dab1bad..20ca9b5 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,8 +1,6 @@ import dts from "rollup-plugin-dts"; import esbuild from "rollup-plugin-esbuild"; -const name = require("./package.json").main.replace(/\.js$/, ""); - const bundle = (config) => ({ ...config, input: "src/index.ts", @@ -14,12 +12,7 @@ export default [ plugins: [esbuild()], output: [ { - file: `${name}.js`, - format: "cjs", - sourcemap: true, - }, - { - file: `${name}.es.js`, + file: `build/index.es.js`, format: "es", sourcemap: true, }, @@ -28,7 +21,7 @@ export default [ bundle({ plugins: [dts()], output: { - file: `${name}.d.ts`, + file: `build/index.d.ts`, format: "es", }, }),