@@ -6,6 +6,7 @@ import { getLocator } from 'locate-character';
6
6
import { walk } from 'zimmerframe' ;
7
7
import { validate_component_options , validate_module_options } from './validate-options.js' ;
8
8
import { convert } from './legacy.js' ;
9
+ import { CompileError } from './errors.js' ;
9
10
export { default as preprocess } from './preprocess/index.js' ;
10
11
11
12
/**
@@ -30,12 +31,8 @@ export function compile(source, options) {
30
31
const result = transform_component ( analysis , source , combined_options ) ;
31
32
return result ;
32
33
} catch ( e ) {
33
- if ( /** @type {any } */ ( e ) . name === 'CompileError' ) {
34
- handle_compile_error (
35
- /** @type {import('#compiler').CompileError } */ ( e ) ,
36
- options . filename ,
37
- source
38
- ) ;
34
+ if ( e instanceof CompileError ) {
35
+ handle_compile_error ( e , options . filename , source ) ;
39
36
}
40
37
41
38
throw e ;
@@ -56,12 +53,8 @@ export function compileModule(source, options) {
56
53
const analysis = analyze_module ( parse_acorn ( source , false ) , validated ) ;
57
54
return transform_module ( analysis , source , validated ) ;
58
55
} catch ( e ) {
59
- if ( /** @type {any } */ ( e ) . name === 'CompileError' ) {
60
- handle_compile_error (
61
- /** @type {import('#compiler').CompileError } */ ( e ) ,
62
- options . filename ,
63
- source
64
- ) ;
56
+ if ( e instanceof CompileError ) {
57
+ handle_compile_error ( e , options . filename , source ) ;
65
58
}
66
59
67
60
throw e ;
@@ -106,12 +99,8 @@ export function parse(source, options = {}) {
106
99
try {
107
100
ast = _parse ( source ) ;
108
101
} catch ( e ) {
109
- if ( /** @type {any } */ ( e ) . name === 'CompileError' ) {
110
- handle_compile_error (
111
- /** @type {import('#compiler').CompileError } */ ( e ) ,
112
- options . filename ,
113
- source
114
- ) ;
102
+ if ( e instanceof CompileError ) {
103
+ handle_compile_error ( e , options . filename , source ) ;
115
104
}
116
105
117
106
throw e ;
0 commit comments