Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@vue/compiler-sfc] No fs option provided to compileScript in non-Node environment. when importing types in Vue file #565

Open
mschwebler-tgm opened this issue Sep 23, 2024 · 0 comments

Comments

@mschwebler-tgm
Copy link

Reproduction repository: https://github.com/mschwebler-tgm/vue-jest-reproduction-example

Problem description

Given we import a TS type,
When we use that type in vue's defineProps<> API,
We get an error when running the unit tests:

[@vue/compiler-sfc] No fs option provided to `compileScript` in non-Node environment. File system access is required for resolving imported types.

    /Users/user/repos/vue-jest-reproduction-example/src/components/Example.vue
    6  |  import type {ExampleProps} from "@/components/ExampleProps";
    7  |  
    8  |  const data = defineProps<ExampleProps>();
       |                           ^^^^^^^^^^^^

Node: 18.20.4
npm: 10.7.0
jest: 29.7.0
vue: 3.4.38
@vue/vue3-jest: 29.2.6

Details

  • The error occurs when we import TS types and use them in Vue's API functions (defineProps, defineEmits, etc...)
  • The error does not occur when the type is used for anything else
  • For commonjs projects a workaround exists here - this does not work for ESM module projects

Steps to reproduce

  1. Clone the repository
  2. Install dependencies npm i
  3. Run tests npm run test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant