1
1
import crypto from 'crypto'
2
2
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
3
3
import path from 'path'
4
- // @ts -ignore: Currently missing types
5
4
import PnpWebpackPlugin from 'pnp-webpack-plugin'
6
5
import webpack from 'webpack'
7
6
import {
@@ -29,7 +28,6 @@ import {
29
28
} from './plugins/collect-plugins'
30
29
import { build as buildConfiguration } from './webpack/config'
31
30
import { __overrideCssConfiguration } from './webpack/config/blocks/css/overrideCssConfiguration'
32
- // @ts -ignore: JS file
33
31
import { pluginLoaderOptions } from './webpack/loaders/next-plugin-loader'
34
32
import BuildManifestPlugin from './webpack/plugins/build-manifest-plugin'
35
33
import ChunkNamesPlugin from './webpack/plugins/chunk-names-plugin'
@@ -113,6 +111,12 @@ function getOptimizedAliases(
113
111
)
114
112
}
115
113
114
+ type ClientEntries = {
115
+ 'main.js' : string [ ]
116
+ } & {
117
+ [ key : string ] : string
118
+ }
119
+
116
120
export default async function getBaseWebpackConfig (
117
121
dir : string ,
118
122
{
@@ -197,7 +201,7 @@ export default async function getBaseWebpackConfig(
197
201
const outputPath = path . join ( distDir , isServer ? outputDir : '' )
198
202
const totalPages = Object . keys ( entrypoints ) . length
199
203
const clientEntries = ! isServer
200
- ? {
204
+ ? ( {
201
205
// Backwards compatibility
202
206
'main.js' : [ ] ,
203
207
[ CLIENT_STATIC_FILES_RUNTIME_MAIN ] :
@@ -215,7 +219,7 @@ export default async function getBaseWebpackConfig(
215
219
? 'polyfills-nomodule.js'
216
220
: 'polyfills.js'
217
221
) ,
218
- }
222
+ } as ClientEntries )
219
223
: undefined
220
224
221
225
let typeScriptPath
@@ -652,7 +656,6 @@ export default async function getBaseWebpackConfig(
652
656
] ,
653
657
plugins : [ PnpWebpackPlugin ] ,
654
658
} ,
655
- // @ts -ignore this is filtered
656
659
module : {
657
660
rules : [
658
661
{
@@ -902,8 +905,7 @@ export default async function getBaseWebpackConfig(
902
905
webpack,
903
906
} )
904
907
905
- // @ts -ignore: Property 'then' does not exist on type 'Configuration'
906
- if ( typeof webpackConfig . then === 'function' ) {
908
+ if ( typeof ( webpackConfig as any ) . then === 'function' ) {
907
909
console . warn (
908
910
'> Promise returned in next config. https://err.sh/zeit/next.js/promise-in-next-config'
909
911
)
@@ -1109,7 +1111,6 @@ export default async function getBaseWebpackConfig(
1109
1111
// Server compilation doesn't have main.js
1110
1112
if ( clientEntries && entry [ 'main.js' ] && entry [ 'main.js' ] . length > 0 ) {
1111
1113
const originalFile = clientEntries [ CLIENT_STATIC_FILES_RUNTIME_MAIN ]
1112
- // @ts -ignore TODO: investigate type error
1113
1114
entry [ CLIENT_STATIC_FILES_RUNTIME_MAIN ] = [
1114
1115
...entry [ 'main.js' ] ,
1115
1116
originalFile ,
@@ -1122,8 +1123,8 @@ export default async function getBaseWebpackConfig(
1122
1123
}
1123
1124
1124
1125
if ( ! dev ) {
1125
- // @ts -ignore entry is always a function
1126
- webpackConfig . entry = await webpackConfig . entry ( )
1126
+ // entry is always a function
1127
+ webpackConfig . entry = await ( webpackConfig . entry as webpack . EntryFunc ) ( )
1127
1128
}
1128
1129
1129
1130
return webpackConfig
0 commit comments