Repository navigation
Only import types from declared dependencies - #16494
Merged
Merged
Conversation
nicolo-ribaudo
force-pushed
the
no-missing-deps
branch
from
May 15, 2024 11:42
cc21a3b to
1519a1b
Compare
Collaborator
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/57017 |
nicolo-ribaudo
marked this pull request as draft
May 15, 2024 16:57
nicolo-ribaudo
force-pushed
the
no-missing-deps
branch
from
May 22, 2024 06:51
d550a2f to
f3fd184
Compare
nicolo-ribaudo
commented
May 22, 2024
| @@ -1,3 +1,4 @@ | |||
| // eslint-disable-next-line import/no-extraneous-dependencies -- TODO: Avoid cycle | |||
Member
Author
There was a problem hiding this comment.
There are 4 packages whose types circularly depend on @babel/traverse. Lets just ignore those errors for now (@babel/traverse will be in the dependencies anyway), but I will think of a better solution before going stable.
nicolo-ribaudo
marked this pull request as ready for review
May 22, 2024 14:45
JLHwung
approved these changes
May 30, 2024
liuxingbaoyu
approved these changes
May 30, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1, Fixes #2This PR makes sure that all our
import types only reference packages that are listed independencies/peerDependencies. This is done mainly in two ways:@babel/core, so they can importNodePath/Visitor/Scope/typesfrom there rather than from@babel/traverse/@babel/types@babel/traverse/@babel/types: if a helper expects aNodePathas a parameter, you already have to have@babel/traverse/@babel/typesin your dependencies so this is not causing extra deps.To (2) there are some exceptions:
babel-helper-builder-react-jsxandbabel-helper-plugin-utilsonly make sense when using with a full plugin (and not directly with parser+traverse), so I added@babel/coreas a peer dependency (but only for Babel 8)babel-helper-fixturesis also only needed when testing plugins, so I added@babel/coreas a peer depThis PR doesn't lint
@babel/standaloneand@babel/parsersince those are bundled, but we should probably add@babel/typesas a dependency of@babel/parser. I don't really like doing it since it's perfectly reasonable to use@babel/parserwithout also using@babel/types, but on the other hand if the dependency is only used inimport typeit won't actually affect anything at runtime (it won't be loaded) so adding it is not too bad.There is one remaining lint error fixed by #16493.