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

Add a missing dependency on @babel/types to @babel/parser #15042

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Member

@Andarist Andarist commented Oct 14, 2022

This is an actual dependency of the typings contained in this package and thus should be declared explicitly:

): ParseResult<import("@babel/types").File>;

Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix? x
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes? x
License MIT

@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/53151/

@JLHwung
Copy link
Contributor

JLHwung commented Oct 14, 2022

cf. #10315, #9924

@Andarist
Copy link
Member Author

I see the concern with the added dependency - but without this, it just doesn't work with strict package managers and can cause some weird issues in the ones that rely on the flattened node_modules. I had an issue today where different packages were accidentally loading @babel/types from different locations and thus causing type issues because those types were not quite compatible. This wouldn't happen if the dependency would be declared explicitly.

@liuxingbaoyu
Copy link
Member

I personally prefer to remove the import and return any or {type:xxx...}.

@merceyz
Copy link
Contributor

merceyz commented Oct 15, 2022

but without this, it just doesn't work with strict package managers

While that is correct both Yarn and pnpm declare this dependency automatically so in this case they're not affected.
https://github.com/yarnpkg/berry/blob/444eea50e8bdbd8c6a3afef51633a011e4f30069/packages/yarnpkg-extensions/sources/index.ts#L160-L165

@liuxingbaoyu
Copy link
Member

liuxingbaoyu commented Oct 29, 2022

I've looked at the past two PRs and it seems that only bundling of types is an acceptable solution.
Currently I'm doing something similar in #15094, if we want the types of @babel/types to be bundled together as well, then I don't have to try to suppress the error warning from ts . (see Failed CI)

Thanks to merceyz for the information, in my opinion, since yarn and pnpm already have @babel/types as a dependency, it is acceptable for us to add it.
But maybe packaging the types can report some compatibility issues for users, I'm not sure about that.

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.

None yet

5 participants