Skip to content

vue-cli-4 breaks disambiguation of file name #4636

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

Closed
bodograumann opened this issue Oct 1, 2019 · 6 comments
Closed

vue-cli-4 breaks disambiguation of file name #4636

bodograumann opened this issue Oct 1, 2019 · 6 comments

Comments

@bodograumann
Copy link
Contributor

Version

4.0.0-rc.6

Environment info

Environment Info:

  System:
    OS: Linux 4.19 Gentoo/Linux undefined
    CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
  Binaries:
    Node: 8.12.0 - /usr/bin/node
    Yarn: 1.17.3 - ~/.local/bin/yarn
    npm: 6.4.1 - /usr/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: 60.7.2
  npmGlobalPackages:
    @vue/cli: 4.0.0-rc.6

Steps to reproduce

Install a vue-cli preset, which (installs a vue-cli plugin that / itself) detects whether it needs to modify router.js or router.ts in the following way:

  const routerFile = fs.existsSync(api.resolve("src/router.ts"))
    ? "src/router.ts"
    : "src/router.js";
  api.transformScript(routerFile, ({ source }, { jscodeshift: j }) => {

What is expected?

The correct file is targeted.

What is actually happening?

An error is thrown:

ERROR TypeError: Received an unexpected value [object Undefined]

This, in my experience, means that routerFile does not exist (in the file system or the vue-cli working buffer respectively).


In vue-cli-3 the typescript plugin moved router.js to router.ts in a post-processing step. So when applying transformScript on that file in a preset, it needed to target router.js. If the transformation is applied later, e.g. with vue invoke after the typescript plugin was already added, it needed to target router.ts.

The above disambiguation works for vue-cli@^3.9, but not for vue-cli@4.0.0-rc6

@haoqunjiang
Copy link
Member

Is it because in Vue CLI 4 the directory structure changed to router/index.js rather than router.js? Since this PR #4196

@bodograumann
Copy link
Contributor Author

You are absolutely right, @sodatea. So I guess this is a request for a upgrade guide for plugin authors :-D

Also I found out now, from that PR, that routerHistoryMode becomes plugins["@vue/cli-plugin-router"].historyMode and that router and vuex options are replaced with the plugins.

@haoqunjiang
Copy link
Member

Yeah, definitely need to document it.

The legacy preset options are still supported, though.

@GoodGuyGregory
Copy link

Where would these Sections need to be documented in the Repository?
vue-cli/docs/core-plugins/
Would this be an ideal place? Under each Section Header?

@haoqunjiang
Copy link
Member

https://deploy-preview-4552--vue-cli.netlify.com/migrating-from-v3/#vue-router-and-vuex-now-have-corresponding-cli-plugins

Added the changelog here.

But I'm not sure if we should document the generator directory structure like other public APIs.

@haoqunjiang
Copy link
Member

Added in the documentation.

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

No branches or pull requests

3 participants