From 6eec5e6d2e19a41d236d5db7a3d8873efd1e856e Mon Sep 17 00:00:00 2001 From: ssddi456 Date: Thu, 14 Jul 2022 02:14:10 +0800 Subject: [PATCH] let the plugin can access to loader context info #36 maybe this will be more flexible --- src/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/index.js b/src/index.js index ccaaff4..4c8d601 100644 --- a/src/index.js +++ b/src/index.js @@ -74,6 +74,13 @@ function makeLoader() { programmaticOptions.sourceMaps = true; } + if (programmaticOptions.plugin) { + const passInPlugin = programmaticOptions.plugin; + programmaticOptions.plugin = (m) => { + return passInPlugin(m, this); + }; + } + try { if (sync) { const output = swc.transformSync(source, programmaticOptions);