From 6164d149c0555a5b39bb286eab7ed2329334e3d9 Mon Sep 17 00:00:00 2001 From: Puru Vijay Date: Tue, 4 Apr 2023 00:58:59 +0530 Subject: [PATCH] Commit --- .../docs/04-compiler-and-api/01-svelte-compiler.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/site/content/docs/04-compiler-and-api/01-svelte-compiler.md b/site/content/docs/04-compiler-and-api/01-svelte-compiler.md index 186d1c0a56..4b1c070b62 100644 --- a/site/content/docs/04-compiler-and-api/01-svelte-compiler.md +++ b/site/content/docs/04-compiler-and-api/01-svelte-compiler.md @@ -240,7 +240,7 @@ If a `dependencies` array is returned, it will be included in the result object. ```js import svelte from 'svelte/compiler'; import sass from 'node-sass'; -const { dirname } = require('path'); +import { dirname } from 'path'; const { code, dependencies } = await svelte.preprocess( source, @@ -278,7 +278,7 @@ const { code, dependencies } = await svelte.preprocess( Multiple preprocessors can be used together. The output of the first becomes the input to the second. `markup` functions run first, then `script` and `style`. ```js -const svelte = require('svelte/compiler'); +import svelte from 'svelte/compiler'; const { code } = await svelte.preprocess( source, @@ -326,7 +326,8 @@ The `walk` function provides a way to walk the abstract syntax trees generated b The walker takes an abstract syntax tree to walk and an object with two optional methods: `enter` and `leave`. For each node, `enter` is called (if present). Then, unless `this.skip()` is called during `enter`, each of the children are traversed, and then `leave` is called on the node. ```js -const svelte = require('svelte/compiler'); +import svelte from 'svelte/compiler'; + svelte.walk(ast, { enter(node, parent, prop, index) { do_something(node); @@ -345,6 +346,6 @@ svelte.walk(ast, { The current version, as set in package.json. ```js -const svelte = require('svelte/compiler'); +import svelte from 'svelte/compiler'; console.log(`running svelte version ${svelte.VERSION}`); ```