Skip to content

Commit

Permalink
Revert "Copy webServer from Typescript to VS Code (#165771)"
Browse files Browse the repository at this point in the history
This reverts commit cb43019.
  • Loading branch information
hediet authored Nov 15, 2022
1 parent 02a64e1 commit b11207c
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 578 deletions.
1 change: 0 additions & 1 deletion build/gulpfile.extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ 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
17 changes: 11 additions & 6 deletions build/lib/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,14 +414,19 @@ async function webpackExtensions(taskName, isWatch, webpackConfigLocations) {
const webpackConfigs = [];
for (const { configPath, outputRoot } of webpackConfigLocations) {
const configOrFnOrArray = require(configPath);
function addConfig(configOrFnOrArray) {
for (const configOrFn of Array.isArray(configOrFnOrArray) ? configOrFnOrArray : [configOrFnOrArray]) {
const config = typeof configOrFn === 'function' ? configOrFn({}, {}) : configOrFn;
if (outputRoot) {
config.output.path = path.join(outputRoot, path.relative(path.dirname(configPath), config.output.path));
}
function addConfig(configOrFn) {
let config;
if (typeof configOrFn === 'function') {
config = configOrFn({}, {});
webpackConfigs.push(config);
}
else {
config = configOrFn;
}
if (outputRoot) {
config.output.path = path.join(outputRoot, path.relative(path.dirname(configPath), config.output.path));
}
webpackConfigs.push(configOrFn);
}
addConfig(configOrFnOrArray);
}
Expand Down
18 changes: 12 additions & 6 deletions build/lib/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,14 +506,20 @@ export async function webpackExtensions(taskName: string, isWatch: boolean, webp

for (const { configPath, outputRoot } of webpackConfigLocations) {
const configOrFnOrArray = require(configPath);
function addConfig(configOrFnOrArray: webpack.Configuration | ((env: unknown,args: unknown) => webpack.Configuration) | webpack.Configuration[]) {
for (const configOrFn of Array.isArray(configOrFnOrArray) ? configOrFnOrArray : [configOrFnOrArray]) {
const config = typeof configOrFn === 'function' ? configOrFn({}, {}) : configOrFn;
if (outputRoot) {
config.output!.path = path.join(outputRoot, path.relative(path.dirname(configPath), config.output!.path!));
}
function addConfig(configOrFn: webpack.Configuration | Function) {
let config;
if (typeof configOrFn === 'function') {
config = (configOrFn as Function)({}, {});
webpackConfigs.push(config);
} else {
config = configOrFn;
}

if (outputRoot) {
config.output.path = path.join(outputRoot, path.relative(path.dirname(configPath), config.output.path));
}

webpackConfigs.push(configOrFn);
}
addConfig(configOrFnOrArray);
}
Expand Down
3 changes: 0 additions & 3 deletions extensions/.vscodeignore

This file was deleted.

1 change: 1 addition & 0 deletions extensions/postinstall.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function processRoot() {
function processLib() {
const toDelete = new Set([
'tsc.js',
'tsserverlibrary.js',
'typescriptServices.js',
]);

Expand Down
1 change: 0 additions & 1 deletion extensions/typescript-language-features/.vscodeignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
build/**
src/**
web/**
test/**
test-workspace/**
out/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

'use strict';
const CopyPlugin = require('copy-webpack-plugin');
const Terser = require('terser');
const fs = require('fs');
const path = require('path');

const defaultConfig = require('../shared.webpack.config');
Expand All @@ -28,7 +30,8 @@ const languages = [
'tr',
'zh-cn',
];
module.exports = [withBrowserDefaults({

module.exports = withBrowserDefaults({
context: __dirname,
entry: {
extension: './src/extension.browser.ts',
Expand Down Expand Up @@ -57,21 +60,30 @@ module.exports = [withBrowserDefaults({
}))
],
}),
// @ts-ignore
new CopyPlugin({
patterns: [
{
from: '../node_modules/typescript/lib/tsserver.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 output = await Terser.minify(content.toString());
if (!output.code) {
throw new Error('Terser returned undefined code');
}

if (prefix) {
return prefix.toString() + '\n' + output.code;
}
return output.code;
},
transformPath: (targetPath) => {
return targetPath.replace('tsserver.js', 'tsserver.web.js');
}
}
],
}),
],
}), withBrowserDefaults({
context: __dirname,
entry: {
'typescript/tsserver.web': './web/webServer.ts'
},
ignoreWarnings: [/Critical dependency: the request of a dependency is an expression/],
output: {
// all output goes into `dist`.
// packaging depends on that and this must always be like it
filename: '[name].js',
path: path.join(__dirname, 'dist', 'browser'),
libraryTarget: undefined,
},
externals: {
'perf_hooks': 'commonjs perf_hooks',
}
})];
});
15 changes: 0 additions & 15 deletions extensions/typescript-language-features/web/tsconfig.json

This file was deleted.

Loading

0 comments on commit b11207c

Please sign in to comment.