From f22fdded062eac265060b7357f96945698949806 Mon Sep 17 00:00:00 2001 From: Michael de Laborde Date: Mon, 16 Oct 2023 09:36:21 +0200 Subject: [PATCH] Add bundler picking with optional CLI argument --- index.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/index.js b/index.js index cec3d26..186e0d3 100644 --- a/index.js +++ b/index.js @@ -83,6 +83,23 @@ function hasScope(node) { } } +function hasChosenBundler(argument, bundler) { + if ( + argument.includes('r') && bundler === 'Rollup' || + argument.includes('w') && bundler === 'Webpack' || + argument.includes('e') && bundler === 'ESBuild' + ) { + return true + } else { + return false + } +} + +// Remove bundlers that are not chosen +for (const bundler in bundlers) { + if(process.argv[3] && !hasChosenBundler(process.argv[3], bundler)) delete bundlers[bundler] +} + try { const input = process.argv[2] const file = path.resolve(input)