Skip to content

Commit 64faade

Browse files
fix: only import webpack types (#297)
* remove webpack import * chore: rename _loaderContext --------- Co-authored-by: Andrew Powell <shellscape@users.noreply.github.com> Co-authored-by: shellscape <andrew@shellscape.org>
1 parent 9a39d31 commit 64faade

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/hooks.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,15 @@ interface LegacyModule extends Module {
170170
userRequest?: any;
171171
}
172172

173+
173174
const normalModuleLoaderHook = (
174175
{ moduleAssets }: { moduleAssets: Record<any, any> },
175-
loaderContext: LoaderContext<any>,
176+
context: unknown,
176177
module: LegacyModule
177178
) => {
179+
const loaderContext = context as LoaderContext<any>;
178180
const { emitFile } = loaderContext;
179181

180-
// eslint-disable-next-line no-param-reassign
181182
loaderContext.emitFile = (file: string, content: string, sourceMap: any) => {
182183
if (module.userRequest && !moduleAssets[file]) {
183184
Object.assign(moduleAssets, { [file]: join(dirname(file), basename(module.userRequest)) });

src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { relative, resolve } from 'path';
22

33
import { SyncHook } from 'tapable';
4-
import { Compiler, WebpackPluginInstance, Compilation } from 'webpack';
5-
// @ts-ignore
6-
import NormalModule from 'webpack/lib/NormalModule';
7-
4+
import type { Compiler, WebpackPluginInstance, Compilation } from 'webpack';
85
import { FileDescriptor } from './helpers';
96
import { beforeRunHook, emitHook, getCompilerHooks, normalModuleLoaderHook } from './hooks';
107

@@ -71,6 +68,7 @@ class WebpackManifestPlugin implements WebpackPluginInstance {
7168
}
7269

7370
apply(compiler: Compiler) {
71+
const { NormalModule } = compiler.webpack;
7472
const moduleAssets = {};
7573
const manifestFileName = resolve(compiler.options.output?.path || './', this.options.fileName);
7674
const manifestAssetId = relative(compiler.options.output?.path || './', manifestFileName);

0 commit comments

Comments
 (0)