Skip to content

Commit

Permalink
fix: fix webpack 4 by not using loader options (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
Demivan authored Aug 4, 2022
1 parent 56b5742 commit b68fbc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/webpack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ export function getWebpackPlugin<UserOptions = {}> (
// 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({
Expand Down
10 changes: 9 additions & 1 deletion src/webpack/loaders/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ import { createContext } from '../context'

export default async function transform (this: LoaderContext<any>, 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) {
Expand Down

0 comments on commit b68fbc4

Please sign in to comment.