-
Notifications
You must be signed in to change notification settings - Fork 308
[typespec-vscode] setting custom entrypoint file for tsp project #7929
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
base: main
Are you sure you want to change the base?
[typespec-vscode] setting custom entrypoint file for tsp project #7929
Conversation
All changed packages have been documented.
Show changes
|
You can try these changes here
|
@mzhongl524 pleas try to submit the PR as a draft(Dropdown on the create Pr button) not converting it to a draft otherwise it still request review from everybody immediately. |
.chronus/changes/custom-entrypoint-file-for-tsp-project-2025-6-24-6-57-40 copy.md
Outdated
Show resolved
Hide resolved
.chronus/changes/custom-entrypoint-file-for-tsp-project-2025-6-24-6-57-40.md
Outdated
Show resolved
Hide resolved
…ub.com/mzhongl524/typespec into custom-entrypoint-file-for-tsp-project
…he build error issue of the html-program-viewer package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file name is inconsistent with the file name its testing
import { resolveEntrypointFile } from "../../src/server/entrypoint-resolver.js"; | ||
import type { ServerLog } from "../../src/server/types.js"; | ||
|
||
describe("compiler: server: resolveEntrypointFile", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove top level describe
} | ||
|
||
// If there is no configuration, null is passed in vscode while undefined is passed in the compiler. | ||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we agreed that this should be deleted and entrpoints should just default to main.tsp
above with the package.json being the outerbound regardless
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, we did that change but then realize it breaks the behavior that if user sets nothing but have main defined in package.json instead, it should have higher priority than main.tsp file. so made some change there. thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which does seem expected to me. Can you show a file structure where you think the user wouldn't want that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like below. the entrypoint should be resolved as 'abc.tsp' instead of 'main.tsp' if user doesn't set the entrypoint explicitly in vscode.
-- main.tsp
- abc.tsp
- package.json <-- in the package.json, set the main to 'abc.tsp'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I would expect abc to be the entrypoint. The package.json marks the boundary anyway where packages are installed. They main.tsp most likely is not working.
Package.json is the closest we currently have to make something as a project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, so we need to check the "main.tsp" after the package.json part when the entrypoints are not set explicitly, otherwise if we default to ["main.tsp"] and search for it before the package.json part, the "main.tsp" will be returned (line 34 above) instead of the "abc.tsp".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't that just work if the algorithm is
while dir:
If has tsp main in package.json
Return
If has file in entrypoints(default to main.tsp)
Return
Dir = parent dir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I think if user set the entrypoints in the vscode settings explicitly, it should have higher priority than the tsp main in package.json, so the priority is like
- explicit settings of entrypoint
- tsp main in package.json
- default 'main.tsp' (when nothing set above)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree. If you hit this as said above it most likely will break as dependencies are below.
Packagejson mark the package boundary it doesn't make sense imo it would work outside of it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the search should stop at the package.json level? I agree with that. The pri i mentioned above is in the same dir level, it's something like below in my mind:
while(valid dir || no package.json)
{
check entrypoints explicitly set, return if found
check tsp main in package.json, return if found
check default 'main.tsp' if entrypoints not set explicitly, if found, save as potential entrypoint to be returned
dir = parent dir
}
Fix: #6062
Setting custom entrypoint file for tsp project