From 637f3049bd795194912bdbc14798e2a6f1db2368 Mon Sep 17 00:00:00 2001 From: Emelia Smith Date: Wed, 1 Sep 2021 20:22:18 +0200 Subject: [PATCH] Prevent automatic global installation of wasm-pack Installing software globally on a developers' machine as a side-effect of using a webpack plugin is generally a bad idea, especially when they are not informed that this will take place. Instead, it's better to provide instructions as to how someone can install the relevant software, and allow a user to choose. Automatic installation can also be problematic in certain CI environments where there are stricter security requirements. --- plugin.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/plugin.js b/plugin.js index 28b9018..8bfc801 100644 --- a/plugin.js +++ b/plugin.js @@ -133,18 +133,9 @@ class WasmPackPlugin { return true; } - info('ℹ️ Installing wasm-pack \n'); - - if (commandExistsSync("npm")) { - return runProcess("npm", ["install", "-g", "wasm-pack"], {}); - } else if (commandExistsSync("yarn")) { - return runProcess("yarn", ["global", "add", "wasm-pack"], {}); - } else { - error( - "⚠️ could not install wasm-pack, you must have yarn or npm installed" - ); - } - return false + error('⚠️ Could not find wasm-pack\n Please install it via `yarn add -D wasm-pack`, `npm install --dev wasm-pack` or by following the instructions at: https://rustwasm.github.io/wasm-pack/installer/'); + + return false; } _compile(watching) {