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

vue-cli build will repeat new Service when use eslint-config-standard #5585

Closed
dtcz opened this issue Jun 16, 2020 · 2 comments · Fixed by #5592
Closed

vue-cli build will repeat new Service when use eslint-config-standard #5585

dtcz opened this issue Jun 16, 2020 · 2 comments · Fixed by #5592

Comments

@dtcz
Copy link
Contributor

dtcz commented Jun 16, 2020

Version

4.4.4

Reproduction link

https://github.com/dtcz/vue-cli-eslint-bug-report

Environment info

Environment Info:

  System:
    OS: Windows 7 6.1.7601
    CPU: (2) x64 Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz
  Binaries:
    Node: 10.15.1 - C:\ThsSoftware\nodejs\node.EXE
    Yarn: 1.22.4 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.4.1 - C:\ThsSoftware\nodejs\npm.CMD
  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.4.4
    @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.4.4
    @vue/cli-plugin-babel: ~4.4.0 => 4.4.4
    @vue/cli-plugin-eslint: ~4.4.0 => 4.4.4
    @vue/cli-plugin-router:  4.4.4
    @vue/cli-plugin-typescript: ~4.4.0 => 4.4.4
    @vue/cli-plugin-vuex:  4.4.4
    @vue/cli-service: ~4.4.0 => 4.4.4
    @vue/cli-shared-utils:  4.4.4
    @vue/component-compiler-utils:  3.1.2
    @vue/eslint-config-standard: ^5.1.2 => 5.1.2
    @vue/eslint-config-typescript: ^5.0.2 => 5.0.2
    @vue/preload-webpack-plugin:  1.1.1
    @vue/web-component-wrapper:  1.2.0
    eslint-plugin-vue: ^6.2.2 => 6.2.2
    typescript: ~3.9.3 => 3.9.5
    vue: ^2.6.11 => 2.6.11
    vue-class-component: ^7.2.3 => 7.2.3
    vue-eslint-parser:  7.1.0
    vue-hot-reload-api:  2.3.4
    vue-loader:  15.9.2
    vue-property-decorator: ^8.4.2 => 8.5.0
    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: Not Found

Steps to reproduce

git clone https://github.com/dtcz/vue-cli-eslint-bug-report.git
cd vue-cli-eslint-bug-report
npm install
npm run build:2

What is expected?

promise.finally is packed

What is actually happening?

can't find promise.finally in report.html


in this file

// this file is for cases where we need to access the
// webpack config as a file when using CLI commands.
let service = process.VUE_CLI_SERVICE
if (!service || process.env.VUE_CLI_API_MODE) {
const Service = require('./lib/Service')
service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd())
service.init(process.env.VUE_CLI_MODE || process.env.NODE_ENV)
}
module.exports = service.resolveWebpackConfig()

at line 5 insert following debug

console.log(!service)

will see true which cause program repeat new Service()

@dtcz
Copy link
Contributor Author

dtcz commented Jun 16, 2020

link to #5508
i think my pr 5544 should rethink,
maybe the following is better

if (args.entry && !options.pages) {
    config.entryPoints
      .clear()

    config
      .entry('app')
      .add(api.resolve(args.entry))
}
return api.resolveWebpackConfig(config)

@dtcz
Copy link
Contributor Author

dtcz commented Jun 17, 2020

@sodatea
After careful debugging, I consider it cause by parallel options, because sub worker's process.VUE_CLI_SERVICE is null.
when I set parallel to false
and fix @vue/cli-service/lib/commands/build/resolveAppConfig.js with

module.exports = (api, args, options) => {
  // respect inline entry
  if (args.entry && !options.pages) {
    api.chainWebpack(config => {
      config.entryPoints
        .clear()

      config
        .entry('app')
        .add(api.resolve(args.entry))
    })
  }

  const config = api.resolveChainableWebpackConfig()
  // ... some other codes
  return api.resolveWebpackConfig(config)
}

It's work fine.
this isn't a eslint bug, just trigger this case by chance.
maybe the following codes
https://github.com/vuejs/eslint-config-standard/blob/4b13e72574e2c42061220265e510ebfb3576dfea/index.js#L7-L11

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 a pull request may close this issue.

1 participant