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

address dual dts issues #60

Closed
wants to merge 3 commits into from
Closed

address dual dts issues #60

wants to merge 3 commits into from

Conversation

patroza
Copy link
Member

@patroza patroza commented Mar 27, 2024

I think I found the structural fix for the dual dts problem, exposed for example when you start using fast-check with schema from an esm project.

The problem appears to stem from that a single dts file exposed from package.json can only be interpeted either as cjs or as esm, which will dictate which dts it will load from external packages, which for better or worse, can have different .d.ts files for esm and cjs.
In the case of schema that turns out to be the cjs version of fast-check, leading to the problem once you mix it from an esm source.

The fix is by creating individual proxy .d.ts for cjs and esm, but re-exporting from a single source of dts truth, so that symbols remain unique

Copy link

changeset-bot bot commented Mar 27, 2024

🦋 Changeset detected

Latest commit: 505b9b3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@effect/build-utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

.changeset/lovely-adults-brush.md Outdated Show resolved Hide resolved
Effect.all([
fs.writeFileString(
`dist/dist/cjs/${module}.d.ts`,
`export * from "../dts/${module}"`,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u could very well just do this to be more explicit:

Suggested change
`export * from "../dts/${module}"`,
`export * from "../dts/${module}.js"`,

the .js extension isn't forbidden in CJS-oriented .d.ts files

@patroza patroza closed this Mar 27, 2024
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.

3 participants