svelte/compiler/index.js

24 lines
639 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import parse from './parse/index.js';
import validate from './validate/index.js';
import generate from './generate/index.js';
export function compile ( source, options = {} ) {
const parsed = parse( source, options );
if ( !options.onwarn ) {
options.onwarn = warning => {
if ( warning.loc ) {
console.warn( `(${warning.loc.line}:${warning.loc.column}) ${warning.message}` ); // eslint-disable-line no-console
} else {
console.warn( warning.message ); // eslint-disable-line no-console
}
};
}
validate( parsed, source, options );
return generate( parsed, source, options );
}
export { parse, validate };