Subscribe on changes!

compiler-sfc: 解析Scss时实现处未支持异步的情况,前面的API调用都已经支持了异步,但是实现的时候却只处理了同步的情况, 是否考虑在实现处支持promise的情况

avatar
Jan 9th 2022

What problem does this feature solve?

https://github.com/vuejs/vue-next/blob/eb721d49c004abf5eff0a4e7da71bad904aa6bac/packages/compiler-sfc/src/stylePreprocessors.ts?_pjax=%23js-repo-pjax-container%2C%20div%5Bitemtype%3D%22http%3A%2F%2Fschema.org%2FSoftwareSourceCode%22%5D%20main%2C%20%5Bdata-pjax-container%5D#L36

最近在做一些关于移植到浏览器内支持vue-sfc-loader时,浏览器内的scss.js 仅支持异步函数解析,处理到这块会出现问题,是否要增加代码适配scss异步的情况

What does the proposed API look like?

if(options.isAsync){
    result = await new Promise((resolve, reject) => {
    nodeSass.render(finalOptions, (err, res) => { // node-scss 官方的语法, 浏览器内也只要实现一遍render方法即可
      resolve(res)
    })
  })
} else{
  result =  nodeSass.renderSync(finalOptions)
}
avatar
Jan 11th 2022

Hello, make sure to always provide a reproduction that follows the instructions at https://new-issue.vuejs.org/?repo=vuejs/vue-next#why-repro.

Open a new issue with a reproduction that follows those instructions if you manage to create a boiled down reproduction.