-
Notifications
You must be signed in to change notification settings - Fork 205
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
fix: .
and ./
incorrectly converted
#409
base: master
Are you sure you want to change the base?
Conversation
Please add some tests too 🙏 |
Also this should probably affect paths like Now that I think of it, maybe adding an option that introduces this behavior instead of the default one would be the best (because it's non-standard compared to Node resolve algorithm). |
Test Case have been supplemented |
like |
Just for curiosity: why not |
|
Hi all, has this plugin been abandoned? Have not seen any activity in months and this PR has been open since then |
@tleunen just as an example react-native-calendars has this |
@Grohden It's allowed so it should definitely be supported. I agree. Even if it's kind of risky of having circular dependencies. |
Yo, suggestion for maintainers: use prettier or dprint to format the project so we don't have unnecessary changes/noise at PRs (like formatting) Also, for people looking for a patch (for patch package) here's the simple version (its just the if, its basically the same for 4.1.0)
diff --git a/node_modules/babel-plugin-module-resolver/lib/resolvePath.js b/node_modules/babel-plugin-module-resolver/lib/resolvePath.js
index cd53e95..5f17543 100644
--- a/node_modules/babel-plugin-module-resolver/lib/resolvePath.js
+++ b/node_modules/babel-plugin-module-resolver/lib/resolvePath.js
@@ -75,7 +75,11 @@ function resolvePathFromAliasConfig(sourcePath, currentFile, opts) {
}
const resolvers = [resolvePathFromAliasConfig, resolvePathFromRootConfig];
function resolvePath(sourcePath, currentFile, opts) {
- if ((0, _utils.isRelativePath)(sourcePath)) {
+ // https://github.com/tleunen/babel-plugin-module-resolver/pull/409
+ // `.` and `./` are specific paths, we can't transform them
+ const isSpecificPath = sourcePath === '.' || sourcePath === './'
+
+ if ((0, _utils.isRelativePath)(sourcePath) || isSpecificPath) {
return sourcePath;
}
const normalizedOpts = (0, _normalizeOptions.default)(currentFile, opts);
btw, I wonder what kind of changes can be done to make it easier to debug whats being transformed.. I spend the whole day trying to figure out why my test was ending up with a circular import (undefined import values) in a unrelated file.. I at least added a debug flag for my own plugin |
.
and./
are specific paths, we can't transfrom them.There are many projects(example) that use
import xxx from '.'
.Example code:
The directory structure:
Babel config:
Babel Transform Output:
And it should transfrom code
import { name } from './index'
, notimport { name } from './..'