vuejs / vue-loader

📦 Webpack loader for Vue.js components
MIT License
4.99k stars 915 forks source link

Cannot import .vue file outside root directory #1922

Open dmtkpv opened 2 years ago

dmtkpv commented 2 years ago

Version

16.8.3

Reproduction link

github.com

Steps to reproduce

git clone https://github.com/dmtkpv/vue-loader-issue.git
cd vue-loader-issue/package1
npm install
npm run build

Project structure

package1
├─ src
│   └─ index.js
├─ package.json
└─ webpack.config.js

package2
...

package3
...

shared
└─ shared-component.vue

The error occurs while importing shared/shared-component.vue in package1/src/index.js

import SharedComponent from '../../shared/shared-component.vue'

What is expected?

No errors

What is actually happening?

ERROR in ../shared/shared-component.vue?vue&type=template&id=e37cff36 (./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[1]!./node_modules/vue-loader/dist/index.js??ruleSet[1].rules[2].use[0]!../shared/shared-component.vue?vue&type=template&id=e37cff36) 1:0-88
Module not found: Error: Can't resolve 'vue' in '/project/shared'
skjnldsv commented 2 years ago

Same problem here, did you find a solution?