jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.26k stars 508 forks source link

regeneratorRuntime is not defined #684

Closed poteirard closed 4 years ago

poteirard commented 4 years ago

Hello,

I have some libraries that are meant to be used in node and web environments.

I run tsdx build, then in the consumer of the library I run tsc and then node dist/index.js then I get an error:

ReferenceError: regeneratorRuntime is not defined
[server]     at Object.<anonymous> (/Users/.../node_modules/myPakcage/random-lib/dist/random-lib.cjs.development.js:214:28)

Am I missing something?

Thank you!

tsdx -v 0.13.1

agilgur5 commented 4 years ago

Please don't remove the issue template. It is there for a reason. Please do search issues before posting duplicates -- this is a duplicate of #547 and #169

You're using generators, which require a polyfill (i.e. regeneratorRuntime). You need to decide how you're going to polyfill it and then do so. That's unrelated to and not caused by web vs node usage. But potentially worthy to note, those are two separate target platforms and TSDX has the --target flag as such (which configures things like preset-env's options for node builds).

agilgur5 commented 4 years ago

Automatic pure polyfilling of generators with babel-plugin-polyfill-regenerator for targets that need a polyfill has been added in #795 and will be released in v0.14.0 soon.