Skip to content

fix: TypeScript resolution should now work across bundlers#1165

Merged
spencermountain merged 3 commits into
spencermountain:masterfrom
crutchcorn:fix-are-types-wrong
Jan 15, 2025
Merged

fix: TypeScript resolution should now work across bundlers#1165
spencermountain merged 3 commits into
spencermountain:masterfrom
crutchcorn:fix-are-types-wrong

Conversation

@crutchcorn

Copy link
Copy Markdown

This PR fixes #1164 by:

  • Fixing fallback cases
  • Adding node10 (think Webpack 4 and older node) resolution via {root}/one/package.json files
  • Creating CJS-specific .d.cts types so TypeScript doesn't incorrectly warn of default usage when doing a require
  • Removing unused (AFAICT) type exports like ./misc and ./views

This should not be a breaking change for existing users, but will likely fix many reported problems in CJS (and even some ESM) usage of this library

Before

Using "AreTheTypesWrong" CLI:

image

After

Using the same CLI:

image

@spencermountain

Copy link
Copy Markdown
Owner

whoaaaaaa
This is amazing. Thank you Corbin.
Yes, i believe your suspicions are correct. I read something in 2015 about esm and haven't changed anything since then. Thank you for showing me this tool.

Gonna merge this and will see if I can get a release going.

@spencermountain spencermountain merged commit 53d40d0 into spencermountain:master Jan 15, 2025
@spencermountain

Copy link
Copy Markdown
Owner

okay, one question - do we need the one/package.json two/package.json etc?

I kinda like the compromise/one compromise/two scheme ... and would prefer not having to publish individual packages compromise-one etc?

are those package.json files scooped up by a bundler somewhere?
thank you for your help. I know none of this.
cheers

@crutchcorn

Copy link
Copy Markdown
Author

okay, one question - do we need the one/package.json two/package.json etc?

Unfortunately, yes, they need to stay as they are :( Big headache for many of my projects as well, I agree.

The reason for it is that older bundlers and Node installs used the literal filesystem lookups to see if there were package.jsons under the subpath that's listed.

If we remove, say, one/package.json it'll break the node10 lookup (and likely many CJS projects on modern bundlers, even)

@crutchcorn

Copy link
Copy Markdown
Author

(total aside; thanks so much for being so bright and kind in these replies ✨ Always such a refreshing welcome to any new project one contributes to :D )

@spencermountain spencermountain mentioned this pull request Jan 16, 2025
@spencermountain

Copy link
Copy Markdown
Owner

ok released as 14.14.4 - I'm around tomorrow, so please let me know if you see anything weird.
Thank you for your help.

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.

TypeScript Support Impacted By Incorrect Package.json Configuration

2 participants