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.

vue-cli-4 breaks disambiguation of file name

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sodateacommented, Oct 16, 2019

Added in the documentation.

0reactions
sodateacommented, Oct 4, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to customise names of the JS files produced by Vue CLI?
I'm sure Vue CLI minifies JS output when running build in production mode. It's just using different naming convention (no "min.js").
Read more >
Commons:File renaming
The file rename function allows renaming (or "moving") of files, which works basically the same way as "normal" page moves.
Read more >
Configuration | Vue Styleguidist
getComponentPathLine. Type: Function , default: component file name. Function that returns a component path line (displayed under the component name).
Read more >
8.3 filename - Wikipedia
An 8.3 filename is a filename convention used by old versions of DOS and versions of Microsoft Windows prior to Windows 95 and...
Read more >
Static / Fixed filenames for generated vue-cli builds
How to setup vue.config.js for static assets. Tagged with beginners, vue, javascript, buildtools.
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