Skip to content

Commit

Permalink
fix: split CJS and ESM builds correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranet committed May 16, 2024
1 parent 39c913d commit ff3e8a7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
"description": "A framework agnostic library for editable commands",
"author": "@skyra",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.mjs",
"types": "dist/cjs/index.d.cts",
"exports": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
"import": {
"types": "./dist/esm/index.d.mts",
"default": "./dist/esm/index.mjs"
},
"require": {
"types": "./dist/cjs/index.d.cts",
"default": "./dist/cjs/index.cjs"
}
},
"sideEffects": false,
"homepage": "https://skyra-project.github.io/editable-commands",
"files": [
"dist/**/*.js*",
"dist/**/*.mjs*",
"dist/**/*.d*"
],
"scripts": {
"lint": "eslint src --ext ts --fix",
"format": "prettier --write \"src/**/*.ts\"",
Expand All @@ -29,6 +29,9 @@
"check-update": "cliff-jumper --dry-run",
"prepack": "yarn build"
},
"files": [
"dist/"
],
"devDependencies": {
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
Expand Down
15 changes: 10 additions & 5 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { defineConfig } from 'tsup';
import { Options, defineConfig } from 'tsup';

export default defineConfig({
const baseOptions: Options = {
clean: true,
dts: true,
entry: ['src/index.ts'],
format: ['esm', 'cjs'],
minify: false,
skipNodeModulesBundle: true,
sourcemap: true,
target: 'es2020',
tsconfig: 'src/tsconfig.json',
keepNames: true
});
keepNames: true,
treeshake: true
};

export default [
defineConfig({ ...baseOptions, outDir: 'dist/cjs', format: 'cjs', outExtension: () => ({ js: '.cjs' }) }),
defineConfig({ ...baseOptions, outDir: 'dist/esm', format: 'esm' })
];

0 comments on commit ff3e8a7

Please sign in to comment.