Skip to content
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

fix(cli): avoid assertion error when vue.config.js includes assignment expression #2770

Merged
merged 1 commit into from
Oct 28, 2018

Conversation

ktsn
Copy link
Member

@ktsn ktsn commented Oct 18, 2018

There is a case that Vue CLI fails to add a plugin with the following assertion error (it's a case adding vue-cli-plugin-quasar):

🚀  Invoking generator for vue-cli-plugin-quasar...
 ERROR  Error: Must either call this.traverse or return false in visitAssignmentExpression
Error: Must either call this.traverse or return false in visitAssignmentExpression
    at Context.invokeVisitorMethod (/xxx/node_modules/@vue/cli/node_modules/ast-types/lib/path-visitor.js:365:21)
    at Visitor.PVp.visitWithoutReset (/xxx/node_modules/@vue/cli/node_modules/ast-types/lib/path-visitor.js:196:32)
    at visitChildren (/xxx/node_modules/@vue/cli/node_modules/ast-types/lib/path-visitor.js:246:25)
    at Visitor.PVp.visitWithoutReset (/xxx/node_modules/@vue/cli/node_modules/ast-types/lib/path-visitor.js:204:20)
    at NodePath.each (/xxx/node_modules/@vue/cli/node_modules/ast-types/lib/path.js:101:26)
    at visitChildren (/xxx/node_modules/@vue/cli/node_modules/ast-types/lib/path-visitor.js:219:18)
    at Visitor.PVp.visitWithoutReset (/xxx/node_modules/@vue/cli/node_modules/ast-types/lib/path-visitor.js:204:20)
    at visitChildren (/xxx/node_modules/@vue/cli/node_modules/ast-types/lib/path-visitor.js:246:25)
    at Visitor.PVp.visitWithoutReset (/xxx/node_modules/@vue/cli/node_modules/ast-types/lib/path-visitor.js:204:20)
    at visitChildren (/xxx/node_modules/@vue/cli/node_modules/ast-types/lib/path-visitor.js:246:25)

The reason is extendJSConfig function does not handle the case that vue.config.js includes assignment expression not for module.exports. For example, the following vue.config.js provides the error:

process.env.VUE_APP_SOME_VAR = 'test'

module.exports = {
  // ...
}

We need to explicitly call this.traverse() method in the visitor function to avoid this error and this PR is adding it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants