| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,10 @@ | |||
| 1 | - import type { Compilation, Compiler, LoaderContext } from 'webpack' | ||
| 1 | + import type { Compilation, Compiler, LoaderContext, sources } from 'webpack' | ||
| 2 | 2 | import type { UnpluginBuildContext, UnpluginContext, UnpluginMessage } from '../types' | |
| 3 | 3 | import { Buffer } from 'buffer' | |
| 4 | + import { createRequire } from 'module' | ||
| 4 | 5 | import { resolve } from 'path' | |
| 5 | 6 | import process from 'process' | |
| 6 | 7 | import { Parser } from 'acorn' | |
| 7 | - import * as webpack from 'webpack' | ||
| 8 | 8 | ||
| 9 | 9 | interface ContextOptions { | |
| 10 | 10 | addWatchFile: (file: string) => void | |
@@ -22,7 +22,9 @@ export function contextOptionsFromCompilation(compilation: Compilation): Context | |||
| 22 | 22 | } | |
| 23 | 23 | } | |
| 24 | 24 | ||
| 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') | ||
| 26 | 28 | return new webpack.sources.RawSource( | |
| 27 | 29 | typeof fileSource === 'string' ? fileSource : Buffer.from(fileSource.buffer), | |
| 28 | 30 | ) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments