-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
ATA: Unable to resolve sub module path for dual published ESM/CJS package #3008
Comments
This is the repo for TypeScript's website... Did you mean to file this on the typebox repo? |
Hi @jakebailey !
Yes, I did mean to submit here :) (assuming this is the correct place to submit issues for the TypeScript Playground). If there is a better place to submit issues for the TypeScript Playground, please let me know! :) As for the issue itself, it seems specific to submodule resolution on the TypeScript Playground; where it's lost the ability to import submodules from the TypeBox package. Note the issue only relates to the TypeScript Playground, as importing these submodules works fine in a local environment (vscode, language service and compiler) Also note, this issue has only appeared since TypeBox introduced ESM + CJS dual publishing, where it currently uses a package redirection technique (linked above) to achieve this. This technique seems to be both "valid" and yet very "non-typical", with the technique seemingly tripping up resolution on the TSP. It may be helpful to take a look at how the package setup on NPM (notice that submodule directories only contain a package.json file which redirects imports elsewhere) https://www.npmjs.com/package/@sinclair/typebox?activeTab=code I am open to this being an issue with TypeBox (and would certainly fix if that is the case), but as far as I can tell everything seems to be configured correctly (as indicated by this tool) Submitting here just in case there is something a miss with TSP resolution. |
Oops. I didn't see who filed the issue. It's possible that the playground's implementation of ATA can't handle it. Likely we should yank the new "APA" out of vscode.dev (which runs an actual package manager via wasm in the browser). |
To be honest, I don't quite get the layout; the one tshy uses is a lot simpler and likely would work out of the box. |
@jakebailey Thanks for the follow up on this!
Yeah, I've just become aware of tshy, will be taking a deeper look into it in the new year.
Yeah, the setup is a quite different. It was selected to support dual publishing and extensionless submodule pathing contrasted with the following criteria.
The package-json-redirect technique seems to achieve the above and makes TS and Node happy locally, it also enables downstream bundlers (esbuild / webpack) to do their thing...however the configuration hasn't been entirely without issue .... it's just that it seems to yield less issues than other layouts I've tried! :)
This would be amazing! |
Page URL:
TypeScript Link Here
Example Code:
Code above
Issue:
I'm not sure if this is a critical issue, but following a recent update to support dual published ESM / CJS in TypeBox. I have noticed that the TSP is no longer able to locate the
/value
sub module (or any other sub module), however the top level module import continues to work fine. I have checked to ensure TS resolution of sub module paths are valid for the package via the link below, I believe everything is setup correctly.https://arethetypeswrong.github.io/?p=%40sinclair%2Ftypebox%400.32.4
I should note that this package uses a somewhat non-typical package redirection setup to support dual publishing. The technique it uses is described at the following link / project.
https://github.com/andrewbranch/example-subpath-exports-ts-compat/tree/main/examples/node_modules/package-json-redirects
Would be amazing if this could be looked at as I use the TSP almost daily to help users who have submitting issues to the TypeBox project. It would be a shame to lose the sub module imports as many type inference features exists for these sub modules, and it would be difficult to demonstrate functionality and share code via other means.
Many Thanks
The text was updated successfully, but these errors were encountered: