Skip to content

Conversation

@hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Apr 18, 2025

Description

This types field is only used by (mostly deprecated) moduleResolution: "node". index.d.ts was same as index.d.mts previously, but unbuild 3.5.0 changed something and it's now index.d.cts for some reason. Making a quick fix to just point to index.d.mts to preserve old ts behavior.

Technically this should be reported and fixed on unbuild, but this types fields are only for back compat for ancient config, so quick fix on our side seems fine.

I locally confirmed the repro is fixed with local override.

@hi-ogawa hi-ogawa marked this pull request as ready for review April 18, 2025 02:45
@ArnaudBarre
Copy link
Member

I'm not really good at this madness of dual package, if it does not affect other module resolutions it should be a safe change then. Tagging the expert @bluwy

@bluwy
Copy link
Member

bluwy commented Apr 18, 2025

unbuild 3.5.0 changed something and it's now index.d.cts for some reason.

Haven't tested, but I noticed plugin-react 4.4.0 adds "type": "module" which changes how .d.ts gets evaluated. So that might've affected the output.

But anyways, I think this change is ok for compatibility. It changes the evaluation type from CJS to ESM (previous 4.3.4 evaluates as CJS), but this field is only used by moduleResolution: "node" which iirc doesn't care about evaluation type anyways.

The side-effect of using .d.mts though is that it's only supported since TypeScript 4.7, but it's an older release now and shouldn't affect most setup (similar bombshell-dev/clack#253)

@ArnaudBarre ArnaudBarre merged commit a62bdd6 into vitejs:main Apr 19, 2025
9 checks passed
@hi-ogawa hi-ogawa deleted the fix-old-types branch April 20, 2025 04:17
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.

No default export when using "moduleResolution": "node" in 4.4.0

3 participants