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

fix: dependency submodules may not be discovered #3151

Merged
merged 7 commits into from
Nov 10, 2021

Conversation

RomainMuller
Copy link
Contributor

When a dependency exposes submodules, and the entry point of that
dependency is never imported by the program being compiled, symbols
from the dependency were not correctly mapped to their submodule because
the entry point was not part of the compiler input (and hence the
ts.Program did not hold a ts.SourceFile for it, and the
ts.TypeChecker did not have symbols for exports therein).

In order to address this problem, this always explicitly references
dependencies' entry point (the .d.ts file referenced by the types
key) to the compiler input path. This guarantees the compiler binds
symbols within those, and that the submodule mapper can appropriately
discover those.


An alternative approach was considered (but rejected because it
introduced significant complexity): we could have created
ts.SourceFile objects using ts.createSourceFile, which allows us to
obtain a set of ts.Statement nodes, however those are not bound to
symbols and we then have to process the AST without the assistance of
the type checker (and would end up having to re-implement a sub-set of
the binder/type-checker's features).


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

When a dependency exposes submodules, and the entry point of that
dependency is never imported by the program being compiled, symbols
from the dependency were not correctly mapped to their submodule because
the entry point was not part of the compiler input (and hence the
`ts.Program` did not hold a `ts.SourceFile` for it, and the
`ts.TypeChecker` did not have symbols for exports therein).

In order to address this problem, this always explicitly references
dependencies' entry point (the `.d.ts` file referenced by the `types`
key) to the compiler input path. This guarantees the compiler binds
symbols within those, and that the submodule mapper can appropriately
discover those.

------------------------------------------------------------------------

An alternative approach was considered (but rejected because it
introduced significant complexity): we could have created
`ts.SourceFile` objects using `ts.createSourceFile`, which allows us to
obtain a set of `ts.Statement` nodes, however those are not bound to
symbols and we then have to process the AST without the assistance of
the type checker (and would end up having to re-implement a sub-set of
the binder/type-checker's features).
@RomainMuller RomainMuller requested a review from a team November 10, 2021 10:45
@RomainMuller RomainMuller self-assigned this Nov 10, 2021
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Nov 10, 2021
@rix0rrr rix0rrr added the pr/do-not-merge This PR should not be merged at this time. label Nov 10, 2021
Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

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

Provisional approval if you don't think the previous 2 comments are a concern.

@RomainMuller RomainMuller removed the pr/do-not-merge This PR should not be merged at this time. label Nov 10, 2021
@mergify
Copy link
Contributor

mergify bot commented Nov 10, 2021

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Nov 10, 2021
@mergify
Copy link
Contributor

mergify bot commented Nov 10, 2021

Merging (with squash)...

@mergify mergify bot merged commit 5768bb9 into main Nov 10, 2021
@mergify mergify bot deleted the rmuller/fix-barrel-import branch November 10, 2021 19:03
@mergify
Copy link
Contributor

mergify bot commented Nov 10, 2021

Merging (with squash)...

@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Nov 10, 2021
nija-at pushed a commit that referenced this pull request Nov 15, 2021
This reverts commit 5768bb9.

The commit breaks the build of CDKv2 alpha modules.
see aws/aws-cdk#17502
mergify bot pushed a commit that referenced this pull request Nov 16, 2021
…3170)

This reverts commit 5768bb9.

The commit breaks the build of CDKv2 alpha modules.
see aws/aws-cdk#17502



---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants