danger-js: Automatic Babel Transformation problematic
Hey Orta!
Thanks for all your hard work on Danger. Fantastic tool 😃.
I’m running into an issue with the automatic Babel transformation that I wanted to discuss with you and any other collaborators before submitting a Pull Request.
My project is a pretty standard webpack/babel compiled front-end application. I’m running Danger on node 8.x, so I really do not need Babel transformation of my dangerfile.
Right now, because of my babel-preset-env config for builds targeting web browsers, template literals in my dangerfile are being compiled to ES5. This would be fine, except my .babelrc is setup to use transform-runtime. This is problematic because Babel 6 has a bug where transform-runtime injects import declarations rather than require calls. After this happens, Danger fails on calls to node’s module._compile.
I can work around this issue by moving everything in my Babel config to use the env feature temporarily, and have no “default” babel config. However, I’m concerned that the automatic Babel transformation in Danger without an opt-out is a bit heavy-handed.
Would you be willing to accept a PR that disables Babel/TypeScript transformation?
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 2
- Comments: 20 (16 by maintainers)
Just to chime in, the default example of setting up an action with the following gets the same
Error: Cannot find module '@babel/plugin-transform-flow-strip-types' from '/github/workspace'error. Sounds like it’s the same issue?@brandonjmckay Setting
DANGER_DISABLE_TRANSPILATION="true"env var fixed it for me.Yep, a CLI flag makes sense for that 👍
I started looking into it and I noticed there’s already an env var:
DANGER_DISABLE_TRANSPILATIONneeds to be set to"true". That solves it for me.Cool, yeah sure, you’re welcome to add an option, or an env var etc 👍
I use typescript for all my dangerfiles, so it’s not a pain for me
I’ve run into problems related to this a few times, too.
The
transpiler.tsfile is quite problematic for me. I use Babel 7 TypeScript but it is not detected because I’m using the scoped version of the Babel packages – what ends up happening is thattransform-flow-strip-typesgets picked up due to it being installed within my monorepo by Storybook’sbabel-preset-react(viababel-preset-flow), and finally mybabel.config.jsfile gets loaded with its actual@babel/preset-typescriptand obviously this is not a valid configuration so it fails.I definitely think this is something we should be able to switch off. Perhaps it’d also be possible to change the defaults here?
@DrewML Are you still going to submit a PR request for this?