File tree 2 files changed +13
-9
lines changed
packages/nextjs/src/config/loaders
2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change 1
1
import * as fs from 'fs' ;
2
2
import * as path from 'path' ;
3
3
4
+ import { LoaderThis } from './types' ;
5
+
4
6
type LoaderOptions = {
5
7
distDir : string ;
6
8
} ;
7
- // TODO Use real webpack types
8
- type LoaderThis = {
9
- // Webpack 4
10
- query ?: LoaderOptions ;
11
- // Webpack 5
12
- getOptions ?: ( ) => LoaderOptions ;
13
- addDependency : ( filepath : string ) => void ;
14
- } ;
15
9
16
10
/**
17
11
* Inject templated code into the beginning of a module.
18
12
*/
19
- function prefixLoader ( this : LoaderThis , userCode : string ) : string {
13
+ function prefixLoader ( this : LoaderThis < LoaderOptions > , userCode : string ) : string {
20
14
// We know one or the other will be defined, depending on the version of webpack being used
21
15
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
22
16
const { distDir } = this . getOptions ? this . getOptions ( ) : this . query ! ;
Original file line number Diff line number Diff line change
1
+ // TODO Use real webpack types
2
+ export type LoaderThis < Options > = {
3
+ // Loader options in Webpack 4
4
+ query ?: Options ;
5
+ // Loader options in Webpack 5
6
+ getOptions ?: ( ) => Options ;
7
+
8
+ // Function to add outside file used by loader to `watch` process
9
+ addDependency : ( filepath : string ) => void ;
10
+ } ;
You can’t perform that action at this time.
0 commit comments