From 4b8d28103d5845016f5fcc031101e20eb1aab843 Mon Sep 17 00:00:00 2001 From: Peter van Gulik Date: Thu, 29 Sep 2022 15:44:27 +0200 Subject: [PATCH] fix: vscode extension fails to start due to canvas dependency being incorrectly required by jsdom --- packages/cli/webpack/webpack.ts | 7 +++++-- packages/vscode-extension/webpack/webpack.common.ts | 11 +++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/cli/webpack/webpack.ts b/packages/cli/webpack/webpack.ts index bb26f354..e0667f07 100644 --- a/packages/cli/webpack/webpack.ts +++ b/packages/cli/webpack/webpack.ts @@ -9,8 +9,7 @@ import * as packageJson from '../package.json'; const packageExternals = [ 'vscode', 'vscode-languageclient', - 'electron', - 'canvas' + 'electron' ]; const contextFolder = path.resolve(__dirname, '..'); @@ -102,6 +101,10 @@ const common : webpack.Configuration = { }, plugins: [ new WatchMarkersPlugin(), + new webpack.IgnorePlugin({ + resourceRegExp: /^canvas$/, + contextRegExp: /jsdom$/, + }), new webpack.DefinePlugin({ __webpack_build_info__: JSON.stringify({ version: packageJson.version, diff --git a/packages/vscode-extension/webpack/webpack.common.ts b/packages/vscode-extension/webpack/webpack.common.ts index 9d4fb5fb..300329c4 100644 --- a/packages/vscode-extension/webpack/webpack.common.ts +++ b/packages/vscode-extension/webpack/webpack.common.ts @@ -17,8 +17,7 @@ const packageExternals = [ // VSCode is an external that we do not want to package 'vscode', 'vscode-languageclient', - 'electron', - 'canvas' + 'electron' ]; const contextFolder = path.resolve(__dirname, '..'); @@ -98,7 +97,11 @@ const common : webpack.Configuration = { devtoolModuleFilenameTemplate: '[absolute-resource-path]' }, plugins: [ - new WatchMarkersPlugin() + new WatchMarkersPlugin(), + new webpack.IgnorePlugin({ + resourceRegExp: /^canvas$/, + contextRegExp: /jsdom$/, + }) ], node: { __dirname: false, @@ -162,7 +165,7 @@ const common : webpack.Configuration = { externals: function({ request }, callback) { const isExternal = packageExternals.some( moduleName => request && new RegExp(`^${moduleName}(/|$)`, 'i').test(request) - ); + ) if (isExternal){ // @ts-ignore return callback(undefined, `commonjs ${request}`);