Skip to content

Remove explicit dependency installation of @vue/compiler-sfc #409

Closed
@Theiaz

Description

@Theiaz

Hello,

I'm not sure if this is even an "issue", but a little code improvement. Currently, I'm on a project using Vue 3 with Vue3-jest:

Some lines of the package.json:

  "devDependencies": {
    "@babel/core": "7.16.0",
    "@babel/preset-env": "7.16.0",
    "@vue/compiler-sfc": "3.2.22",
    "@vue/test-utils": "2.0.0-rc.16",
    "@vue/vue3-jest": "27.0.0-alpha.3",
    "babel-jest": "27.3.1",
    "jest": "27.3.1",
  },
  "dependencies": {
    "@jest/globals": "27.3.1",
    "vue": "3.2.22",
    "vue-loader": "16.8.3",
  }

I stumbled upon following change with those lines of text:

Note: as of 3.2.13+, this package is included as a dependency of the main vue package and can be accessed as vue/compiler-sfc. This means you no longer need to explicitly install this package and ensure its version match that of vue's. Just use the main vue/compiler-sfc deep import instead.

As far as I can tell, it is no longer necessary to specify the dependency "@vue/compiler-sfc": "3.2.22", in the package.json. So I removed it. However, our tests arent working anymore, jest is throwing following error message:

> jest --coverage

Error: Cannot find module '@vue/compiler-sfc'
Require stack:
- /home/node_modules/@vue/vue3-jest/lib/process.js
- /home/node_modules/@vue/vue3-jest/lib/index.js
- /home/node_modules/jest-util/build/requireOrImportModule.js
- /home/node_modules/jest-util/build/index.js
- /home/node_modules/jest-config/build/getCacheDirectory.js
- /home/node_modules/jest-config/build/Defaults.js
- /home/node_modules/jest-config/build/normalize.js
- /home/node_modules/jest-config/build/index.js
- /home/node_modules/jest/node_modules/jest-cli/build/init/index.js
- /home/node_modules/jest/node_modules/jest-cli/build/cli/index.js
- /home/node_modules/jest/node_modules/jest-cli/bin/jest.js
- /home/node_modules/jest/bin/jest.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/home/node_modules/@vue/vue3-jest/lib/process.js:1:51)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)

I did not expect that, vue-jest should be not affected if I'm deleting this dependency. However, vue-jest is still depending on @vue/compiler-sfc as a dependency (see package.json of vue-jest). Is it possible to delete this separate dependency and use deep import of @vue/compiler-sfc instead?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions