|
|
@ -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_warnings(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_warnings(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);
|
|
|
|