You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Relative path '.' is transpiled to package.json main field #415
And I have a main field specified in my package.json: "main": "src/main.js". If I have a relative import of index.js in SomeModule.js, it gets transpiled to the main field from the package.json.
importutilsfrom'.';// gets transpiled to '../../main'importutilsfrom'./';// works
Will try to look into where the resolution is coming from a bit more after work today.
Reacted by Fernando Maia, Dale Seo and Gabriel Rohden
Replacing custom matcher with !path.isAbsolutePath() (reference)
Refining the regex to make slash optional
This leads me to a question: is there a reason to have a custom matcher? Is there any use case where resolving . to the current package.json main entry is the desired behavior?
Activity
fsmaia commentedon Feb 18, 2021
Just found where it is coming from:
babel-plugin-module-resolver/src/utils.js
Line 13 in f533cc2
The method
isRelativePathisn't matching..fsmaia commentedon Feb 18, 2021
Fix suggestions:
!path.isAbsolutePath()(reference)This leads me to a question: is there a reason to have a custom matcher? Is there any use case where resolving
.to the current package.json main entry is the desired behavior?fsmaia commentedon Feb 18, 2021
Too late I guess 😆
This is a duplicate of #373, and it will be fixed on #409.