question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Example Dangerfile does not parse with a vue-cli app

See original GitHub issue

Describe the bug When using Danger with an app generated with vue-cli, the example Dangerfile from the documentation fails to parse with SyntaxError: cannot use import statement outside a module.

The output in the GitLab CI log:

$ yarn run danger ci --failOnErrors
yarn run v1.22.5
$ /builds/unikitty37/danger-demo/node_modules/.bin/danger ci --failOnErrors
Unable to evaluate the Dangerfile
 dangerfile.js:1
import "core-js/modules/es.array.join";
^^^^^^
SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:991:16)
    at Module._compile (internal/modules/cjs/loader.js:1039:27)
    at Object.requireFromString [as default] (/builds/unikitty37/danger-demo/node_modules/require-from-string/index.js:28:4)
    at Object.<anonymous> (/builds/unikitty37/danger-demo/node_modules/danger/distribution/runner/runners/inline.js:144:63)
    at step (/builds/unikitty37/danger-demo/node_modules/danger/distribution/runner/runners/inline.js:32:23)
    at Object.next (/builds/unikitty37/danger-demo/node_modules/danger/distribution/runner/runners/inline.js:13:53)
    at /builds/unikitty37/danger-demo/node_modules/danger/distribution/runner/runners/inline.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/builds/unikitty37/danger-demo/node_modules/danger/distribution/runner/runners/inline.js:3:12)
    at Object.exports.runDangerfileEnvironment (/builds/unikitty37/danger-demo/node_modules/danger/distribution/runner/runners/inline.js:105:136)
Failing the build, there is 1 fail.
Feedback: https://gitlab.com/unikitty37/danger-demo/merge_requests/1#note_404292895
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

To Reproduce Steps to reproduce the behaviour:

  1. Fork https://gitlab.com/unikitty37/danger-demo, which uses the Dangerfile from https://danger.systems/js/guides/getting_started.html#creating-a-dangerfile
  2. Configure the DANGER_GITLAB_API_TOKEN variable in the CI settings
  3. Create an MR on the fork

Expected behaviour

The Dangerfile runs, and attaches a comment containing a list of the modified files.

Screenshots n/a

Your Environment

software version
danger.js 10.4.0
node 14.5.0
yarn 1.22.4
Operating System Docker container node:14-alpine

Additional context I’m not sure if Danger is transpiling correctly — vue-cli sets up projects with Babel by default, but https://danger.systems/js/tutorials/transpilation.html doesn’t really give me much of a clue on how to debug this…

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
themojillacommented, Jan 18, 2021

While the issue is already being closed if anyone struggles with this issue just add the join polyfills in the babel.config.js. this will do the trick.

module.exports = {
  presets: [
    ['@vue/cli-plugin-babel/preset', {
      polyfills: [
        'es.array.join',
      ],
    }],
  ],
};
1reaction
YasiOnFirecommented, Sep 6, 2020

Same problem, similar setup (vue). Dind’t work either in CI or locally. I’ve tried to debug the source provided by @orta, but with no luck. However just changed dangerfile to typescript and everything works in CI as well as locally.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Running into "couldn't infer parser" error using vue-cli
I'm not sure why, but I tried to downgrade to 1.2.1 using yarn , but it didn't seem to work. The thing that...
Read more >
Vue.js | IntelliJ IDEA Documentation - JetBrains
js app is the create-vue official Vue project scaffolding tool, which IntelliJ IDEA downloads and runs for you using npx. You can still...
Read more >
From vue-cli to vitejs - Medium
I recently migrated some Vue2 projects from vue-cli / webpack to vitejs. ... Now with vite, WebStorm doesn't know yet how to parse...
Read more >
Modes and Environment Variables - Vue CLI
With NODE_ENV set to "test" for example, Vue CLI creates a webpack config that is intended to be used and optimized for unit...
Read more >
How to Migrate from Vue CLI to Vite - Vue School Blog
The approach also means that Hot Module Replacement remains fast no matter the size of the application since the entire bundle doesn't have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found