Skip to content

Fix the self type module resolution issue#4689

Closed
MaryGao wants to merge 5 commits intomainfrom
fix-self-module-resolution-issue
Closed

Fix the self type module resolution issue#4689
MaryGao wants to merge 5 commits intomainfrom
fix-self-module-resolution-issue

Conversation

@MaryGao
Copy link
Member

@MaryGao MaryGao commented Oct 11, 2024

See comment. In resolveSelf we should traverse all possible dirs to find potential module, not directly skip continuing loop when find one package.json file.

@microsoft-github-policy-service microsoft-github-policy-service bot added the compiler:core Issues for @typespec/compiler label Oct 11, 2024
@azure-sdk
Copy link
Collaborator

azure-sdk commented Oct 11, 2024

All changed packages have been documented.

  • @typespec/compiler
Show changes

@typespec/compiler - fix ✏️

Fix module resolution issue for self type module

@MaryGao MaryGao changed the title Update the fix Fix the module resolution issue for self type resolution Oct 11, 2024
@MaryGao MaryGao changed the title Fix the module resolution issue for self type resolution Fix the self type module resolution issue Oct 11, 2024
@MaryGao MaryGao marked this pull request as ready for review October 11, 2024 05:14
@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 📚 Next docs

return undefined;
}
if (pkg.name !== name) continue;
return loadPackage(dir, pkg);
Copy link
Member

Choose a reason for hiding this comment

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

I think the way it is done now is the correct way according the the node resolution spec, you only lookup to the first parent package.json for resolving self. What is the use case?

Copy link
Member Author

Choose a reason for hiding this comment

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

The case happened in our cadl-ranch test where during generation our emitter dist code is in the same folder with tsp code and emitter is not released yet.

@timotheeguerin timotheeguerin changed the base branch from main to release/october-2024 October 11, 2024 15:50
@timotheeguerin timotheeguerin changed the base branch from release/october-2024 to main October 11, 2024 15:50
@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

@timotheeguerin
Copy link
Member

We'll discuss later on this should have been an allowed feature or not, took your fix and made it in the correct branch #4697

@archerzz
Copy link
Member

I agree with @timotheeguerin on the change. We should follow the convention of how a node module is resolved. In csharp emitter, we fixed the build error by specifying the absolute path: 0b02283 (#4693)

@archerzz
Copy link
Member

Correction. To follow node module convention, we need to fix our pipeline as well. Because in some regen steps, the emitter module is downloaded as build artifact, and we need to know the path to it: https://dev.azure.com/azure-sdk/public/_build/results?buildId=4226197&view=logs&j=ad8522ef-ffaf-59d1-5ee5-3e85b44db816&t=237d07e5-d6e4-537a-487e-2d10838f2a6b

@timotheeguerin timotheeguerin deleted the fix-self-module-resolution-issue branch March 12, 2025 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:core Issues for @typespec/compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants