Skip to content

compiler-sfc failed to resolve external type imports under subdirectory #8849

@Bernankez

Description

@Bernankez

Vue version

3.3.4

Link to minimal reproduction

https://stackblitz.com/edit/stackblitz-starters-5bbywb?description=Starter%20project%20for%20Node.js,%20a%20JavaScript%20runtime%20built%20on%20Chrome%27s%20V8%20JavaScript%20engine&file=package.json,Test.vue,src%2Ftypes2.ts,src%2FTest.vue,src%2Findex.ts,package-lock.json&title=node.new%20Starter

Steps to reproduce

run

$ npm run dev

It works well.

then run

$ npm run dev:src

It fails with

Error: [@vue/compiler-sfc] Failed to resolve import source "./types2".

anonymous.vue
6  |  import type { Props } from './types2';
7  |  
8  |  defineProps<Props>();
   |              ^^^^^
9  |  </script>
10 |  
    at async ESMLoader.import (https://stackblitzstarters5bbywb-abfr.w-corp.staticblitz.com/blitz.bec01ace.js:35:1347715)
    at async i.loadESM (https://stackblitzstarters5bbywb-abfr.w-corp.staticblitz.com/blitz.bec01ace.js:35:352602)
    at async handleMainPromise (https://stackblitzstarters5bbywb-abfr.w-corp.staticblitz.com/blitz.bec01ace.js:35:1051734)
Failed running './src/index.ts'

What is expected?

compileScript should compile external relative type imports.

What is actually happening?

compile failed

System Info

System:
    OS: macOS 13.5
    CPU: (8) arm64 Apple M2
    Memory: 53.84 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
    npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm
    pnpm: 8.6.2 - ~/.nvm/versions/node/v18.15.0/bin/pnpm
  Browsers:
    Chrome: 114.0.5735.248
    Safari: 16.6

Any additional comments?

Seems that const filename = joinPaths(scope.filename, '..', source) filename here lacks of relative path.

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