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

fix: correctly declare types in package.json exports #2972

Merged
merged 7 commits into from
Nov 24, 2023

Conversation

tbouffard
Copy link
Member

@tbouffard tbouffard commented Nov 20, 2023

Add the types value to the exports field of the package.json file.
This makes projects work when moduleResolution is set to bundler in tsconfig.json.

The previous configuration generated a TypeScript compiler error:

TS7016: Could not find a declaration file for module 'bpmn-visualization'.
There are types at 'node_modules/bpmn-visualization/dist/bpmn-visualization.d.ts',
but this result could not be resolved when respecting package.json "exports".
The 'bpmn-visualization' library may need to update its package.json or typings.

A reproduction test project has been added to validate the change.

Notes

Issue detected in process-analytics/bpmn-visualization-examples#390 (comment)
Reproduced with a minimal setup in process-analytics/bpmn-visualization-examples#580.

TypeScript documentation: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html#packagejson-exports-imports-and-self-referencing

The exports field in the package.json file was introduced in #2840.

Implementation validation

Remove the types property of the exports field in the package.json file. This restores a configuration equivalent to that which existed before the change.
Then run the test in test/typescript-moduleResolution-bundler. It will fail whereas it succeeds with the new configuration.

@tbouffard tbouffard added the bug Something isn't working label Nov 20, 2023
Copy link

github-actions bot commented Nov 20, 2023

♻️ PR Preview ea1bed0 has been successfully destroyed since this PR has been closed.

🤖 By surge-preview

Copy link

github-actions bot commented Nov 20, 2023

♻️ PR Preview ea1bed0 has been successfully destroyed since this PR has been closed.

🤖 By surge-preview

Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@tbouffard tbouffard merged commit da05316 into master Nov 24, 2023
26 checks passed
@tbouffard tbouffard deleted the fix/package.json_exports_types branch November 24, 2023 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants