@@ -7,6 +7,7 @@ import { CompileOptions, Warning } from '../interfaces';
77import Component from './Component' ;
88import fuzzymatch from '../utils/fuzzymatch' ;
99import get_name_from_filename from './utils/get_name_from_filename' ;
10+ import optimise from '../parse/optimise/index' ;
1011
1112const valid_options = [
1213 'format' ,
@@ -25,7 +26,7 @@ const valid_options = [
2526 'tag' ,
2627 'css' ,
2728 'preserveComments' ,
28- 'preserveWhitespace'
29+ 'preserveWhitespace' ,
2930] ;
3031
3132function validate_options ( options : CompileOptions , warnings : Warning [ ] ) {
@@ -68,6 +69,10 @@ export default function compile(source: string, options: CompileOptions = {}) {
6869 const ast = parse ( source , options ) ;
6970 stats . stop ( 'parse' ) ;
7071
72+ stats . start ( 'optimise-ast' ) ;
73+ optimise ( ast ) ;
74+ stats . stop ( 'optimise-ast' ) ;
75+
7176 stats . start ( 'create component' ) ;
7277 const component = new Component (
7378 ast ,
@@ -79,9 +84,10 @@ export default function compile(source: string, options: CompileOptions = {}) {
7984 ) ;
8085 stats . stop ( 'create component' ) ;
8186
82- const js = options . generate === false
83- ? null
84- : options . generate === 'ssr'
87+ const js =
88+ options . generate === false
89+ ? null
90+ : options . generate === 'ssr'
8591 ? render_ssr ( component , options )
8692 : render_dom ( component , options ) ;
8793
0 commit comments