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
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,20 @@ 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 hostpath = path.join(__dirname, 'out', 'tsServer', 'webServer.js');
sandersn marked this conversation as resolved.
Show resolved Hide resolved
const prefix = fs.existsSync(dynamicImportCompatPath) ? fs.readFileSync(dynamicImportCompatPath) : undefined;
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 (prefix && host) {
return prefix.toString() + '\n' + output.code + '\n' + host;
}
return output.code;
},
Expand Down
Loading