Skip to content

Commit

Permalink
Adds build hack because of vsls package issues
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Dec 27, 2018
1 parent d5d4a3e commit c72a824
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)];
};

Expand Down

0 comments on commit c72a824

Please sign in to comment.