kenchris / urlpattern-polyfill

URLPattern polyfill
https://www.npmjs.com/package/urlpattern-polyfill
MIT License
267 stars 30 forks source link

Node.js native ESM exports + types #48

Closed fabiancook closed 2 years ago

fabiancook commented 2 years ago

Today I used patch-package to patch urlpattern-polyfill@1.0.0-rc1 for the project I'm working on.

I found the TypeScript types for the project were not provided through the package.json file, even though the source is originally TypeScript, and that Node.js's native exports field was not added

Here is the diff that solved my problem:

diff --git a/node_modules/urlpattern-polyfill/package.json b/node_modules/urlpattern-polyfill/package.json
index 36e7a66..990beda 100755
--- a/node_modules/urlpattern-polyfill/package.json
+++ b/node_modules/urlpattern-polyfill/package.json
@@ -9,6 +9,11 @@
   "main": "./dist/index.cjs",
   "module": "./dist/index.js",
   "unpkg": "./dist/index.umd.js",
+  "types": "./dist/index.d.ts",
+  "exports": "./dist/index.js",
   "files": [
     "src",
     "dist"

This issue body was partially generated by patch-package.