From c72a824f76bd68664988699244eba87a111e582d Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Thu, 27 Dec 2018 00:30:35 -0500 Subject: [PATCH] Adds build hack because of vsls package issues --- webpack.config.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/webpack.config.js b/webpack.config.js index 0b623d0..5c2716d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -19,6 +19,38 @@ module.exports = function(env, argv) { env.optimizeImages = true; } + // TODO: Total and complete HACK until the following vsls issues are resolved + // https://github.com/MicrosoftDocs/live-share/issues/1334 & https://github.com/MicrosoftDocs/live-share/issues/1335 + + const vslsPatchRegex = /const liveShareApiVersion = require\(path\.join\(__dirname, 'package\.json'\)\)\.version;/; + + let vslsPath = path.resolve(__dirname, 'node_modules/vsls/package.json'); + if (fs.existsSync(vslsPath)) { + const vsls = require(vslsPath); + if (vsls.main === undefined) { + vsls.main = 'vscode.js'; + fs.writeFileSync(vslsPath, `${JSON.stringify(vsls, undefined, 4)}\n`, 'utf8'); + } + + vslsPath = path.resolve(__dirname, 'node_modules/vsls/vscode.js'); + if (fs.existsSync(vslsPath)) { + console.log(vslsPath); + + let code = fs.readFileSync(vslsPath, 'utf8'); + if (vslsPatchRegex.test(code)) { + console.log('found'); + code = code.replace( + vslsPatchRegex, + `const liveShareApiVersion = '${ + vsls.version + }'; // require(path.join(__dirname, 'package.json')).version;` + ); + console.log(code); + fs.writeFileSync(vslsPath, code, 'utf8'); + } + } + } + return [getExtensionConfig(env), getUIConfig(env)]; };