@@ -2,20 +2,20 @@ import {dirname, parse, relative, resolve, sep} from 'path'
22import fs , { readFileSync } from 'fs'
33import { createResolver , fileSyntax , sourceMappingURL } from './utils'
44import { PartialMessage } from 'esbuild'
5- import * as sass from 'sass'
6- import { ImporterResult } from 'sass'
5+ import * as sass from 'sass-embedded '
6+ import { ImporterResult , initAsyncCompiler } from 'sass-embedded '
77import { fileURLToPath , pathToFileURL } from 'url'
88import { SassPluginOptions } from './index'
99
10- export type RenderSync = ( path : string ) => RenderResult
10+ export type RenderSync = ( path : string ) => Promise < RenderResult >
1111
1212export type RenderResult = {
1313 cssText : string
1414 watchFiles : string [ ]
1515 warnings ?: PartialMessage [ ]
1616}
1717
18- export function createRenderer ( options : SassPluginOptions = { } , sourcemap : boolean ) : RenderSync {
18+ export async function createRenderer ( options : SassPluginOptions = { } , sourcemap : boolean ) : Promise < RenderSync > {
1919
2020 const loadPaths = options . loadPaths !
2121 const resolveModule = createResolver ( options , loadPaths )
@@ -61,10 +61,12 @@ export function createRenderer(options: SassPluginOptions = {}, sourcemap: boole
6161
6262 const sepTilde = `${ sep } ~`
6363
64+ const compiler = await initAsyncCompiler ( ) ;
65+
6466 /**
6567 * renderSync
6668 */
67- return function ( path : string ) : RenderResult {
69+ return async function ( path : string ) : Promise < RenderResult > {
6870
6971 const basedir = dirname ( path )
7072
@@ -112,7 +114,7 @@ export function createRenderer(options: SassPluginOptions = {}, sourcemap: boole
112114 css,
113115 loadedUrls,
114116 sourceMap
115- } = sass . compileString ( source , {
117+ } = await compiler . compileStringAsync ( source , {
116118 sourceMapIncludeSources : true ,
117119 ...options ,
118120 logger,
0 commit comments