-
-
Notifications
You must be signed in to change notification settings - Fork 15
fix TS resolution for CJS package types #29
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
Conversation
typescript is known to not follow semver and introduce breaking changes in minor versions
|
Thanks for the PR! This is very helpful since CJS and TS are both moderately unfamiliar areas for me. It's unfortunate that this added complexity is needed. I'd almost rather go ESM only, but I guess this is the right path. I'm curious, are you personally trying to use this library from a CommonJS module, or just helping out?
Can you confirm that this is necessary for it to work? Can import
Would changing the current |
Yeah, TypeScript support for dual packages does feel unnecessarily complex. I'm trying to use
Unfortunately it is necessary for TypeScript's resolution algorithm. I am not very good at explaining stuff, but I'll try as best as I can: So, in the case of
I think so, will try it and update. Do you intend to keep support for Node 14? It's EOL for over a year now. If so I will have to address the failing CI check. |
change prepare script to prepublishOnly: attw calls npm pack which in turn would call prepare and then deadlock
|
I changed |
|
Thanks for all the details!
What would it take to address the failing check? And which version of Node first supports the I don't particularly care about Node 14, but I like running tests on it because it's the first version that supports all the JavaScript features I use within the library (e.g. including the Heads up that this PR will be a breaking change due to removing Edit: Based on this thread, |
|
Some minor-ish follow-ups in d18b974, including moving CI to Node 16. |
|
Now published in v5.0.0. |
|
For future reference, here's one ATTW-passing example that generates separate |
Fixes #28
TS resolution failed for CJS packages as shown by Are The Types Wrong.
This fix changes the bundle outputs to
dist/module/regex.jsanddist/commonjs/regex.jsfor ESM and CJS respectively and adds a postbuild script which does two things for each dist type:package.jsonfile with only thetypefield setRunning
npx attw --pack .now produces the following result:It still errors for
regex/atomicwith anode10module option, but I believe this is irrelevant since theexportsfield and subpaths are not supported by Node 10 anyway.I tried to integrate the
attwcheck into thetestscript but it would deadlock sinceattwcallsnpm packwhich in turn callsnpm preparewhich callsnpm test.Edit:
Forgot to mention that I changed the TS dependency to patch range since TS is known for not following semver and introducing breaking changes in minor versions.