@@ -228,21 +228,17 @@ export function overwriteAttrValue(
228228/**
229229 * Format parse5 @type {ParserError} to @type {RollupError}
230230 */
231- function formatParseError (
232- parserError : ParserError ,
233- id : string ,
234- html : string ,
235- ) : RollupError {
236- const formattedError : RollupError = {
231+ function formatParseError ( parserError : ParserError , id : string , html : string ) {
232+ const formattedError = {
237233 code : parserError . code ,
238234 message : `parse5 error code ${ parserError . code } ` ,
239- }
240- formattedError . frame = generateCodeFrame ( html , parserError . startOffset )
241- formattedError . loc = {
242- file : id ,
243- line : parserError . startLine ,
244- column : parserError . startCol ,
245- }
235+ frame : generateCodeFrame ( html , parserError . startOffset ) ,
236+ loc : {
237+ file : id ,
238+ line : parserError . startLine ,
239+ column : parserError . startCol ,
240+ } ,
241+ } satisfies RollupError
246242 return formattedError
247243}
248244
@@ -266,15 +262,11 @@ function handleParseError(
266262 // Allow self closing on non-void elements #10439
267263 return
268264 }
269- const parseError = {
270- loc : filePath ,
271- frame : '' ,
272- ...formatParseError ( parserError , filePath , html ) ,
273- }
265+ const parseError = formatParseError ( parserError , filePath , html )
274266 throw new Error (
275- `Unable to parse HTML; ${ parseError . message } \n at ${ JSON . stringify (
276- parseError . loc ,
277- ) } \n ${ parseError . frame } `,
267+ `Unable to parse HTML; ${ parseError . message } \n` +
268+ ` at ${ parseError . loc . file } : ${ parseError . loc . line } : ${ parseError . loc . column } \n` +
269+ ` ${ parseError . frame } `,
278270 )
279271}
280272
0 commit comments