next.js / packages /next /src /build /webpack /plugins /wellknown-errors-plugin /parse-dynamic-code-evaluation-error.ts
AbdulElahGwaith's picture
Upload folder using huggingface_hub
b91e262 verified
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
)
}