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 3 defineProps fail with imported types #9565

Closed
Demivan opened this issue Mar 6, 2024 · 2 comments
Closed

Vue 3 defineProps fail with imported types #9565

Demivan opened this issue Mar 6, 2024 · 2 comments
Labels

Comments

@Demivan
Copy link

Demivan commented Mar 6, 2024

🐛 bug report

When using Vue defineProps<Type>() compilation fails when type is imported from a separate file.

<script setup lang="ts">
import type { ExternalProps } from './types';

defineProps<ExternalProps>();
</script>

🎛 Configuration (.babelrc, package.json, cli command)

Default config

{
  "scripts": {
    "build": "parcel build index.html"
  },
  "devDependencies": {
    "@parcel/transformer-vue": "2.12.0",
    "parcel": "^2.12.0"
  },
  "dependencies": {
    "vue": "^3.4.21"
  }
}

🤔 Expected Behavior

Using imported types for defineProps (and other Vue macros) should work.

😯 Current Behavior

  Error: [@vue/compiler-sfc] No fs option provided to `compileScript` in non-Node environment. File system access is required for resolving imported types.
  
  /parcel-vue/src/App.vue
  2  |  import type { ExternalProps } from './types';
  3  |  
  4  |  defineProps<ExternalProps>();
     |              ^^^^^^^^^^^^^
  5  |  </script>
  6  |  
      at ScriptCompileContext.error (/parcel-vue/node_modules/.pnpm/@[email protected]/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:15575:11)
      at importSourceToScope (/parcel-vue/node_modules/.pnpm/@[email protected]/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:18385:16)
      at resolveTypeFromImport (/parcel-vue/node_modules/.pnpm/@[email protected]/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:18374:23)
      at innerResolveTypeReference (/parcel-vue/node_modules/.pnpm/@[email protected]/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:18261:14)
      at resolveTypeReference (/parcel-vue/node_modules/.pnpm/@[email protected]/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:18249:20)
      at innerResolveTypeElements (/parcel-vue/node_modules/.pnpm/@[email protected]/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:17854:24)
      at resolveTypeElements (/parcel-vue/node_modules/.pnpm/@[email protected]/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:17799:20)
      at resolveRuntimePropsFromType (/parcel-vue/node_modules/.pnpm/@[email protected]/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:19324:20)
      at extractRuntimeProps (/parcel-vue/node_modules/.pnpm/@[email protected]/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:19300:17)
      at genRuntimeProps (/parcel-vue/node_modules/.pnpm/@[email protected]/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:19288:18)

💁 Possible Solution

Pass fs configuration to compileScript.

🔦 Context

💻 Code Sample

https://github.com/Demivan/parcel-vue

🌍 Your Environment

Software Version(s)
Parcel 2.12.0
Node 21.6.2
pnpm 8.12.1
Operating System Linux (NixOS)
@mischnic mischnic added the Vue label Apr 5, 2024
Copy link

github-actions bot commented Oct 2, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

@github-actions github-actions bot added the Stale Inactive issues label Oct 2, 2024
@danwomersley
Copy link

I've had the same issue. Did you find a solution?

@github-actions github-actions bot removed the Stale Inactive issues label Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants