不正式支持在浏览器中运行dart-sass(#25),但是也许有人可以给我提示如何进行调试(非常困难,没有Dart代码的源映射)。
Error: Error: Illegal invocation
at Object.AU (http://localhost:5000/ParcelWorker.cc8dae65.js:536605:15)
at w6.$2 (http://localhost:5000/ParcelWorker.cc8dae65.js:556087:53)
at u6.v7 (http://localhost:5000/ParcelWorker.cc8dae65.js:543941:33)
at u6.v6 (http://localhost:5000/ParcelWorker.cc8dae65.js:543945:19)
at ik.uh (http://localhost:5000/ParcelWorker.cc8dae65.js:542621:20)
at tF.$0 (http://localhost:5000/ParcelWorker.cc8dae65.js:542922:19)
at Object.ex (http://localhost:5000/ParcelWorker.cc8dae65.js:529758:55)
at aj.bb (http://localhost:5000/ParcelWorker.cc8dae65.js:542753:9)
at iz.bb (http://localhost:5000/ParcelWorker.cc8dae65.js:542606:14)
at iz.cA (http://localhost:5000/ParcelWorker.cc8dae65.js:542577:12)
添加任何进口商(甚至是“空”进口商)时都会发生这种情况。在主线程上执行此代码(仅使用require
)可以正常工作。不会一次执行导入程序就抛出错误。
/* index.js */
// this works:
require("./worker.js");
// this doesn't:
const worker = new Worker("./worker.js");
worker.onerror = console.error;
/* worker.js */
self.Buffer = require("buffer").Buffer;
const sass = require("sass");
const data = `$colorRed: red;
#header {
color: $colorRed;
}`;
function run() {
return sass.renderSync({
data,
importer: [
(url, prev, done) => {
return { file: url };
}
]
});
}
console.log(run().css.toString("utf8"));
完全复制(只需运行npm i
和npm start
):https://github.com/mischnic/sass-worker-importer-错误被打印到控制台上