Skip to content

Commit 41cdd51

Browse files
authored
Merge pull request microsoft#166364 from microsoft/revert-165771-tsserver-webhost
Revert "Copy webServer from Typescript to VS Code"
2 parents 49068d8 + b11207c commit 41cdd51

File tree

9 files changed

+54
-578
lines changed

9 files changed

+54
-578
lines changed

build/gulpfile.extensions.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ const compilations = [
6464
'references-view/tsconfig.json',
6565
'simple-browser/tsconfig.json',
6666
'typescript-language-features/test-workspace/tsconfig.json',
67-
'typescript-language-features/web/tsconfig.json',
6867
'typescript-language-features/tsconfig.json',
6968
'vscode-api-tests/tsconfig.json',
7069
'vscode-colorize-tests/tsconfig.json',

build/lib/extensions.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,14 +414,19 @@ async function webpackExtensions(taskName, isWatch, webpackConfigLocations) {
414414
const webpackConfigs = [];
415415
for (const { configPath, outputRoot } of webpackConfigLocations) {
416416
const configOrFnOrArray = require(configPath);
417-
function addConfig(configOrFnOrArray) {
418-
for (const configOrFn of Array.isArray(configOrFnOrArray) ? configOrFnOrArray : [configOrFnOrArray]) {
419-
const config = typeof configOrFn === 'function' ? configOrFn({}, {}) : configOrFn;
420-
if (outputRoot) {
421-
config.output.path = path.join(outputRoot, path.relative(path.dirname(configPath), config.output.path));
422-
}
417+
function addConfig(configOrFn) {
418+
let config;
419+
if (typeof configOrFn === 'function') {
420+
config = configOrFn({}, {});
423421
webpackConfigs.push(config);
424422
}
423+
else {
424+
config = configOrFn;
425+
}
426+
if (outputRoot) {
427+
config.output.path = path.join(outputRoot, path.relative(path.dirname(configPath), config.output.path));
428+
}
429+
webpackConfigs.push(configOrFn);
425430
}
426431
addConfig(configOrFnOrArray);
427432
}

build/lib/extensions.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -506,14 +506,20 @@ export async function webpackExtensions(taskName: string, isWatch: boolean, webp
506506

507507
for (const { configPath, outputRoot } of webpackConfigLocations) {
508508
const configOrFnOrArray = require(configPath);
509-
function addConfig(configOrFnOrArray: webpack.Configuration | ((env: unknown,args: unknown) => webpack.Configuration) | webpack.Configuration[]) {
510-
for (const configOrFn of Array.isArray(configOrFnOrArray) ? configOrFnOrArray : [configOrFnOrArray]) {
511-
const config = typeof configOrFn === 'function' ? configOrFn({}, {}) : configOrFn;
512-
if (outputRoot) {
513-
config.output!.path = path.join(outputRoot, path.relative(path.dirname(configPath), config.output!.path!));
514-
}
509+
function addConfig(configOrFn: webpack.Configuration | Function) {
510+
let config;
511+
if (typeof configOrFn === 'function') {
512+
config = (configOrFn as Function)({}, {});
515513
webpackConfigs.push(config);
514+
} else {
515+
config = configOrFn;
516516
}
517+
518+
if (outputRoot) {
519+
config.output.path = path.join(outputRoot, path.relative(path.dirname(configPath), config.output.path));
520+
}
521+
522+
webpackConfigs.push(configOrFn);
517523
}
518524
addConfig(configOrFnOrArray);
519525
}

extensions/.vscodeignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

extensions/postinstall.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function processRoot() {
2626
function processLib() {
2727
const toDelete = new Set([
2828
'tsc.js',
29+
'tsserverlibrary.js',
2930
'typescriptServices.js',
3031
]);
3132

extensions/typescript-language-features/.vscodeignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
build/**
22
src/**
3-
web/**
43
test/**
54
test-workspace/**
65
out/**

extensions/typescript-language-features/extension-browser.webpack.config.js

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
'use strict';
99
const CopyPlugin = require('copy-webpack-plugin');
10+
const Terser = require('terser');
11+
const fs = require('fs');
1012
const path = require('path');
1113

1214
const defaultConfig = require('../shared.webpack.config');
@@ -28,7 +30,8 @@ const languages = [
2830
'tr',
2931
'zh-cn',
3032
];
31-
module.exports = [withBrowserDefaults({
33+
34+
module.exports = withBrowserDefaults({
3235
context: __dirname,
3336
entry: {
3437
extension: './src/extension.browser.ts',
@@ -57,21 +60,30 @@ module.exports = [withBrowserDefaults({
5760
}))
5861
],
5962
}),
63+
// @ts-ignore
64+
new CopyPlugin({
65+
patterns: [
66+
{
67+
from: '../node_modules/typescript/lib/tsserver.js',
68+
to: 'typescript/tsserver.web.js',
69+
transform: async (content) => {
70+
const dynamicImportCompatPath = path.join(__dirname, '..', 'node_modules', 'typescript', 'lib', 'dynamicImportCompat.js');
71+
const prefix = fs.existsSync(dynamicImportCompatPath) ? fs.readFileSync(dynamicImportCompatPath) : undefined;
72+
const output = await Terser.minify(content.toString());
73+
if (!output.code) {
74+
throw new Error('Terser returned undefined code');
75+
}
76+
77+
if (prefix) {
78+
return prefix.toString() + '\n' + output.code;
79+
}
80+
return output.code;
81+
},
82+
transformPath: (targetPath) => {
83+
return targetPath.replace('tsserver.js', 'tsserver.web.js');
84+
}
85+
}
86+
],
87+
}),
6088
],
61-
}), withBrowserDefaults({
62-
context: __dirname,
63-
entry: {
64-
'typescript/tsserver.web': './web/webServer.ts'
65-
},
66-
ignoreWarnings: [/Critical dependency: the request of a dependency is an expression/],
67-
output: {
68-
// all output goes into `dist`.
69-
// packaging depends on that and this must always be like it
70-
filename: '[name].js',
71-
path: path.join(__dirname, 'dist', 'browser'),
72-
libraryTarget: undefined,
73-
},
74-
externals: {
75-
'perf_hooks': 'commonjs perf_hooks',
76-
}
77-
})];
89+
});

extensions/typescript-language-features/web/tsconfig.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)