-
Notifications
You must be signed in to change notification settings - Fork 96
jsnext:main directory support? #44
Comments
cc @IgorMinar |
the other option would be to support |
@robwormald As this plugin can be configured to resolve ids according to the If it's a small change which will be useful also outside of Angular, go ahead and create a PR. I'm assuming it'd be useful for other users of scoped packages. 👍 @IgorMinar Supporting a proper standard, be it |
our problem is that we have a quite hard requirement to support deep imports for various environments, so not only we are trying to support cjs and esm builds but also we want need to support imports from |
Is this still relevant? |
Perhaps |
This isn't strictly node resolution, but I figure this is as close a place as any.
Situation:
Angular2's codebase distributes es modules in a subdirectory
/esm
and denotes thejsnext:main
field in the package.json.This works well, except for our compiler-generated code outputs code that uses deep imports (which is a much longer story...), so whereas most userland code does stuff like:
which resolves fine via
jsnext:main
and this plugin, our generated code does stuff likewhich of course fails to resolve properly. I implemented a simple plugin that did a path rewrite, but that seems to confuse rollup's symbol resolution, so I end up with multiple copies of imports, which breaks all kinds of things. None of this is particularly unexpected.
On a whim, I dug into the source of this plugin today and moved my dirty hack into the
_resolveId
function, leveragingpath-resolve
's pathFilter function to rewrite the path internally, relative to thejsnext:main
file, and lo and behold my issue is solved.Would a PR be accepted to enable this behavior? Or should this already work? Or is it out of scope of this plugin?
tldr: basically, i want to leverage
jsnext:main
to rewrite all imports into a package relative to the es module main entry point, rather than just the main.The text was updated successfully, but these errors were encountered: