File size: 764 Bytes
b91e262 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import type { webpack } from 'next/dist/compiled/webpack/webpack'
import { formatModuleTrace, getModuleTrace } from './getModuleTrace'
import { SimpleWebpackError } from './simpleWebpackError'
export function getDynamicCodeEvaluationError(
message: string,
module: webpack.NormalModule,
compilation: webpack.Compilation,
compiler: webpack.Compiler
): SimpleWebpackError {
const { moduleTrace } = getModuleTrace(module, compilation, compiler)
const { formattedModuleTrace, lastInternalFileName, invalidImportMessage } =
formatModuleTrace(compiler, moduleTrace)
return new SimpleWebpackError(
lastInternalFileName,
message +
invalidImportMessage +
'\n\nImport trace for requested module:\n' +
formattedModuleTrace
)
}
|