Skip to content

Prepare VS Code extension for marketplace preview #884

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

Merged

Conversation

andrewbranch
Copy link
Member

This builds on top of #876 to update strings in the extension, allow resolution of the exe from the @typescript/native-preview package, and make minor UX improvements.

@andrewbranch andrewbranch requested a review from jakebailey May 20, 2025 16:55
const packagePath = workspaceResolve(exe);
const packageJsonPath = vscode.Uri.joinPath(packagePath, "package.json");
const packageJson = JSON.parse(await vscode.workspace.fs.readFile(packageJsonPath).then(buffer => buffer.toString()));
const getExePath = (await import(vscode.Uri.joinPath(packagePath, "lib", "getExePath.js").toString())).default;
Copy link
Member

Choose a reason for hiding this comment

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

Does this require modifying the package to be importable? IIRC this isn't exported on the package. Does this only work because the emitted code is CJS?

We should probably just formally export it (and maybe drop the default export?).

Copy link
Member Author

Choose a reason for hiding this comment

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

No, this works because it’s an absolute path, so the package.json is irrelevant.

Copy link
Member

Choose a reason for hiding this comment

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

Huh, I didn't realize that absolute resolution bypassed export rules.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also relative. Only bare specifiers do the complicated thing. The idea being that ESM resolution should generally be predictable and cheap, but package specifier resolution is what it is.

}

export function getBuiltinExePath(context: vscode.ExtensionContext): string {
return context.asAbsolutePath(path.join("./lib", `tsgo${process.platform === "win32" ? ".exe" : ""}`));
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to be able to move this to node_modules so we can just use resolve, but vsce is making it very hard to do that due to microsoft/vscode-vsce#970, so I think we'll have to keep this for now. Thankfully it's in the VSIX so is changeable, unlike the other resolution algorithm.

Comment on lines +9 to +12
const output = vscode.window.createOutputChannel("typescript-native-preview", "log");
const traceOutput = vscode.window.createOutputChannel("typescript-native-preview (LSP)");
const client = new Client(output, traceOutput);
registerCommands(context, client, output, traceOutput);
Copy link
Member

Choose a reason for hiding this comment

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

Can we defer output window creation until Client actually starts the language server?

For the "show output" command, I think we could just make the command ask the Client for its output window (or undefined).

Probably not required for this PR, though, just noticing it now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe we can just defer the trace output; I have a message in the main output window saying that the extension is disabled whenever typescript.experimental.useTsgo isn’t set.

Copy link
Member

Choose a reason for hiding this comment

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

I don't really mind; this seems fine for now.

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

LGTM; will defer to @DanielRosenwasser about the package.json naming
and stuff.

@@ -1208,6 +1208,6 @@ export const installExtension = task({
console.log(pc.yellowBright("\nExtension installed. ") + "To enable this extension, set:\n");
console.log(pc.whiteBright(` "typescript.experimental.useTsgo": true\n`));
Copy link
Member

Choose a reason for hiding this comment

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

Is this going to be the final setting name?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@DanielRosenwasser DanielRosenwasser May 20, 2025

Choose a reason for hiding this comment

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

@mjbvz can we at least change how this looks on the UI so Tsgo is not awkwardly Pascal-cased?

image

Copy link

Choose a reason for hiding this comment

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

Mentioned here that extensions may not be able to change it: microsoft/vscode#73374

@rzhao271 Can let the TS team know if there's a way around the auto casing in the settings UI

Choose a reason for hiding this comment

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

I see the Tsgo setting in the package.json file.

There's no workaround yet. What is the expected display name, "Use TS Go"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Worth noting users don’t need to see this setting if they use this
image

@andrewbranch andrewbranch merged commit af312b3 into microsoft:jabaile/native-preview May 21, 2025
1 check passed
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.

None yet

5 participants