<commit_before>---
title: Compile time
---

Typically, you won't interact with the Svelte compiler directly, but will instead integrate it into your build system using a bundler plugin:

* [rollup-plugin-svelte](https://github.com/sveltejs/rollup-plugin-svelte) for users of [Rollup](https://rollupjs.org)
* [svelte-loader](https://github.com/sveltejs/svelte-loader) for users of [webpack](https://webpack.js.org)
* or one of the [community-maintained plugins](https://sveltesociety.dev/tooling)

Nonetheless, it's useful to understand how to use the compiler, since bundler plugins generally expose compiler options to you.



### `svelte.compile`

```js
result: {
	js,
	css,
	ast,
	warnings,
	vars,
	stats
} = svelte.compile(source: string, options?: {...})
```

---

This is where the magic happens. `svelte.compile` takes your component source code, and turns it into a JavaScript module that exports a class.

```js
const svelte = require('svelte/compiler');

const result = svelte.compile(source, {
	// options
});
```
<commit_msg>[docs] fix link to Svelte Society community-maintained tools (#6957)<commit_after>---
title: Compile time
---

Typically, you won't interact with the Svelte compiler directly, but will instead integrate it into your build system using a bundler plugin:

* [rollup-plugin-svelte](https://github.com/sveltejs/rollup-plugin-svelte) for users of [Rollup](https://rollupjs.org)
* [svelte-loader](https://github.com/sveltejs/svelte-loader) for users of [webpack](https://webpack.js.org)
* or one of the [community-maintained plugins](https://sveltesociety.dev/tools)

Nonetheless, it's useful to understand how to use the compiler, since bundler plugins generally expose compiler options to you.



### `svelte.compile`

```js
result: {
	js,
	css,
	ast,
	warnings,
	vars,
	stats
} = svelte.compile(source: string, options?: {...})
```

---

This is where the magic happens. `svelte.compile` takes your component source code, and turns it into a JavaScript module that exports a class.

```js
const svelte = require('svelte/compiler');

const result = svelte.compile(source, {
	// options
});
```

{'fraction_non_alphanumeric': 0.13352139163140572, 'fraction_numerical': 0.0018805829807240243, 'mean_word_length': 4.484536082474227, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '112434', 'n_tokens_mistral': 702, 'n_tokens_neox': 673, 'n_words': 216}