@@ -6,6 +6,7 @@ import { CompileOptions, Warning } from '../interfaces';
6
6
import Component from './Component' ;
7
7
import fuzzymatch from '../utils/fuzzymatch' ;
8
8
import get_name_from_filename from './utils/get_name_from_filename' ;
9
+ import { valid_namespaces } from '../utils/namespaces' ;
9
10
10
11
const valid_options = [
11
12
'format' ,
@@ -22,6 +23,7 @@ const valid_options = [
22
23
'hydratable' ,
23
24
'legacy' ,
24
25
'customElement' ,
26
+ 'namespace' ,
25
27
'tag' ,
26
28
'css' ,
27
29
'loopGuardTimeout' ,
@@ -30,7 +32,7 @@ const valid_options = [
30
32
] ;
31
33
32
34
function validate_options ( options : CompileOptions , warnings : Warning [ ] ) {
33
- const { name, filename, loopGuardTimeout, dev } = options ;
35
+ const { name, filename, loopGuardTimeout, dev, namespace } = options ;
34
36
35
37
Object . keys ( options ) . forEach ( key => {
36
38
if ( ! valid_options . includes ( key ) ) {
@@ -65,6 +67,15 @@ function validate_options(options: CompileOptions, warnings: Warning[]) {
65
67
toString : ( ) => message
66
68
} ) ;
67
69
}
70
+
71
+ if ( namespace && valid_namespaces . indexOf ( namespace ) === - 1 ) {
72
+ const match = fuzzymatch ( namespace , valid_namespaces ) ;
73
+ if ( match ) {
74
+ throw new Error ( `Invalid namespace '${ namespace } ' (did you mean '${ match } '?)` ) ;
75
+ } else {
76
+ throw new Error ( `Invalid namespace '${ namespace } '` ) ;
77
+ }
78
+ }
68
79
}
69
80
70
81
export default function compile ( source : string , options : CompileOptions = { } ) {
0 commit comments