Skip to content

Commit b68fbc4

Browse files
authored
fix: fix webpack 4 by not using loader options (#149)
1 parent 56b5742 commit b68fbc4

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/webpack/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ export function getWebpackPlugin<UserOptions = {}> (
4949
// transform hook
5050
if (plugin.transform) {
5151
const useLoader: RuleSetUseItem[] = [{
52-
loader: TRANSFORM_LOADER,
53-
ident: plugin.name,
54-
options: {
55-
unpluginName: plugin.name
56-
}
52+
loader: `${TRANSFORM_LOADER}?unpluginName=${encodeURIComponent(plugin.name)}`
5753
}]
5854
const useNone: RuleSetUseItem[] = []
5955
compiler.options.module.rules.push({

src/webpack/loaders/transform.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ import { createContext } from '../context'
44

55
export default async function transform (this: LoaderContext<any>, source: string, map: any) {
66
const callback = this.async()
7-
const { unpluginName } = this.query
7+
8+
let unpluginName
9+
if (typeof this.query === 'string') {
10+
const query = new URLSearchParams(this.query)
11+
unpluginName = query.get('unpluginName')
12+
} else {
13+
unpluginName = this.query.unpluginName
14+
}
15+
816
const plugin = this._compiler?.$unpluginContext[unpluginName]
917

1018
if (!plugin?.transform) {

0 commit comments

Comments
 (0)