@ -16,6 +16,11 @@ export let warnings = [];
* /
export let filename ;
/ * *
* This is the fallback used when no filename is specified .
* /
export const UNKNOWN _FILENAME = '(unknown)' ;
/ * *
* The name of the component that is used in the ` export default function ... ` statement .
* /
@ -80,15 +85,6 @@ export function pop_ignore() {
ignore _stack . pop ( ) ;
}
/ * *
*
* @ param { ( warning : Warning ) => boolean } fn
* /
export function reset _warnings ( fn = ( ) => true ) {
warning _filter = fn ;
warnings = [ ] ;
}
/ * *
* @ param { AST . SvelteNode | NodeLike } node
* @ param { import ( '../constants.js' ) . IGNORABLE _RUNTIME _WARNINGS [ number ] } code
@ -99,21 +95,36 @@ export function is_ignored(node, code) {
}
/ * *
* Call this to reset the compiler state . Should be called before each compilation .
* @ param { { warning ? : ( warning : Warning ) => boolean ; filename : string | undefined } } state
* /
export function reset ( state ) {
dev = false ;
runes = false ;
component _name = UNKNOWN _FILENAME ;
source = '' ;
locator = ( ) => undefined ;
filename = ( state . filename ? ? UNKNOWN _FILENAME ) . replace ( /\\/g , '/' ) ;
warning _filter = state . warning ? ? ( ( ) => true ) ;
warnings = [ ] ;
}
/ * *
* Adjust the compiler state based on the provided state object .
* Call this after parsing and basic analysis happened .
* @ param { {
* dev : boolean ;
* filename : string ;
* component _name ? : string ;
* rootDir ? : string ;
* runes : boolean ;
* } } state
* /
export function reset ( state ) {
export function adjus t( state ) {
const root _dir = state . rootDir ? . replace ( /\\/g , '/' ) ;
filename = state . filename . replace ( /\\/g , '/' ) ;
dev = state . dev ;
runes = state . runes ;
component _name = state . component _name ? ? '(unknown)' ;
component _name = state . component _name ? ? UNKNOWN _FILENAME ;
if ( typeof root _dir === 'string' && filename . startsWith ( root _dir ) ) {
// make filename relative to rootDir