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: Add types to package export map #569

Merged
merged 6 commits into from
Oct 20, 2024

Conversation

tylerbutler
Copy link
Contributor

@tylerbutler tylerbutler commented May 25, 2024

This is a possible fix for StoneCypher/fsl#1295.

As noted in that issue, TypeScript is unable to find the included jssm types in some configurations. Part of the problem is that there are no types in the export map, so this PR updates the export map to include types entries.

I also created a rolled-up declaration for ESM and CJS using rollup-plugin-dts. This seems to work well in my testing and is the smallest fix I know of. I prototyped those changes and tested them on the repro project at https://github.com/tylerbutler/jssm-node16 and compilation worked as expected for both CJS and ESM.

Because jssm is using Rollup v2, I used an older release of rollup-plugin-dts since the most recent version requires Rollup 3.

Possible risks:

As it stands today without this change, TypeScript projects using more recent moduleResolution settings will fail to compile outright. With this change, those projects can compile and will see jssm types. However, there is a risk that rollup-plugin-dts produces invalid or flawed declaration files, or that there are further types-related issues that are uncovered by this change.

That said, this change should be exceedingly safe in terms of runtime behavior, because all the changes are limited to the types-level only, and thus only affect compilation in TypeScript projects. The runtime jssm JS has not changed.

@tylerbutler tylerbutler marked this pull request as ready for review October 10, 2024 19:23
@tylerbutler
Copy link
Contributor Author

@StoneCypher Did you have a chance to think about this change? We've been successfully using a patched version of jssm with this change for some time without issues, though to be fair we use jssm in our build tools, not product code, so take this anecdotal data with a grain of salt.

That said, I think this is a safe change and doesn't represent any runtime changes - all the changes are in the type layer.

@StoneCypher
Copy link
Owner

Have you looked at the new package stuff in typescript from yesterday yet?

I'm inclined to land this but I haven't figured out testing yet

@StoneCypher StoneCypher merged commit 8c3ea00 into StoneCypher:main Oct 20, 2024
1 check passed
tylerbutler added a commit to microsoft/FluidFramework that referenced this pull request Oct 25, 2024
The latest release of jssm includes the fixes in
StoneCypher/jssm#569, so our patch is no longer
needed and has been removed. However, the jssm-viz package has a similar
problem (open PR: StoneCypher/jssm-viz#54) so I
patched it with type changes similar to what was done for jssm
originally.

If or when the jssm-viz PR is accepted or the issue is otherwise fixed,
we can remove the patch.
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