mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 04:09:28 +00:00
Add patch for enabling new TS plugins on web approach (#149186)
* Add patch for enabling new TS plugins on web approach https://github.com/microsoft/TypeScript/pull/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
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
'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');
|
||||
const withBrowserDefaults = defaultConfig.browser;
|
||||
@@ -64,9 +66,12 @@ module.exports = withBrowserDefaults({
|
||||
{
|
||||
from: '../node_modules/typescript/lib/tsserver.js',
|
||||
to: 'typescript/tsserver.web.js',
|
||||
transform: (content) => {
|
||||
return Terser.minify(content.toString()).then(output => output.code);
|
||||
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());
|
||||
|
||||
return prefix + '\n' + output.code;
|
||||
},
|
||||
transformPath: (targetPath) => {
|
||||
return targetPath.replace('tsserver.js', 'tsserver.web.js');
|
||||
|
||||
Reference in New Issue
Block a user