docs: add await in front of preprocess examples (#4404)

pull/4411/head
PKlknr 5 years ago committed by GitHub
parent b6d80f485a
commit 7fdae5f8a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -185,7 +185,7 @@ const ast = svelte.parse(source, { filename: 'App.svelte' });
result: {
code: string,
dependencies: Array<string>
} = svelte.preprocess(
} = await svelte.preprocess(
source: string,
preprocessors: Array<{
markup?: (input: { content: string, filename: string }) => Promise<{
@ -222,7 +222,7 @@ The `markup` function receives the entire component source text, along with the
```js
const svelte = require('svelte/compiler');
const { code } = svelte.preprocess(source, {
const { code } = await svelte.preprocess(source, {
markup: ({ content, filename }) => {
return {
code: content.replace(/foo/g, 'bar')
@ -244,7 +244,7 @@ const svelte = require('svelte/compiler');
const sass = require('node-sass');
const { dirname } = require('path');
const { code, dependencies } = svelte.preprocess(source, {
const { code, dependencies } = await svelte.preprocess(source, {
style: async ({ content, attributes, filename }) => {
// only process <style lang="sass">
if (attributes.lang !== 'sass') return;
@ -277,7 +277,7 @@ Multiple preprocessors can be used together. The output of the first becomes the
```js
const svelte = require('svelte/compiler');
const { code } = svelte.preprocess(source, [
const { code } = await svelte.preprocess(source, [
{
markup: () => {
console.log('this runs first');

Loading…
Cancel
Save