Skip to content

Commit

Permalink
updated some inference; updated build script for cjs
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvander committed May 21, 2023
1 parent bd9809f commit fde2868
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,5 @@ Other options include passing a `keys` array, which explicitly spell out the sel
[downloads-url]: https://www.npmtrends.com/zustand-computed
[npm-img]: https://img.shields.io/npm/v/zustand-computed
[npm-url]: https://www.npmjs.com/package/zustand-computed
[issues-img]: https://img.shields.io/github/issues/chrisvander/zustand-computed/issues
[issues-img]: https://img.shields.io/github/issues/chrisvander/zustand-computed
[issues-url]: https://github.com/chrisvander/chrisvander/zustand-computed/issues
11 changes: 11 additions & 0 deletions fixup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cat >dist/cjs/package.json <<!EOF
{
"type": "commonjs"
}
!EOF

cat >dist/mjs/package.json <<!EOF
{
"type": "module"
}
!EOF
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@
"description": "A Zustand middleware to create computed states.",
"author": "chrisvander",
"license": "MIT",
"main": "dist/index.js",
"main": "dist/cjs/index.js",
"module": "dist/mjs/index.js",
"exports": {
".": {
"import": "./dist/mjs/index.js",
"require": "./dist/cjs/index.js"
}
},
"repository": "chrisvander/zustand-computed",
"files": [
"/dist"
],
"scripts": {
"test": "jest",
"build": "tsc"
"build": "rm -rf dist/* && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && ./fixup.sh"
},
"dependencies": {},
"devDependencies": {
Expand Down
34 changes: 34 additions & 0 deletions tsconfig-base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"compilerOptions": {
"lib": [
"esnext",
"dom"
],
"sourceMap": true,
"allowJs": false,
"declaration": true,
"moduleResolution": "node",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"noUnusedParameters": true
},
"include": [
"src"
],
"exclude": [
"**/*/*.test.*",
"**/*/*.spec.*",
"node_modules",
"dist",
"coverage",
"example",
"babel.config.js",
"jest.config.js"
]
}
8 changes: 8 additions & 0 deletions tsconfig-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig-base.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "dist/cjs",
"target": "es2015"
}
}
27 changes: 6 additions & 21 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
{
"compilerOptions": {
"outDir": "dist",
"module": "esnext",
"target": "es5",
"lib": ["es6", "dom", "es2016", "es2017"],
"sourceMap": true,
"allowJs": false,
"declaration": true,
"moduleResolution": "node",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"noUnusedParameters": true
},
"include": ["src"],
"exclude": ["**/*/*.test.*", "**/*/*.spec.*", "node_modules", "dist", "coverage", "example", "babel.config.js", "jest.config.js"]
"extends": "./tsconfig-base.json",
"compilerOptions": {
"module": "esnext",
"outDir": "dist/mjs",
"target": "esnext"
}
}

0 comments on commit fde2868

Please sign in to comment.