Skip to content

Commit

Permalink
Switch to async version
Browse files Browse the repository at this point in the history
  • Loading branch information
electerious committed Nov 28, 2020
1 parent 32cb6e2 commit 70e09f0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/sass.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const util = require('util')
const sass = require('sass')

/**
Expand All @@ -18,7 +19,7 @@ module.exports = async function(folderPath, str, opts) {
// Dismiss sourceMap when output should be optimized
const sourceMap = opts.optimize !== true

const result = sass.renderSync({
const result = await util.promisify(sass.render)({
data: str,
includePaths: [ folderPath ],
sourceMap: sourceMap === true ? '' : false,
Expand Down

2 comments on commit 70e09f0

@omBratteng
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the docs. renderSync() is faster than render()

When using Dart Sass, renderSync() is almost twice as fast as render() by default, 
due to the overhead of making the entire evaluation process asynchronous.
To avoid this performance hit, you can pass the fiber option to render().

And when I tried to wrap it in util.promisify, it threw this NoSuchMethodError: method not found: 'call'

@electerious
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good to know. Thanks!

Please sign in to comment.