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

Also handle imports deep imports from libraries? #2

Closed
CarsonF opened this issue Jul 20, 2023 · 5 comments
Closed

Also handle imports deep imports from libraries? #2

CarsonF opened this issue Jul 20, 2023 · 5 comments

Comments

@CarsonF
Copy link

CarsonF commented Jul 20, 2023

This might be my missing link to actually adopt ESM, so thank you for that.

I'm wondering if you think it's possible to also handle library imports. Something like

import { isPlainObject } from '@nestjs/common/utils/shared.utils';

Adding the extension to that import fixes it.
Maybe that's harder though logically, because there's package.json exports to consider. Or some other complication with non-local code?

@barhun
Copy link
Owner

barhun commented Jul 22, 2023

I think it's better to not modify the default package resolution behavior for the reasons mentioned below:

Why deep imports can be a problem

Deep imports for dual packages presents a problem for transpiling for dual-packages

@CarsonF
Copy link
Author

CarsonF commented Jul 26, 2023

Yeah makes sense 👍

@CarsonF CarsonF closed this as completed Jul 26, 2023
@barhun
Copy link
Owner

barhun commented Sep 22, 2023

Have you considered using subpath imports instead?

@CarsonF
Copy link
Author

CarsonF commented Sep 22, 2023

Was not aware of that. Good to know. But many of these imports are only done once, so a separate mapping isn't worth it.

@barhun
Copy link
Owner

barhun commented Dec 4, 2023

You might wanna give it a try with the latest version of the npm package. (:

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

No branches or pull requests

2 participants