Skip to content

fix: support resolving with import condition - #52

Merged
pi0 merged 10 commits into
mainfrom
feat/esm
Jan 25, 2022
Merged

pi0 merged 10 commits into
mainfrom
feat/esm

Conversation

@antfu

@antfu antfu commented Jan 25, 2022

Copy link
Copy Markdown
Member

We had the problem in Nuxt development that jiti failed to resolve estree-walker, which is due to it only having exports field without main (https://unpkg.com/browse/[email protected]/package.json).

Since we also transpile node modules, making the resolving aware of exports by esm-resolve package is able to fix most of the cases. This also makes the native ESM support a performance improvement instead of a blocker.

Comment thread src/jiti.ts Resolved
Comment thread src/jiti.ts Resolved
@pi0

pi0 commented Jan 25, 2022

Copy link
Copy Markdown
Member

We had the problem in Nuxt development that jiti failed to resolve estree-walker, which is due to it only having exports field without main (https://unpkg.com/browse/[email protected]/package.json).

Actually native require.resolve that is currently being used supports exports field but it uses require condition and estree-walker does not provide it.

@pi0 pi0 changed the title fix: support resolving for exports fix: support resolving with module condition Jan 25, 2022
@pi0 pi0 changed the title fix: support resolving with module condition fix: support resolving with import condition Jan 25, 2022
@antfu

antfu commented Jan 25, 2022

Copy link
Copy Markdown
Member Author

Switched to mlly, but it does not seem to resolve the entry

@pi0

pi0 commented Jan 25, 2022

Copy link
Copy Markdown
Member

Switched to mlly, but it does not seem to resolve the entry

We need to fallback to ['node', 'import'] condition to fix estree-walker issue :D

@antfu

antfu commented Jan 25, 2022

Copy link
Copy Markdown
Member Author

Should be good now, thanks for the help :)

@pi0
pi0 merged commit 1e1bb0c into main Jan 25, 2022
@pi0
pi0 deleted the feat/esm branch January 25, 2022 14:24
@pi0

pi0 commented Jan 26, 2022

Copy link
Copy Markdown
Member

Because of side-effects to legacy users, moved this under a flag (https://github.com/unjs/jiti#esmresolve). Let's enable in next major version by default with more tests.

@1natsu172 1natsu172 mentioned this pull request Aug 20, 2024
1 task done
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