Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "types" to package exports for TypeScript NodeNext #101

Merged
merged 2 commits into from
Jul 15, 2022

Conversation

aomarks
Copy link
Contributor

@aomarks aomarks commented Jul 15, 2022

TypeScript 4.7 has support for package exports, however it requires that each package export entry specifies the typings for that export. If omitted, for a project that is using the new NodeNext resolution mode, the typings will not be found: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#package-json-exports-imports-and-self-referencing

This PR adds a "types" field to the two export conditions, so that they can be imported when using the NodeNext setting in TypeScript 4.7.

It also adds a .js extension to index.d.ts's import of types, which is also required when consumers are using the new NodeNext resolution mode.

TypeScript 4.7 has support for package exports, however it requires that each package export entry specifies the typings for that export. If omitted, for a project that is using the new `NodeNext` resolution mode, the typings will not be found: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#package-json-exports-imports-and-self-referencing

This PR adds a "types" field to the two export conditions, so that they can be imported when using the `NodeNext` setting in TypeScript 4.7.
@kenchris kenchris self-assigned this Jul 15, 2022
@kenchris
Copy link
Owner

Thanks for the patch @aomarks - the tests pass so I am going to merge this.

@kenchris kenchris merged commit f04fb41 into kenchris:main Jul 15, 2022
@kenchris
Copy link
Owner

Published 5.0.4 to NPM https://www.npmjs.com/package/urlpattern-polyfill/v/5.0.4

@aomarks
Copy link
Contributor Author

aomarks commented Jul 15, 2022

Published 5.0.4 to NPM https://www.npmjs.com/package/urlpattern-polyfill/v/5.0.4

Thanks for the super fast review and publish! Much appreciated.

It looks like for some reason the .js change didn't make it into the release. Compare:

https://unpkg.com/browse/urlpattern-polyfill@5.0.4/dist/index.d.ts
https://github.com/kenchris/urlpattern-polyfill/blob/main/src/index.d.ts

@kenchris
Copy link
Owner

That is very strange, not sure how that could be @SanderElias ?

@kenchris
Copy link
Owner

Seems fixed in https://unpkg.com/browse/urlpattern-polyfill@5.0.5/dist/index.d.ts

@aomarks
Copy link
Contributor Author

aomarks commented Jul 15, 2022

Seems fixed in https://unpkg.com/browse/urlpattern-polyfill@5.0.5/dist/index.d.ts

Confirmed, it's compiling nicely for us now. Thanks again!

aomarks added a commit to lit/lit that referenced this pull request Jul 15, 2022
- Upgrades almost all dependencies, both dev and prod.

- There were only 2 deps I didn't tackle in this PR, because it seems like they'll need a little more work:
    - parse5 6 -> 7 (cc @43081j, seems like the types API is substantially different now, so I wasn't able to easily do this upgrade).
    - react 17 -> 18 (cc @justinfagnani @taylor-vann I wasn't sure what the implications/requirements for upgrading to react 18 will be, so I didn't even try).

- Consolidated some very common devDeps (e.g. uvu, mocha) into the top-level package.json, for easier future upgrade.

- Removes some unnecessary dependencies I found.

- Updates a few spots where typings changed.

- Removes 350MB (1.6GB -> 1.25GB) and 999 packages (3122 -> 2123), from our install.

- FYI these external PRs were also needed to get things fully upgraded:
  - kenchris/urlpattern-polyfill#101
  - google/tachometer#239
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants