-
-
Notifications
You must be signed in to change notification settings - Fork 535
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
Can't use dynamic imports with swc #1508
Comments
Does swc's transpiled output have a runtime dependency on |
@cspotcode My application doesn't use regenerator-runtime directly, and the code runs correctly with ts-node without enabling swc, but it seems that swc expects regenerator-runtime to be available. |
That would fall into the same category as tslib and @swc/helpers. Sometimes changing compiler options necessitates that additional dependencies be available. Notably, even if we declared them as peerDependencies, they would still need to be declared in your package.json since they are being imported/required by your code as opposed to by ts-node. I believe certain flavors of yarn enforce this. We don't want to declare them as peerDependencies because then they get eagerly installed by npm even in projects that don't need them. We will accept a PR adding this to our docs, probably belongs on this page where we mention @swc/helpers https://typestrong.org/ts-node/docs/transpilers#bundled-swc-integration |
Okay, that makes sense. Adding |
Thanks. It also occurred to me, we can detect when an import fails and log a helpful warning. For example, when a file compiled by ts-node attempts to |
* Fix inconsistent reference to ts-node in docs * docs: regenerator-runtime dependency for swc (#1508) (#1509) * docs: regenerator-runtime dependency for swc (#1508) * docs(transpilers): update advice for installing regenerator-runtime * Update transpilers.md Co-authored-by: Andrew Bradley <cspotcode@gmail.com> Co-authored-by: Peter Coulton <petercoulton@gmail.com>
Search Terms
Expected Behavior
Dynamic imports should continue to work after switching to the swc transpiler.
Actual Behavior
Throws
Error: Cannot find module 'regenerator-runtime
Steps to reproduce the problem
See TypeStrong/ts-node-repros#20 for full example.
Minimal reproduction
TypeStrong/ts-node-repros#20
Specifications
The text was updated successfully, but these errors were encountered: