File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 1- import type { Compilation , Compiler , LoaderContext } from 'webpack'
1+ import type { Compilation , Compiler , LoaderContext , sources } from 'webpack'
22import type { UnpluginBuildContext , UnpluginContext , UnpluginMessage } from '../types'
33import { Buffer } from 'buffer'
4+ import { createRequire } from 'module'
45import { resolve } from 'path'
56import process from 'process'
67import { Parser } from 'acorn'
7- import * as webpack from 'webpack'
88
99interface ContextOptions {
1010 addWatchFile : ( file : string ) => void
@@ -22,7 +22,9 @@ export function contextOptionsFromCompilation(compilation: Compilation): Context
2222 }
2323}
2424
25- export function getSource ( fileSource : string | Uint8Array ) : webpack . sources . RawSource {
25+ const require = createRequire ( import . meta. url )
26+ export function getSource ( fileSource : string | Uint8Array ) : sources . RawSource {
27+ const webpack = require ( 'webpack' )
2628 return new webpack . sources . RawSource (
2729 typeof fileSource === 'string' ? fileSource : Buffer . from ( fileSource . buffer ) ,
2830 )
You can’t perform that action at this time.
0 commit comments