Skip to content

Commit

Permalink
feat: export cjs for projects that dont have type module at root (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
alec-chernicki authored Jan 16, 2024
1 parent 643494e commit 866b97a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
9 changes: 6 additions & 3 deletions apps/commonality/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
"bin.js"
],
"types": "./dist/utilities/index.d.ts",
"main": "./dist/utilities/index.js",
"main": "./dist/utilities/index.cjs",
"exports": {
".": "./dist/utilities/index.js"
".": {
"import": "./dist/utilities/index.js",
"require": "./dist/utilities/index.cjs"
}
},
"description": "Infinitely scalable front-end ecosystems",
"repository": {
Expand Down Expand Up @@ -97,4 +100,4 @@
"typescript": "^5.2.2",
"vitest": "^0.34.6"
}
}
}
2 changes: 1 addition & 1 deletion apps/commonality/tsup.config.utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Options } from 'tsup';

const config: Options = {
entryPoints: ['src/index.ts'],
format: ['esm'],
format: ['esm', 'cjs'],
platform: 'node',
outDir: './dist/utilities',
noExternal: [/^@commonalityco\/.*/],
Expand Down
14 changes: 9 additions & 5 deletions packages/commonality-checks-recommended/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
"type": "module",
"types": "./dist/index.d.ts",
"exports": {
".": "./dist/index.js"
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.js",
"main": "./dist/index.cjs",
"scripts": {
"build": "tsc --build",
"dev": "tsc --watch",
"build": "tsup-node --config tsup.config.ts",
"dev": "tsup-node --config tsup.config.ts --watch",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"test": "vitest",
Expand All @@ -31,6 +34,7 @@
"commonality": "workspace:*",
"eslint-config-commonality": "workspace:*",
"mock-fs": "^5.2.0",
"tsup": "^8.0.1",
"typescript": "^5.2.2"
},
"dependencies": {
Expand All @@ -43,4 +47,4 @@
"url": "https://github.com/commonalityco/commonality",
"directory": "packages/commonality-checks-recommended"
}
}
}
15 changes: 15 additions & 0 deletions packages/commonality-checks-recommended/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Options } from 'tsup';

const config: Options = {
entryPoints: ['src/index.ts'],
format: ['esm', 'cjs'],
platform: 'node',
outDir: './dist',
clean: true,
noExternal: [/^@commonalityco\/.*/],
dts: {
resolve: true,
},
};

export default config;
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 866b97a

Please sign in to comment.