Skip to content

patch(): pass filename to transform func#3

Open
ShaMan123 wants to merge 4 commits intoviruscamp:masterfrom
ShaMan123:master
Open

patch(): pass filename to transform func#3
ShaMan123 wants to merge 4 commits intoviruscamp:masterfrom
ShaMan123:master

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