/
githubmirror
/
next.js
Обзор
Документация
Войти
/
githubmirror
/
next.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
canary
test/e2e/webpack-loader-parse-error/broken-css-loader.js
33 строки
1 KB
Tobias Koppers
Show generated code from loaders in parse error messages (#89898)
16 мар 2026, 15:41
Не верифицирован
16 мар 2026, 15:41
261922d
Код
Авторство
О чём код?
// A webpack loader that returns invalid CSS with a source map. // The source map points back to the original file, making it clear that the // loader is responsible for the broken output (not the original source). module.exports = function (source) { // Generate a source map that maps generated lines back to the original source. // The original file is valid CSS; the generated output is intentionally broken. // // Mapping (0-based line numbers): // generated line 0 ("/* Generated by... */") -> original line 0 (".page {") // generated line 1 (".page {") -> original line 0 (".page {") // generated line 2 (" color: red") -> original line 1 (" color: blue;") // generated line 3 (" @@@ ...") -> original line 2 (" font-size: 16px;") // generated line 4 (" background: {{{...") -> original line 1 (" color: blue;") // generated line 5 ("}") -> original line 3 ("}") const sourceMap = { version: 3, sources: [this.resourcePath], sourcesContent: [source], mappings: 'AAAA;AAAA;AACE;AACA;AADA;AAEF', names: [], } // Return broken CSS that will fail to parse const brokenCss = `/* Generated by broken-css-loader */ .page { color: red @@@ THIS IS NOT VALID CSS @@@; background: {{{ invalid } ` this.callback(null, brokenCss, sourceMap) }