mirror of
https://github.com/swc-project/swc.git
synced 2024-12-24 14:16:12 +03:00
206c0dbebe
**Description:** Previously, the `async-to-generator` produced invalid AST, in the aspect of span hygiene. [Playground](https://play.swc.rs/?version=1.3.24&code=H4sIAAAAAAAAAz1MbQqAIBT77yn2UyG6gNQJuoSZRCAa7xkk4d1TicZgH7C5%2B4yUYGPgBE7ZuyWazREmSIVpxiMAcumi0C3ANZxyvQ6%2Fqa8CehxjaGNpOAcLaWjn%2F6KhKN1dGaoULSpfHPTdxn8AAAA%3D&config=H4sIAAAAAAAAA0WOSwrDMAxE76K1F22hXfgE3fQQxlWCi39ICsQY3z12cMlOjObNTIUfW9AVsiFGGheXKGYHDVIysiWXBRQId2kxnrEpwF2QovFv9BmJQQtt2D2GVpROIj9u92enfEqMk1MQXHRLGR02hUzIfL1MXP3f2XpFSN9tCPWccWa%2BoF0Zk3P8mcYxoR3Kj7IYzwAAAA%3D%3D). It generate two bindings for `args` so it's invalid. **Related issue:** - Closes https://github.com/swc-project/swc/issues/6730.
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
try {
|
|
var info = gen[key](arg);
|
|
var value = info.value;
|
|
} catch (error) {
|
|
reject(error);
|
|
return;
|
|
}
|
|
if (info.done) {
|
|
resolve(value);
|
|
} else {
|
|
Promise.resolve(value).then(_next, _throw);
|
|
}
|
|
}
|
|
function _asyncToGenerator(fn) {
|
|
return function () {
|
|
var self = this, args = arguments;
|
|
return new Promise(function (resolve, reject) {
|
|
var gen = fn.apply(self, args);
|
|
function _next(value) {
|
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
}
|
|
function _throw(err) {
|
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
}
|
|
_next(undefined);
|
|
});
|
|
};
|
|
}
|
|
export const styleLoader = () => {
|
|
return {
|
|
name: 'style-loader',
|
|
setup(build) {
|
|
build.onLoad({
|
|
filter: /.*/,
|
|
namespace: 'less'
|
|
}, function () {
|
|
var _ref = _asyncToGenerator(function* (args) { });
|
|
return function (args) {
|
|
return _ref.apply(this, arguments);
|
|
};
|
|
}());
|
|
}
|
|
};
|
|
};
|