Description
I'm encountering an error when trying to import the Danger module in my Dangerfile.js. Additionally, the provided Spectrum discussion thread link (https://spectrum.chat/?t=0a005b56-31ec-4919-9a28-ced623949d4d) is broken and returns a 404 error.
Error Message:
throw "\nHey there, it looks like you're trying to import the danger module. Turns out\nthat the code you write in a Dangerfile.js is actually a bit of a sneaky hack. \n\nWhen running Danger, the import or require for Danger is removed before the code\nis evaluated. Instead all of the imports are added to the global runtime, so if\nyou are importing Danger to use one of it's functions - you should instead just\nuse the global object for the root DSL elements.\n\nThere is a spectrum thread for discussion here:\n - https://spectrum.chat/?t=0a005b56-31ec-4919-9a28-ced623949d4d\n";
^
Hey there, it looks like you're trying to import the danger module. Turns out
that the code you write in a Dangerfile.js is actually a bit of a sneaky hack.
When running Danger, the import or require for Danger is removed before the code
is evaluated. Instead all of the imports are added to the global runtime, so if
you are importing Danger to use one of it's functions - you should instead just
use the global object for the root DSL elements.
There is a spectrum thread for discussion here:
- https://spectrum.chat/?t=0a005b56-31ec-4919-9a28-ced623949d4d
(Usenode --trace-uncaught ...
to show where the exception was thrown)
Node.js v20.11.0
Steps to Reproduce:
- Create a Dangerfile.js with the following content:
`import { danger, markdown, message, warn } from 'danger';
// Example usage of danger
markdown('This is a markdown message');`
- Run the Danger.js script using Node.js v20.11.0.
Expected Behavior:
The Danger.js script should run without throwing an import error, and the appropriate actions should be executed as specified in the Dangerfile.js.
Actual Behavior:
The script throws an error indicating that importing the Danger module is not allowed. Additionally, the provided link to the Spectrum discussion thread is broken and returns a 404 error.
Environment:
Node.js version: v20.11.0
Danger.js version: [Specify the version you are using]
Additional Context:
The error suggests that the import for Danger is removed before the code is evaluated, and all imports are added to the global runtime instead. However, there is no clear documentation on this behavior, and the broken Spectrum link makes it difficult to find further information or discussion on the topic.
Please provide guidance on how to properly use Danger.js with Node.js v20.11.0 and any updates on the broken Spectrum thread link.
Activity