@@ -228,21 +228,17 @@ export function overwriteAttrValue(
228
228
/**
229
229
* Format parse5 @type {ParserError} to @type {RollupError}
230
230
*/
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 = {
237
233
code : parserError . code ,
238
234
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
246
242
return formattedError
247
243
}
248
244
@@ -266,15 +262,11 @@ function handleParseError(
266
262
// Allow self closing on non-void elements #10439
267
263
return
268
264
}
269
- const parseError = {
270
- loc : filePath ,
271
- frame : '' ,
272
- ...formatParseError ( parserError , filePath , html ) ,
273
- }
265
+ const parseError = formatParseError ( parserError , filePath , html )
274
266
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 } `,
278
270
)
279
271
}
280
272
0 commit comments