Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make type checking compatible with webpack 5 #15158

Merged
merged 8 commits into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/next/build/webpack/config/blocks/css/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export const css = curry(async function css(
// Extract CSS as CSS file(s) in the client-side production bundle.
fns.push(
plugin(
// @ts-ignore webpack 5 compat
new MiniCssExtractPlugin({
filename: 'static/css/[contenthash].css',
chunkFilename: 'static/css/[contenthash].css',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class BuildManifestPlugin {
apply(compiler: Compiler) {
compiler.hooks.emit.tapAsync(
'NextJsBuildManifest',
(compilation, callback) => {
(compilation: any, callback: any) => {
const chunks: CompilationType.Chunk[] = compilation.chunks
const assetMap: BuildManifest = {
polyfillFiles: [],
Expand Down
4 changes: 2 additions & 2 deletions packages/next/build/webpack/plugins/css-minimizer-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export class CssMinimizerPlugin {
}

apply(compiler: webpack.Compiler) {
compiler.hooks.compilation.tap('CssMinimizerPlugin', (compilation) => {
compiler.hooks.compilation.tap('CssMinimizerPlugin', (compilation: any) => {
compilation.hooks.optimizeChunkAssets.tapPromise(
'CssMinimizerPlugin',
(chunks) =>
(chunks: webpack.compilation.Chunk[]) =>
Promise.all(
chunks
.reduce(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class DropClientPage implements Plugin {
apply(compiler: Compiler) {
compiler.hooks.compilation.tap(
PLUGIN_NAME,
(compilation, { normalModuleFactory }) => {
(compilation: any, { normalModuleFactory }: any) => {
// Recursively look up the issuer till it ends up at the root
function findEntryModule(mod: any): CompilationType.Module | null {
const queue = new Set([mod])
Expand Down
9 changes: 3 additions & 6 deletions packages/next/build/webpack/plugins/next-esm-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,9 @@ export class NextEsmPlugin implements Plugin {
}

apply(compiler: Compiler) {
compiler.hooks.make.tapAsync(
PLUGIN_NAME,
(compilation: CompilationType.Compilation, callback) => {
this.runBuild(compiler, compilation).then(callback)
}
)
compiler.hooks.make.tapAsync(PLUGIN_NAME, (compilation, callback) => {
this.runBuild(compiler, compilation).then(callback)
})
}

getLoaders(rules: RuleSetRule[], predicate: (loader: string) => boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default class WebpackConformancePlugin {
for (const type of JS_TYPES) {
factory.hooks.parser
.for('javascript/' + type)
.tap(this.constructor.name, (parser) => {
.tap(this.constructor.name, (parser: any) => {
parser.hooks.program.tap(this.constructor.name, (ast: any) => {
const visitors: VisitorMap = {}
const that = this
Expand Down
4 changes: 0 additions & 4 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,8 @@
"@types/fresh": "0.5.0",
"@types/json5": "0.0.30",
"@types/jsonwebtoken": "8.3.7",
"@types/loader-utils": "1.1.3",
"@types/lodash.curry": "4.1.6",
"@types/lru-cache": "5.1.0",
"@types/mini-css-extract-plugin": "0.8.0",
"@types/nanoid": "2.0.0",
"@types/node-fetch": "2.3.4",
"@types/path-to-regexp": "1.7.0",
Expand All @@ -150,9 +148,7 @@
"@types/resolve": "0.0.8",
"@types/send": "0.14.4",
"@types/styled-jsx": "2.2.8",
"@types/terser-webpack-plugin": "2.2.0",
"@types/text-table": "0.2.1",
"@types/webpack-hot-middleware": "2.16.5",
"@types/webpack-sources": "0.1.5",
"@zeit/ncc": "0.22.0",
"amphtml-validator": "1.0.31",
Expand Down
1 change: 1 addition & 0 deletions packages/next/server/on-demand-entry-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ class Invalidator {
// Work around a bug in webpack, calling `invalidate` on Watching.js
// doesn't trigger the invalid call used to keep track of the `.done` hook on multiCompiler
for (const compiler of this.multiCompiler.compilers) {
// @ts-ignore TODO: Check if this is still needed with webpack 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compiler.hooks.invalid.call()
}
this.watcher.invalidate()
Expand Down
5 changes: 1 addition & 4 deletions packages/next/types/misc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,7 @@ declare module 'next/dist/compiled/unistore' {
export = m
}

declare module 'next/dist/compiled/terser-webpack-plugin' {
import m from 'terser-webpack-plugin'
export = m
}
declare module 'next/dist/compiled/terser-webpack-plugin'
declare module 'next/dist/compiled/comment-json' {
import m from 'comment-json'
export = m
Expand Down
Loading