From 32d7d972548c81291f40212b1941735fdcefecab Mon Sep 17 00:00:00 2001 From: Jakob Helgesson Date: Sat, 2 Mar 2024 15:12:04 +0100 Subject: [PATCH] Fix exports and allow helpers import (#2) --- package.json | 28 ++++++++++++++++++++++++---- tsup.config.ts | 9 +++++++-- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 3c36aab..d7d5f7a 100644 --- a/package.json +++ b/package.json @@ -2,16 +2,36 @@ "name": "use-enstate", "description": "", "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", + "type": "module", "files": [ "dist", - "src", "tsconfig.json" ], + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./helpers": { + "import": "./dist/helpers.js", + "require": "./dist/helpers.cjs", + "types": "./dist/helpers.d.ts" + } + }, + "typesVersions": { + "*": { + ".": [ + "./dist/index.d.ts" + ], + "./helpers": [ + "./dist/helpers.d.ts" + ] + } + }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build": "tsup ./src/index.ts", + "build": "tsup", "lint": "eslint -c .eslintrc.json --ext .ts ./src", "pub": "yarn build && yarn publish --access public" }, diff --git a/tsup.config.ts b/tsup.config.ts index 1ef7cd5..0fb3cda 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,10 +1,15 @@ import { defineConfig } from 'tsup'; export default defineConfig({ - entryPoints: ['src/index.ts'], // Adjust the entry point based on your project structure + entry: ['src/index.ts', 'src/helpers.ts'], // Adjust the entry point based on your project structure format: ['cjs', 'esm'], // Generate CommonJS and ECMAScript Modules bundles dts: true, // Generate TypeScript declaration files (*.d.ts) outDir: 'dist', // Output directory for the generated bundles - minify: true, // Optionally, enable minification sourcemap: true, // Generate sourcemaps for easier debugging + splitting: true, + clean: true, + minify: true, // Optionally, enable minification + minifyIdentifiers: true, + minifyWhitespace: true, + minifySyntax: true, });