From 186356b85f1be7028717d2c0a99f1f6daf36f1a4 Mon Sep 17 00:00:00 2001 From: Vohmyanin Sergey Vasilevich Date: Fri, 27 Dec 2019 16:00:33 +0300 Subject: [PATCH 1/2] fix(webpack): remove deprecations introduced in webpack 5 --- package.json | 4 ++-- src/after-compile.ts | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 2aa0c7af2..d7c5d1851 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "@types/micromatch": "^3.1.0", "@types/node": "*", "@types/semver": "^6.0.0", - "@types/webpack": "^4.4.30", + "@types/webpack": "~4.41.0", "babel": "^6.0.0", "babel-core": "^6.0.0", "babel-loader": "^7.0.0", @@ -93,7 +93,7 @@ "tslint": "^5.11.0", "tslint-config-prettier": "^1.15.0", "typescript": "^3.6.2", - "webpack": "^4.5.0", + "webpack": "^4.41.4", "webpack-cli": "^3.1.1" }, "peerDependencies": { diff --git a/src/after-compile.ts b/src/after-compile.ts index 517eb6f64..738caee21 100644 --- a/src/after-compile.ts +++ b/src/after-compile.ts @@ -114,8 +114,9 @@ function provideCompilerOptionDiagnosticErrorsToWebpack( * based on filepath */ function determineModules(compilation: webpack.compilation.Compilation) { - return compilation.modules.reduce>( - (modules, module) => { + const modules = new Map(); + compilation.modules.forEach( + (module) => { if (module.resource) { const modulePath = path.normalize(module.resource); const existingModules = modules.get(modulePath); @@ -127,11 +128,9 @@ function determineModules(compilation: webpack.compilation.Compilation) { modules.set(modulePath, [module]); } } - - return modules; - }, - new Map() + } ); + return modules; } function determineFilesToCheckForErrors( @@ -229,7 +228,8 @@ function provideErrorsToWebpack( if (associatedModules !== undefined) { associatedModules.forEach(module => { // remove any existing errors - removeTSLoaderErrors(module.errors); + // @ts-ignore + removeTSLoaderErrors(module.getErrors && module.getErrors() || module.errors); // append errors const formattedErrors = formatErrors( @@ -241,7 +241,7 @@ function provideErrorsToWebpack( compilation.compiler.context ); - module.errors.push(...formattedErrors); + // module.errors.push(...formattedErrors); compilation.errors.push(...formattedErrors); }); } else { @@ -287,7 +287,8 @@ function provideSolutionErrorsToWebpack( if (associatedModules !== undefined) { associatedModules.forEach(module => { // remove any existing errors - removeTSLoaderErrors(module.errors); + // @ts-ignore + removeTSLoaderErrors(module.getErrors && module.getErrors() || module.errors); // append errors const formattedErrors = formatErrors( @@ -299,7 +300,7 @@ function provideSolutionErrorsToWebpack( compilation.compiler.context ); - module.errors.push(...formattedErrors); + // module.errors.push(...formattedErrors); compilation.errors.push(...formattedErrors); }); } else { From 7950bd495f59f4fc810fc9ef4c555ff4e332a7ec Mon Sep 17 00:00:00 2001 From: Vohmyanin Sergey Vasilevich Date: Mon, 30 Dec 2019 08:57:50 +0300 Subject: [PATCH 2/2] restore module.errors.push calls --- src/after-compile.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/after-compile.ts b/src/after-compile.ts index 738caee21..55e80eb79 100644 --- a/src/after-compile.ts +++ b/src/after-compile.ts @@ -39,7 +39,8 @@ export function makeAfterCompile( return; } - removeTSLoaderErrors(compilation.errors); + // @ts-ignore + removeTSLoaderErrors(compilation.getErrors && compilation.getErrors() || compilation.errors); provideCompilerOptionDiagnosticErrorsToWebpack( getCompilerOptionDiagnostics, @@ -241,7 +242,7 @@ function provideErrorsToWebpack( compilation.compiler.context ); - // module.errors.push(...formattedErrors); + module.errors.push(...formattedErrors); compilation.errors.push(...formattedErrors); }); } else { @@ -300,7 +301,7 @@ function provideSolutionErrorsToWebpack( compilation.compiler.context ); - // module.errors.push(...formattedErrors); + module.errors.push(...formattedErrors); compilation.errors.push(...formattedErrors); }); } else {