Skip to content
This repository has been archived by the owner on Oct 24, 2022. It is now read-only.

Reproduce bug occurring in the compiled code of webpack and swc-loader when using the result of two async functions directly when calling another one.

Notifications You must be signed in to change notification settings

finnboeger/swc-loader-async-bug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Run npm run build-swc and e.g. npx http-server dist to see the error in the console: TypeError: Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.

This happens because webpack + swc-loader somehow lead to the following js code:

_asyncToGenerator(function() {
    var _tmp;
    return __generator(this, function(_state) {
        switch(_state.label){
            case 0:
                return [
                    4,
                    a()
                ];
            case 1:
                _tmp = [
                    _state.sent()
                ];
                return [
                    4,
                    a()
                ];
            case 2:
                return [
                    2,
                    b.apply(void 0, _tmp.concat(_state.sent()))
                ];
        }
    });
})().then();

where _tmp.concat(_state.sent())) already deconstructs the array when passing it to the function instead of passing the whole array as one argument.

About

Reproduce bug occurring in the compiled code of webpack and swc-loader when using the result of two async functions directly when calling another one.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published