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

Resolve transitive dependencies based on package.json #3286

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

Conversation

seanoch
Copy link

@seanoch seanoch commented Dec 16, 2024

When the newly added resolveDependenciesFromPackageJson flag is set to true, ATA will resolve the versions of any transitive dependency according to the package.json file of the same module (unless any // types: comment is specified).

Resolve transitive dependencies' versions based on package.json
@seanoch
Copy link
Author

seanoch commented Dec 16, 2024

@microsoft-github-policy-service agree company="wix"

@seanoch seanoch changed the title Support transitive dependencies Resolve transitive dependencies based on pacakge.json Dec 16, 2024
Copy link

@tomenden tomenden left a comment

Choose a reason for hiding this comment

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

See small comments regarding naming.
I suggest adding a bit more context in the PR description to explain the motivation. I think an example will help the typescript team understand what you did here

packages/ata/src/index.ts Outdated Show resolved Hide resolved
Comment on lines 146 to 149
let typesPackageJson
if (config.usePackageJson){
typesPackageJson = moduleMap.get(dts.moduleName)?.typesPackageJson
}

Choose a reason for hiding this comment

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

Suggested change
let typesPackageJson
if (config.usePackageJson){
typesPackageJson = moduleMap.get(dts.moduleName)?.typesPackageJson
}
const typesPackageJson = config.usePackageJson && moduleMap.get(dts.moduleName)?.typesPackageJson

packages/ata/src/index.ts Outdated Show resolved Hide resolved
@jakebailey
Copy link
Member

To be clear, is the intent here to ensure that all dependencies are loaded transitively?

Should this flag be set for the website? Should it be disabled at all?

@seanoch
Copy link
Author

seanoch commented Dec 17, 2024

@jakebailey The intent is to allow resolution of transitive (indirect) dependencies according to their module's package.json file. Before this change, any indirect dependency gets resolved to latest, since the only way to control versioning is via the // types: comment, which is controllable only in the first input file.

For example, if the input file says import a from 'PackageA', and some of PackageA's types imports from PackageB -

  • Before this change, any d.ts from PackageB will be resolved to PackageB@latest
  • After this change, any d.ts from PackageB will be resolved to the version of PackageB that is specified in PackageA's package.json.

@jakebailey jakebailey changed the title Resolve transitive dependencies based on pacakge.json Resolve transitive dependencies based on package.json Dec 17, 2024
@seanoch
Copy link
Author

seanoch commented Dec 23, 2024

@jakebailey Hi, is any additional explanation needed before a review?

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.

3 participants