-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Changes from all commits
be55639
4b4ca3d
dc3c717
a9ce12d
c44d4c4
1094941
d751d5c
8a2f514
356d5a3
9dae7d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/typescript/lib/tsc.js | ||
node_modules/typescript/lib/typescriptServices.js | ||
node_modules/typescript/lib/tsserverlibrary.js |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
build/** | ||
src/** | ||
web/** | ||
test/** | ||
test-workspace/** | ||
out/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,6 @@ | |
|
||
'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'); | ||
|
@@ -30,8 +28,7 @@ const languages = [ | |
'tr', | ||
'zh-cn', | ||
]; | ||
|
||
module.exports = withBrowserDefaults({ | ||
module.exports = [withBrowserDefaults({ | ||
context: __dirname, | ||
entry: { | ||
extension: './src/extension.browser.ts', | ||
|
@@ -60,30 +57,21 @@ 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()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. withBrowserDefaults doesn't minify because it sets |
||
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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. withBrowserDefaults sets There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's correct for all callers because they should all be extensions, which even on web are CJS (they are executed in a funky eval environment). |
||
}, | ||
externals: { | ||
'perf_hooks': 'commonjs perf_hooks', | ||
} | ||
})]; |
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" | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the webpack configs. None of them pass functions, which is good, because this code double-pushed function configs.
Nothing sets
outputRoot
that I could see, so theif (outputRoot)
code is just-in-case. I left it because I don't know what it's supposed to do.