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

fix(webpack): remove deprecations introduced in webpack 5 #1047

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down
20 changes: 11 additions & 9 deletions src/after-compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export function makeAfterCompile(
return;
}

removeTSLoaderErrors(compilation.errors);
// @ts-ignore
removeTSLoaderErrors(compilation.getErrors && compilation.getErrors() || compilation.errors);

provideCompilerOptionDiagnosticErrorsToWebpack(
getCompilerOptionDiagnostics,
Expand Down Expand Up @@ -114,8 +115,9 @@ function provideCompilerOptionDiagnosticErrorsToWebpack(
* based on filepath
*/
function determineModules(compilation: webpack.compilation.Compilation) {
return compilation.modules.reduce<Map<string, WebpackModule[]>>(
(modules, module) => {
const modules = new Map<string, WebpackModule[]>();
compilation.modules.forEach(
(module) => {
if (module.resource) {
const modulePath = path.normalize(module.resource);
const existingModules = modules.get(modulePath);
Expand All @@ -127,11 +129,9 @@ function determineModules(compilation: webpack.compilation.Compilation) {
modules.set(modulePath, [module]);
}
}

return modules;
},
new Map<string, WebpackModule[]>()
}
);
return modules;
}

function determineFilesToCheckForErrors(
Expand Down Expand Up @@ -229,7 +229,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(
Expand Down Expand Up @@ -287,7 +288,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(
Expand Down