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

patch(): pass filename to transform func #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ShaMan123
Copy link

@ShaMan123 ShaMan123 commented Jul 19, 2023

Motivation

When transforming relative files it is crucial to have the filename accessible to make decisions.
Extremely useful when using only babel + module scripts + importmaps

Changes

Passed the full filename for the state to the function.
Tried to add a test but it doesn't have the state as it does in a real call.
Also, I made the transformer skip the transformed imports.

@ShaMan123
Copy link
Author

ShaMan123 commented Jul 19, 2023

Also I think using path.replaceWithMultiple is bad beause it traverses the replacement as well (which might cause an infinite loop and is just wasteful)
https://github.com/babel/babel/blob/0345c1bc1ded6af8d66f8605e6fdbeeb9b70c5b3/packages/babel-traverse/src/path/replacement.js#L179

Fixed by b14734f

Copy link
Author

@ShaMan123 ShaMan123 left a comment

Choose a reason for hiding this comment

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

This is ready

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.

1 participant