Skip to content

Commit 424fe15

Browse files
authored
Add patch for enabling new TS plugins on web approach (#149186)
* Add patch for enabling new TS plugins on web approach microsoft/TypeScript#47377 To run plugins on web, we need to shim out `dynamicImport`. This is done in a file call `tsserverWeb.js`, which is added by the linked PR * Update for new files names
1 parent 2d5a77a commit 424fe15

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

extensions/typescript-language-features/extension-browser.webpack.config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
'use strict';
99
const CopyPlugin = require('copy-webpack-plugin');
1010
const Terser = require('terser');
11+
const fs = require('fs');
12+
const path = require('path');
1113

1214
const defaultConfig = require('../shared.webpack.config');
1315
const withBrowserDefaults = defaultConfig.browser;
@@ -64,9 +66,12 @@ module.exports = withBrowserDefaults({
6466
{
6567
from: '../node_modules/typescript/lib/tsserver.js',
6668
to: 'typescript/tsserver.web.js',
67-
transform: (content) => {
68-
return Terser.minify(content.toString()).then(output => output.code);
69+
transform: async (content) => {
70+
const dynamicImportCompatPath = path.join(__dirname, '..', 'node_modules', 'typescript', 'lib', 'dynamicImportCompat.js');
71+
const prefix = fs.existsSync(dynamicImportCompatPath) ? fs.readFileSync(dynamicImportCompatPath) : undefined;
72+
const output = await Terser.minify(content.toString());
6973

74+
return prefix + '\n' + output.code;
7075
},
7176
transformPath: (targetPath) => {
7277
return targetPath.replace('tsserver.js', 'tsserver.web.js');

0 commit comments

Comments
 (0)