File tree 3 files changed +30
-5
lines changed
3 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -10,10 +10,12 @@ import {
10
10
bareImportRE ,
11
11
cleanUrl ,
12
12
combineSourcemaps ,
13
+ generateCodeFrame ,
13
14
isDataUrl ,
14
15
isExternalUrl ,
15
16
isInNodeModules ,
16
17
moduleListContains ,
18
+ numberToPos ,
17
19
} from '../utils'
18
20
import type { Plugin } from '../plugin'
19
21
import { getDepOptimizationConfig } from '../config'
@@ -221,7 +223,7 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
221
223
try {
222
224
imports = parseImports ( source ) [ 0 ]
223
225
} catch ( e : any ) {
224
- this . error ( e )
226
+ this . error ( e , e . idx )
225
227
}
226
228
227
229
if ( ! imports . length ) {
@@ -462,7 +464,16 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
462
464
try {
463
465
imports = parseImports ( code ) [ 0 ] . filter ( ( i ) => i . d > - 1 )
464
466
} catch ( e : any ) {
465
- this . error ( e )
467
+ const loc = numberToPos ( code , e . idx )
468
+ this . error ( {
469
+ name : e . name ,
470
+ message : e . message ,
471
+ stack : e . stack ,
472
+ cause : e . cause ,
473
+ pos : e . idx ,
474
+ loc : { ...loc , file : chunk . fileName } ,
475
+ frame : generateCodeFrame ( code , loc ) ,
476
+ } )
466
477
}
467
478
468
479
const s = new MagicString ( code )
Original file line number Diff line number Diff line change @@ -279,7 +279,7 @@ export async function createPluginContainer(
279
279
// active plugin in that pipeline can be tracked in a concurrency-safe manner.
280
280
// using a class to make creating new contexts more efficient
281
281
class Context implements PluginContext {
282
- meta = minimalContext . meta !
282
+ meta = minimalContext . meta
283
283
ssr = false
284
284
_scan = false
285
285
_activePlugin : Plugin | null
Original file line number Diff line number Diff line change @@ -6,7 +6,12 @@ import jsonStableStringify from 'json-stable-stringify'
6
6
import type { ResolvedConfig } from '..'
7
7
import type { Plugin } from '../plugin'
8
8
import { preloadMethod } from '../plugins/importAnalysisBuild'
9
- import { joinUrlSegments , normalizePath } from '../utils'
9
+ import {
10
+ generateCodeFrame ,
11
+ joinUrlSegments ,
12
+ normalizePath ,
13
+ numberToPos ,
14
+ } from '../utils'
10
15
11
16
export function ssrManifestPlugin ( config : ResolvedConfig ) : Plugin {
12
17
// module id => preload assets mapping
@@ -42,7 +47,16 @@ export function ssrManifestPlugin(config: ResolvedConfig): Plugin {
42
47
try {
43
48
imports = parseImports ( code ) [ 0 ] . filter ( ( i ) => i . n && i . d > - 1 )
44
49
} catch ( e : any ) {
45
- this . error ( e )
50
+ const loc = numberToPos ( code , e . idx )
51
+ this . error ( {
52
+ name : e . name ,
53
+ message : e . message ,
54
+ stack : e . stack ,
55
+ cause : e . cause ,
56
+ pos : e . idx ,
57
+ loc : { ...loc , file : chunk . fileName } ,
58
+ frame : generateCodeFrame ( code , loc ) ,
59
+ } )
46
60
}
47
61
if ( imports . length ) {
48
62
for ( let index = 0 ; index < imports . length ; index ++ ) {
You can’t perform that action at this time.
0 commit comments