@ -20,9 +20,8 @@ export { default as preprocess } from './preprocess/index.js';
* /
* /
export function compile ( source , options ) {
export function compile ( source , options ) {
source = remove _bom ( source ) ;
source = remove _bom ( source ) ;
state . reset _warning _filter ( options . warningFilter ) ;
state . reset _warning s ( options . warningFilter ) ;
const validated = validate _component _options ( options , '' ) ;
const validated = validate _component _options ( options , '' ) ;
state . reset ( source , validated ) ;
let parsed = _parse ( source ) ;
let parsed = _parse ( source ) ;
@ -64,9 +63,8 @@ export function compile(source, options) {
* /
* /
export function compileModule ( source , options ) {
export function compileModule ( source , options ) {
source = remove _bom ( source ) ;
source = remove _bom ( source ) ;
state . reset _warning _filter ( options . warningFilter ) ;
state . reset _warning s ( options . warningFilter ) ;
const validated = validate _module _options ( options , '' ) ;
const validated = validate _module _options ( options , '' ) ;
state . reset ( source , validated ) ;
const analysis = analyze _module ( source , validated ) ;
const analysis = analyze _module ( source , validated ) ;
return transform _module ( analysis , source , validated ) ;
return transform _module ( analysis , source , validated ) ;
@ -96,6 +94,7 @@ export function compileModule(source, options) {
* @ returns { Record < string , any > }
* @ returns { Record < string , any > }
* /
* /
// TODO 6.0 remove unused `filename`
/ * *
/ * *
* The parse function parses a component , returning only its abstract syntax tree .
* The parse function parses a component , returning only its abstract syntax tree .
*
*
@ -104,14 +103,15 @@ export function compileModule(source, options) {
*
*
* The ` loose ` option , available since 5.13 . 0 , tries to always return an AST even if the input will not successfully compile .
* The ` loose ` option , available since 5.13 . 0 , tries to always return an AST even if the input will not successfully compile .
*
*
* The ` filename ` option is unused and will be removed in Svelte 6.0 .
*
* @ param { string } source
* @ param { string } source
* @ param { { filename ? : string ; rootDir ? : string ; modern ? : boolean ; loose ? : boolean } } [ options ]
* @ param { { filename ? : string ; rootDir ? : string ; modern ? : boolean ; loose ? : boolean } } [ options ]
* @ returns { AST . Root | LegacyRoot }
* @ returns { AST . Root | LegacyRoot }
* /
* /
export function parse ( source , { filename, rootDir , modern, loose } = { } ) {
export function parse ( source , { modern, loose } = { } ) {
source = remove _bom ( source ) ;
source = remove _bom ( source ) ;
state . reset _warning _filter ( ( ) => false ) ;
state . reset _warnings ( ( ) => false ) ;
state . reset ( source , { filename : filename ? ? '(unknown)' , rootDir } ) ;
const ast = _parse ( source , loose ) ;
const ast = _parse ( source , loose ) ;
return to _public _ast ( source , ast , modern ) ;
return to _public _ast ( source , ast , modern ) ;