/
githubmirror
/
next.js
Обзор
Документация
Войти
/
githubmirror
/
next.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
canary
test/e2e/app-dir/webpack-loader-errors/loaders/create-error.js
26 строк
713 B
Tobias Koppers
Improve webpack loader error messages and handling (#89698)
09 мар 2026, 12:11
Не верифицирован
09 мар 2026, 12:11
60f903c
Код
Авторство
О чём код?
const fs = require('fs') // These helpers create errors and invoke the loader callback inside a // setTimeout so that the resulting stack trace does NOT contain the // loader file path — only this helper file. This lets the Turbopack // "(from …)" annotation fire (it's conditional on the loader path // not already being in the stack). module.exports.callbackWithError = function callbackWithError( callback, message ) { setTimeout(() => { callback(new Error(message)) }, 0) } module.exports.callbackWithFsError = function callbackWithFsError(callback) { setTimeout(() => { try { fs.readFileSync('/does/not/exist/file.txt') } catch (err) { callback(err) } }, 0) }