Skip to content

vue.config.js failing calls to require() are now ignored #5442

Closed
@mrozekma

Description

@mrozekma

Version

4.3.0

Reproduction link

https://github.com/mrozekma/vue-cli-bug-demo

Environment info

Environment Info:

  System:
    OS: Linux 4.19 Debian GNU/Linux 9 (stretch) 9 (stretch)
    CPU: (4) x64 06/8e
  Binaries:
    Node: 12.10.0 - /usr/bin/node
    Yarn: 1.19.1 - /usr/bin/yarn
    npm: 6.10.3 - /usr/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: 68.7.0esr
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0 
    @vue/babel-plugin-transform-vue-jsx:  1.1.2 
    @vue/babel-preset-app:  4.3.1 
    @vue/babel-preset-jsx:  1.1.2 
    @vue/babel-sugar-functional-vue:  1.1.2 
    @vue/babel-sugar-inject-h:  1.1.2 
    @vue/babel-sugar-v-model:  1.1.2 
    @vue/babel-sugar-v-on:  1.1.2 
    @vue/cli-overlay:  4.3.1 
    @vue/cli-plugin-babel: ^4.3.0 => 4.3.1 
    @vue/cli-plugin-router: ^4.3.0 => 4.3.1 
    @vue/cli-plugin-typescript: ^4.3.0 => 4.3.1 
    @vue/cli-plugin-vuex:  4.3.1 
    @vue/cli-service: ^4.3.0 => 4.3.1 
    @vue/cli-shared-utils:  4.3.1 
    @vue/component-compiler-utils:  3.1.2 
    @vue/preload-webpack-plugin:  1.1.1 
    @vue/web-component-wrapper:  1.2.0 
    typescript: ~3.8.3 => 3.8.3 
    vue: ^2.6.11 => 2.6.11 
    vue-hot-reload-api:  2.3.4 
    vue-loader:  15.9.2 
    vue-router: ^3.1.6 => 3.1.6 
    vue-style-loader:  4.1.2 
    vue-template-compiler: ^2.6.11 => 2.6.11 
    vue-template-es2015-compiler:  1.9.1 
  npmGlobalPackages:
    @vue/cli: 4.2.2

Steps to reproduce

Run yarn serve. It will load successfully. Then downgrade to @vue/[email protected] and yarn serve will correctly fail.

What is expected?

ERROR Error loading vue.config.js:
ERROR Error: Cannot find module 'bad-module'

What is actually happening?

Server loads successfully


Commit f1bdf73 simplified vue.config.js loading by not checking if the file exists, but instead just require()-ing it and catching the failure if it doesn't. However, this also suppresses cases where vue.config.js exists, but it in turn calls require() on something that doesn't exist, since all the exception handling code looks for is e.code === 'MODULE_NOT_FOUND'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions