Ensure 'undefined' does not make it into tsserver.web.js (#164064)

This commit is contained in:
Jake Bailey
2022-10-19 16:44:03 -07:00
committed by GitHub
parent bebb3ea217
commit b99cf7e41e

View File

@@ -70,8 +70,14 @@ module.exports = withBrowserDefaults({
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');
}
return prefix + '\n' + output.code;
if (prefix) {
return prefix.toString() + '\n' + output.code;
}
return output.code;
},
transformPath: (targetPath) => {
return targetPath.replace('tsserver.js', 'tsserver.web.js');