Skip to content

Commit

Permalink
Ensure 'undefined' does not make it into tsserver.web.js (#164064)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey committed Oct 19, 2022
1 parent bebb3ea commit b99cf7e
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit b99cf7e

Please sign in to comment.