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

Export typings from package.json #56

Merged
merged 1 commit into from
Oct 25, 2023

Conversation

aleksandrjet
Copy link
Contributor

When I try to export preact-ssr-prepass to an application using nodeJs^18 I get an error:

Could not find a declaration file for module 'preact-ssr-prepass'. 
'.../node_modules/preact-ssr-prepass/dist/index.mjs' implicitly has an 'any' type.
There are types at '.../node_modules/preact-ssr-prepass/typings/index.d.ts', 
but this result could not be resolved when respecting package.json "exports". 
The 'preact-ssr-prepass' library may need to update its package.json or typings.

This happens because nodeJs^18 firstly looks at the exports field in package.json, but the types are not specified there.

Description of main field:

The "main" field defines the entry point of a package when imported by name via a node_modules lookup. Its value is a path. When a package has an "exports" field, this will take precedence over the "main" field when importing the package by name.

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@rschristian
Copy link
Member

This happens because nodeJs^18 firstly looks at the exports field in package.json, but the types are not specified there.

For what it's worth, this isn't Node -- Node never has (or likely will) care about the "types" condition. This is from TS under specific "moduleResolution" settings.

@rschristian rschristian merged commit d3a975b into preactjs:master Oct 25, 2023
1 check passed
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.

2 participants