1- import  {  getLocator  }  from  'locate-character' ; 
21import  {  walk  as  zimmerframe_walk  }  from  'zimmerframe' ; 
32import  {  CompileError  }  from  './errors.js' ; 
43import  {  convert  }  from  './legacy.js' ; 
@@ -8,7 +7,7 @@ import { remove_typescript_nodes } from './phases/1-parse/remove_typescript_node
87import  {  analyze_component ,  analyze_module  }  from  './phases/2-analyze/index.js' ; 
98import  {  transform_component ,  transform_module  }  from  './phases/3-transform/index.js' ; 
109import  {  validate_component_options ,  validate_module_options  }  from  './validate-options.js' ; 
11- import  {   reset_warnings   }  from  './warnings .js' ; 
10+ import  *   as   state  from  './state .js' ; 
1211export  {  default  as  preprocess  }  from  './preprocess/index.js' ; 
1312
1413/** 
@@ -21,7 +20,8 @@ export { default as preprocess } from './preprocess/index.js';
2120 */ 
2221export  function  compile ( source ,  options )  { 
2322	try  { 
24- 		const  warnings  =  reset_warnings ( {  source,  filename : options . filename  } ) ; 
23+ 		state . reset ( {  source,  filename : options . filename  } ) ; 
24+ 
2525		const  validated  =  validate_component_options ( options ,  '' ) ; 
2626		let  parsed  =  _parse ( source ) ; 
2727
@@ -44,9 +44,7 @@ export function compile(source, options) {
4444		} 
4545
4646		const  analysis  =  analyze_component ( parsed ,  source ,  combined_options ) ; 
47- 
4847		const  result  =  transform_component ( analysis ,  source ,  combined_options ) ; 
49- 		result . warnings  =  warnings ; 
5048		result . ast  =  to_public_ast ( source ,  parsed ,  options . modernAst ) ; 
5149		return  result ; 
5250	}  catch  ( e )  { 
@@ -68,11 +66,11 @@ export function compile(source, options) {
6866 */ 
6967export  function  compileModule ( source ,  options )  { 
7068	try  { 
71- 		const  warnings  =  reset_warnings ( {  source,  filename : options . filename  } ) ; 
69+ 		state . reset ( {  source,  filename : options . filename  } ) ; 
70+ 
7271		const  validated  =  validate_module_options ( options ,  '' ) ; 
7372		const  analysis  =  analyze_module ( parse_acorn ( source ,  false ) ,  validated ) ; 
7473		const  result  =  transform_module ( analysis ,  source ,  validated ) ; 
75- 		result . warnings  =  warnings ; 
7674		return  result ; 
7775	}  catch  ( e )  { 
7876		if  ( e  instanceof  CompileError )  { 
@@ -92,10 +90,8 @@ function handle_compile_error(error, filename, source) {
9290	error . filename  =  filename ; 
9391
9492	if  ( error . position )  { 
95- 		// TODO this is reused with warnings — DRY out 
96- 		const  locator  =  getLocator ( source ,  {  offsetLine : 1  } ) ; 
97- 		const  start  =  locator ( error . position [ 0 ] ) ; 
98- 		const  end  =  locator ( error . position [ 1 ] ) ; 
93+ 		const  start  =  state . locator ( error . position [ 0 ] ) ; 
94+ 		const  end  =  state . locator ( error . position [ 1 ] ) ; 
9995
10096		error . start  =  start ; 
10197		error . end  =  end ; 
@@ -142,6 +138,8 @@ function handle_compile_error(error, filename, source) {
142138 * @returns  {import('#compiler').Root | import('./types/legacy-nodes.js').LegacyRoot } 
143139 */ 
144140export  function  parse ( source ,  options  =  { } )  { 
141+ 	state . reset ( {  source,  filename : options . filename  } ) ; 
142+ 
145143	/** @type  {import('#compiler').Root } */ 
146144	let  ast ; 
147145	try  { 
0 commit comments