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

Copy webServer from Typescript to VS Code #165771

Merged
merged 10 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/gulpfile.extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const compilations = [
'references-view/tsconfig.json',
'simple-browser/tsconfig.json',
'typescript-language-features/test-workspace/tsconfig.json',
'typescript-language-features/web/tsconfig.json',
'typescript-language-features/tsconfig.json',
'vscode-api-tests/tsconfig.json',
'vscode-colorize-tests/tsconfig.json',
Expand Down
1 change: 0 additions & 1 deletion extensions/postinstall.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ function processRoot() {
function processLib() {
const toDelete = new Set([
'tsc.js',
'tsserverlibrary.js',
sandersn marked this conversation as resolved.
Show resolved Hide resolved
'typescriptServices.js',
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ module.exports = withBrowserDefaults({
new CopyPlugin({
patterns: [
{
from: '../node_modules/typescript/lib/tsserver.js',
from: '../node_modules/typescript/lib/tsserverlibrary.js',
to: 'typescript/tsserver.web.js',
transform: async (content) => {
const dynamicImportCompatPath = path.join(__dirname, '..', 'node_modules', 'typescript', 'lib', 'dynamicImportCompat.js');
const prefix = fs.existsSync(dynamicImportCompatPath) ? fs.readFileSync(dynamicImportCompatPath) : undefined;
const hostpath = path.join(__dirname, 'web', 'out', 'webServer.js');
const host = fs.existsSync(hostpath) ? fs.readFileSync(hostpath) : undefined;
const output = await Terser.minify(content.toString());
Copy link
Member Author

Choose a reason for hiding this comment

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

withBrowserDefaults doesn't minify because it sets mode: none, but there's a comment that says mode: production will minify. So I didn't include a minify entry in tsserver.web.js' config.

if (!output.code) {
throw new Error('Terser returned undefined code');
}

if (prefix) {
return prefix.toString() + '\n' + output.code;
if (host) {
return output.code + '\n' + host;
}
return output.code;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import * as vscode from 'vscode';

declare const navigator: unknown;
export function isWeb(): boolean {
// @ts-expect-error
sandersn marked this conversation as resolved.
Show resolved Hide resolved
return typeof navigator !== 'undefined' && vscode.env.uiKind === vscode.UIKind.Web;
}
15 changes: 15 additions & 0 deletions extensions/typescript-language-features/web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../../out",
"module": "nodenext",
"moduleDetection": "legacy",
"experimentalDecorators": true,
"types": [
"node"
]
},
"files": [
"webServer.ts"
]
}
Loading