405e42e41e
Adds handling for module not found errors exposed by webpack. This ensures you see the actual stack line and code instead of a short message where you don't know where to go. ### Previous <img width="794" alt="Screen Shot 2020-08-05 at 18 02 06" src="https://user-images.githubusercontent.com/6324199/89435935-d5542c00-d745-11ea-9ca7-c67f553364f9.png"> ### New <img width="769" alt="Screen Shot 2020-08-05 at 14 20 23" src="https://user-images.githubusercontent.com/6324199/89412212-f6595480-d726-11ea-81a3-398ab7036338.png"> Fixes #14711
30 lines
907 B
TypeScript
30 lines
907 B
TypeScript
import { Compiler } from 'webpack'
|
|
import { getModuleBuildError } from './webpackModuleError'
|
|
|
|
export class WellKnownErrorsPlugin {
|
|
apply(compiler: Compiler) {
|
|
compiler.hooks.compilation.tap('WellKnownErrorsPlugin', (compilation) => {
|
|
compilation.hooks.afterSeal.tapPromise(
|
|
'WellKnownErrorsPlugin',
|
|
async () => {
|
|
if (compilation.errors?.length) {
|
|
compilation.errors = await Promise.all(
|
|
compilation.errors.map(async (err) => {
|
|
try {
|
|
const moduleError = await getModuleBuildError(
|
|
compilation,
|
|
err
|
|
)
|
|
return moduleError === false ? err : moduleError
|
|
} catch (e) {
|
|
console.log(e)
|
|
return err
|
|
}
|
|
})
|
|
)
|
|
}
|
|
}
|
|
)
|
|
})
|
|
}
|
|
}
|