Skip to content

Conversation

merceyz
Copy link
Contributor

@merceyz merceyz commented Feb 9, 2020

Q                       A
Patch: Bug Fix? Yes
Any Dependency Changes? Yes
License MIT

Jest (@SimenB) is testing Yarn 2 (jestjs/jest#9476) and their TypeScript build failed because @babel/parser is missing a dependency on @babel/types.

@nicolo-ribaudo
Copy link
Member

I'm wondering how it's possible that I didn't notice it while testing yarn 2 on this repository 🤔

@merceyz
Copy link
Contributor Author

merceyz commented Feb 9, 2020

It's only required in the typescript types.

/**
* Parse the provided code as an entire ECMAScript program.
*/
export function parse(input: string, options?: ParserOptions): import('@babel/types').File;
/**
* Parse the provided code as a single expression.
*/
export function parseExpression(input: string, options?: ParserOptions): import('@babel/types').Expression;

@nicolo-ribaudo
Copy link
Member

Oh right, I forgot about it. Related: #10315, #9924.

I don't think that we should add a whole dependency only used for TS types. I think that we have 3 options:

  • Add @babel/types in optionalPeerDependencies. Users using TS can then add @babel/types to their dependencies.
  • Publish a package only with the type definitions
  • Copy the .d.ts file from @babel/types to @babel/parser when publishing.

cc @babel/babel

@ljharb
Copy link
Member

ljharb commented Feb 9, 2020

Is there an optionalPeerDependencies? I think you'd need to add it in peerDeps, and then mark it optional in peerDepsMeta (which would make it required for older npm users).

@nicolo-ribaudo
Copy link
Member

Is there an optionalPeerDependencies?

It was in my search history and I assumed that it existed 😅

which would make it required for older npm users

We are dropping Node.js <10.13 in Babel 8, and v10.13.0 has npm v6.12.0 which supports peerDepsMeta. However, I think that this is sub-optimal and I would prefer my third suggestion.

SimenB added a commit to SimenB/jest that referenced this pull request Jul 5, 2020
SimenB added a commit to SimenB/jest that referenced this pull request Jul 5, 2020
SimenB added a commit to SimenB/jest that referenced this pull request Jul 5, 2020
SimenB added a commit to SimenB/jest that referenced this pull request Jul 16, 2020
SimenB added a commit to SimenB/jest that referenced this pull request Jul 24, 2020
Copy link

@sunlaiman sunlaiman left a comment

Choose a reason for hiding this comment

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

Copy link

@sunlaiman sunlaiman left a comment

Choose a reason for hiding this comment

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

merceyz:parser-types #11118 parser-types

SimenB added a commit to SimenB/jest that referenced this pull request Jul 30, 2020
SimenB added a commit to SimenB/jest that referenced this pull request Aug 23, 2020
SimenB added a commit to SimenB/jest that referenced this pull request Oct 29, 2020
@merceyz merceyz deleted the parser-types branch July 30, 2024 12:34
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 30, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants