Skip to content

Emitted code uses regeneratorRuntime #7

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

Closed
LinusU opened this issue May 29, 2018 · 6 comments · Fixed by #11
Closed

Emitted code uses regeneratorRuntime #7

LinusU opened this issue May 29, 2018 · 6 comments · Fixed by #11

Comments

@LinusU
Copy link

LinusU commented May 29, 2018

The emitted code that this module publishes, uses regeneratorRuntime which makes it fail without that. Because of this, you cannot use this module out of the box on e.g. Node.js 10.x.

node_modules/stream-to-async-iterator/stream-to-async-iterator.js:134
            var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
                                         ^

ReferenceError: regeneratorRuntime is not defined
    at node_modules/stream-to-async-iterator/stream-to-async-iterator.js:134:42
    at node_modules/stream-to-async-iterator/stream-to-async-iterator.js:197:10
    at Object.<anonymous> (node_modules/stream-to-async-iterator/stream-to-async-iterator.js:246:2)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Module.require (internal/modules/cjs/loader.js:650:17)
    at require (internal/modules/cjs/helpers.js:20:18)
@basicdays
Copy link
Owner

Good point, will need to see if there's a way to publish this both transpiled and non-transpiled. You happen to know if there's any standard approach to that? Otherwise I could just publish it twice.

@basicdays
Copy link
Owner

Tell you what, in the meantime I'll just switch this out to use babel-runtime as a dependency. I'll have to consider a way to publish this without transpilation so it "just works" in newer node versions.

@LinusU
Copy link
Author

LinusU commented May 29, 2018

No stress from my side, I wrote an alternative implementation that doesn't use await in the source code at all: https://github.com/LinusU/async-chunks/blob/master/index.ts

It seems like you are only using await at one place, it would probably be easy to get rid of 🤔

On the other hand, another way to solve it would probably be to get flow to target es2015 instead of es5. At least that is how it works in TypeScript, was a while since I last used flow.

Basically, that will tell flow that the target supports generators (which all current versions of Node.js does) and thus won't need regenerator to work. This is probably the best solution since the output code will probably be more performant.

@basicdays
Copy link
Owner

Yeah I'm bumping the version to node 6 and dropping node 4 support. I also intend to switch out flow to typescript as well soon, since that's what I use these days.

@basicdays
Copy link
Owner

Just released a version that should remove the global dependency on regenerator runtime. I didn't release it out of beta yet however, so if you would like to try it out, it's released under stream-to-async-iterator@beta.

basicdays added a commit that referenced this issue Mar 16, 2022
-   Breaking Change: Dropping support for Node 11 and below.
-   Breaking Change: Dropping support for Flow.
-   Bug Fix: Resolves #5. Event handlers are cleaned up after each iteration, fixing some memory leak issues.
-   Bug Fix: Resolves #7. Code no longer depends on babel runtimes or regenerator.
-   Bug Fix: Handles stream not buffering due to starving the event loop.
-   Feature: Resolves #1. Now handles `.throw` and `.return` hooks on the async iterator.
-   Feature: Properly closes stream when finished.
-   Feature: Added support for TypeScript.
-   Feature: Support for Node.js versions 12, 14, and 16.
-   Chore: General overhaul of project setup (should not impact what is published).
@basicdays
Copy link
Owner

Release in v1.0.0

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 a pull request may close this issue.

2 participants