Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make sure regeneratorRuntime isn't included in the cjs build #224

Merged
merged 1 commit into from
Feb 15, 2024

Conversation

gvergnaud
Copy link
Owner

The CJS build of TS-Pattern generates es5 javascript code, and turns the generator syntax into regeneratorRuntime calls, a function that's part of Babel's standard library:

(((t = {})[Symbol.iterator] = function () {
          /*#__PURE__*/ return regeneratorRuntime.mark(function t() {
            var r;
            return regeneratorRuntime.wrap(function (t) {
              // ...
            }, t);
          })();
        }),

The issue is that there is no guarantee that this function is in scope where TS-Pattern's CJS build is executed. This is a microbundle bug that has a closed issue here: developit/microbundle#708 it's supposedly fixed, but I still see this behavior with the latest version of micro bundle, so this PR just turns the only generator of TS-Pattern into an iterator object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant