-
-
Notifications
You must be signed in to change notification settings - Fork 368
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
[BUG] ts-node/register not compatible with Danger even when DANGER_DISABLE_TRANSPILATION=true #1107
Comments
Quick guess because I'm about go step into a meeting. I'm not certain the root cause will be those overrides (though I think it's a good guess) - it's possible that the "evaluation" sub-process doesn't know about ts-node at all ( e.g. the thing that powers this:: https://danger.systems/js/usage/danger-process.html ) e.g. maybe some of these flags need to go through this? danger-js/source/commands/utils/dangerRunToRunnerCLI.ts Lines 2 to 57 in 913db0e
|
@orta also off the cuff because I'm about to head to a meeting, setting My two theories are (1) the overriding of require.extensions as i shared originally, and (2) maybe it would work, but perhaps I did want to give y'all an example of this problem and a workaround; so even if this issue gets closed WONTFIX TOO WEIRD, the next person googling "tsconfig ts-node dangerfile syntax error" will find my workaround :). |
Great points, after a re-read, I think your original suggestion is probably the right call here. I think if |
Describe the bug
Danger's built-in transpiler for Typescript produces syntax errors when it tries to build some code we import in
dangerfile.ts
. This bug report is not about danger's typescript transpiler. It's about struggling to find a work-around to a bug in danger's traspiler compiler.Because Danger's built-in transpiler can't run our dangerfile, we want to use our standard
TS_NODE_PROJECT="tsconfig.tsnode.json" node -r ts-node/register/transpile-only
workflow withdanger
.However, even when setting
DANGER_DISABLE_TRANSPILATION=true
,danger
still doesn't pick up the custom require plugins registered by ts-node.This is the command I'm running:
It outputs as you'd expect for a .ts file run through danger without transpilation:
I suspect this is happening because danger overrides
require.extensions
even when transpilation is supposed to be disabled here:danger-js/source/runner/runners/inline.ts
Lines 67 to 82 in c4fa130
To Reproduce
Steps to reproduce the behavior:
danger
andts-node
.dangerfile.ts
file that does some importsExpected behavior
Danger should respect already-register
require
plugins when transpilation is disabled. I would expect the command posted to work without syntax errors.Additional context
To work around both this problem, and the original problem with Danger's typescript compiler producing syntax errors, I've decided to transpile
dangerfile.ts
usingtsc
as part of our normal build process. In that case, a different work-around is needed to avoid the transpiled typescript from erroring out due to importing the dummydanger
node module at runtime. Here's the code snippet I'm employing:The text was updated successfully, but these errors were encountered: