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

Use self-export over ./ export #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

guybedford
Copy link

This updates the self-import to use the direct self-export form over using ./ as a placeholder for a self-import.

That require('./') inside of CJS packages with exports still works is a legacy path that we should try and deprecate I think, especially since these specifiers cannot be mapped with import maps.

Copy link
Owner

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not only is this a breaking change, since it won't work in older nodes, but I'm not sure why a relative path wouldn't work with import maps?

Relative paths wil exist forever and can never be deprecated - the solution for forward progress can only ever involve supporting everything that's previously worked.

@guybedford
Copy link
Author

Agreed, although it unfortunately means import maps don't work for CommonJS in Node.js.

@ljharb
Copy link
Owner

ljharb commented Aug 20, 2024

I'm confused; why wouldn't import maps in node work with any node-resolvable path? (just like how in browsers, they can work with any browser-resolvable URL)

@guybedford
Copy link
Author

Exact trailing slash mappings like "./" are not mappable in import maps, so it implies handling elsewhere in the toolchain.

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

Successfully merging this pull request may close these issues.

2 participants