From 57bd7750367cd61fdabab46723a2c20f9834852d Mon Sep 17 00:00:00 2001 From: Ivan Demchuk Date: Thu, 4 Aug 2022 00:40:21 +0300 Subject: [PATCH] fix: don't use loader options --- src/webpack/index.ts | 6 +----- src/webpack/loaders/transform.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/webpack/index.ts b/src/webpack/index.ts index 2844b2b3..b366b6b2 100644 --- a/src/webpack/index.ts +++ b/src/webpack/index.ts @@ -49,11 +49,7 @@ export function getWebpackPlugin ( // transform hook if (plugin.transform) { const useLoader: RuleSetUseItem[] = [{ - loader: TRANSFORM_LOADER, - ident: plugin.name, - options: { - unpluginName: plugin.name - } + loader: `${TRANSFORM_LOADER}?unpluginName=${encodeURIComponent(plugin.name)}` }] const useNone: RuleSetUseItem[] = [] compiler.options.module.rules.push({ diff --git a/src/webpack/loaders/transform.ts b/src/webpack/loaders/transform.ts index 614d8b61..bb773ce3 100644 --- a/src/webpack/loaders/transform.ts +++ b/src/webpack/loaders/transform.ts @@ -4,7 +4,15 @@ import { createContext } from '../context' export default async function transform (this: LoaderContext, source: string, map: any) { const callback = this.async() - const { unpluginName } = this.query + + let unpluginName + if (typeof this.query === 'string') { + const query = new URLSearchParams(this.query) + unpluginName = query.get('unpluginName') + } else { + unpluginName = this.query.unpluginName + } + const plugin = this._compiler?.$unpluginContext[unpluginName] if (!plugin?.transform) {