Skip to content

Commit

Permalink
Put type declarations next to JS file (fixes #84)
Browse files Browse the repository at this point in the history
It seems that setting `"types": "index.d.ts"` in `package.json` doesn't
cut it in all cases, and some build toolchains really want the `.d.ts`
files to be next to the `.js` file it's associated with.

So even if since 3.0.0 the `.d.ts` file is the same for `esm/index.js`
and `cjs/index.js`, we still need to copy an identical declaration file
next to the JS files.
  • Loading branch information
valeriangalliat committed Feb 24, 2024
1 parent d2517c2 commit 628d058
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/node_modules
/esm/index.js
/esm/index.d.ts
/cjs/index.js
/index.d.ts
/cjs/index.d.ts
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [3.0.1] - 2024-02-24
* Fix an issue with type declarations resolution. ([#84])

## [3.0.0] - 2024-02-21
* Export `FetchCookieImpl` interface. ([#81])
* **Breaking:** move away from CJS `module.exports = fetchCookie` style,
Expand Down Expand Up @@ -121,7 +124,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [0.1.0] - 2015-04-04
* Initial release.

[Unreleased]: https://github.com/valeriangalliat/fetch-cookie/compare/v2.1.0...HEAD
[Unreleased]: https://github.com/valeriangalliat/fetch-cookie/compare/v3.0.1...HEAD
[3.0.1]: https://github.com/valeriangalliat/fetch-cookie/compare/v3.0.0...v3.0.1
[3.0.0]: https://github.com/valeriangalliat/fetch-cookie/compare/v2.2.0...v3.0.0
[2.2.0]: https://github.com/valeriangalliat/fetch-cookie/compare/v2.1.0...v2.2.0
[2.1.0]: https://github.com/valeriangalliat/fetch-cookie/compare/v2.0.5...v2.1.0
[2.0.5]: https://github.com/valeriangalliat/fetch-cookie/compare/v2.0.4...v2.0.5
[2.0.4]: https://github.com/valeriangalliat/fetch-cookie/compare/v2.0.3...v2.0.4
Expand Down Expand Up @@ -184,3 +190,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
[#70]: https://github.com/valeriangalliat/fetch-cookie/issues/70
[#71]: https://github.com/valeriangalliat/fetch-cookie/issues/71
[#72]: https://github.com/valeriangalliat/fetch-cookie/issues/72
[#81]: https://github.com/valeriangalliat/fetch-cookie/pull/81
[#84]: https://github.com/valeriangalliat/fetch-cookie/issues/84
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
"./package.json": "./package.json",
".": {
"import": {
"types": "./esm/index.d.ts",
"default": "./esm/index.js"
},
"require": {
"types": "./cjs/index.d.ts",
"default": "./cjs/index.js"
}
}
},
"types": "index.d.ts",
"types": "cjs/index.d.ts",
"repository": "valeriangalliat/fetch-cookie",
"scripts": {
"build": "esbuild src/*.ts --format=esm --outdir=esm && esbuild src/*.ts --format=cjs --outdir=cjs",
Expand All @@ -29,7 +31,7 @@
"test": "npm run build && mocha",
"test-import": "node test/cjs/import.js && ts-node test/cjs/import.ts",
"type-check": "tsc -noEmit",
"type-declarations": "tsc --project tsconfig.build.json --declaration --emitDeclarationOnly --outDir ."
"type-declarations": "tsc --project tsconfig.build.json --declaration --emitDeclarationOnly --outDir esm && cp esm/index.d.ts cjs"
},
"dependencies": {
"set-cookie-parser": "^2.4.8",
Expand Down

0 comments on commit 628d058

Please sign in to comment.