Skip to content

esbuild support exports/imports resolution in package.json for type: module #24425

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

Closed
wesselvdv opened this issue Dec 13, 2022 · 5 comments
Closed
Labels
needs: more info Reporter must clarify the issue

Comments

@wesselvdv
Copy link

Command

build

Description

Would it be possible to support the resolution of exports/imports (sub)paths for type: module (https://nodejs.org/api/packages.html)

The only supported "custom" paths are currently through tsconfig. I am aware of the builtin support in esbuild for exports defined in package.json, but I reckon something isn't passed along to esbuild because it doesn't work for the builder.

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

@clydin
Copy link
Member

clydin commented Dec 13, 2022

Can you provide an example and/or a minimal reproduction demonstrating the problem you are encountering?

The Angular framework packages extensively use the package exports field and are also marked as module type packages. However, package exports in general do not require the presence of the type field nor its value being set to module.

@clydin clydin added the needs: more info Reporter must clarify the issue label Dec 13, 2022
@wesselvdv
Copy link
Author

wesselvdv commented Dec 13, 2022

I am trying to use the self reference capabilities of exports/imports (moduleResolution: Node16) in combination with esbuild.

@clydin
Copy link
Member

clydin commented Dec 14, 2022

Can you provide a code example of what is being attempted to assist in replicating and troubleshooting the issue?

If you are attempting to import a package.json package name within the project that contains added exports entries then this won't work unless the TypeScript files in the entries are manually added to the compilation within the tsconfig include/files settings.
This is due to TypeScript behavior which considers those files external to the application and will not be emitted by the TypeScript compiler. The source file is, however, correctly and fully resolved. This situation also applies to imports entries as well.
The esbuild-based builder should be providing an error in these cases with a note to add the file to the TypeScript compilation.

@wesselvdv
Copy link
Author

Looks like I was running into this issue: webpack/enhanced-resolve#355

Now that i've applied my own fix, it works. (both webpack and esbuild)

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: more info Reporter must clarify the issue
Projects
None yet
Development

No branches or pull requests

2 participants