From df448cb36af056aa10604796f66d6b9d632c09f0 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sat, 4 May 2019 07:29:36 -0400 Subject: [PATCH] document svelte.parse --- site/content/docs/04-compile-time.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/site/content/docs/04-compile-time.md b/site/content/docs/04-compile-time.md index 7dd1e371f6..9abeee37ef 100644 --- a/site/content/docs/04-compile-time.md +++ b/site/content/docs/04-compile-time.md @@ -153,6 +153,30 @@ compiled: { --> +### `svelte.parse` + +```js +ast: object = svelte.parse( + source: string, + options?: { + filename?: string, + customElement?: boolean + } +) +``` + +--- + +The `parse` function parses a component, returning only its abstract syntax tree. Unlike compiling with the `generate: false` option, this will not perform any validation or other analysis of the component beyond parsing it. + + +```js +const svelte = require('svelte/compiler'); + +const ast = svelte.parse(source, { filename: 'App.svelte' }); +``` + + ### `svelte.preprocess` ```js