Skip to content

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

Closed
@bodograumann

Description

@bodograumann

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

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