fastify / fastify-vite

Fastify plugin for Vite integration
MIT License
891 stars 75 forks source link

@fastify/vue Smart Import doesn't resolve path in windows #144

Closed agorem closed 8 months ago

agorem commented 8 months ago

Prerequisites

Fastify version

4.26.2

Plugin version

6.0.6

Node.js version

20.10.0

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

11

Description

Hi,

I have downloaded in my Win11 laptop the starter project vue-kitchensink.

After installing the node modules, when I run npm run dev I get loads of errors related with the Smart import URL resolution :

Below you have some examples:

12:54:15 [vite] Pre-transform error: Failed to load url ./$_dev/$_js_projects/vue-kitchensink/C:/$_dev/$_js_projects/vue-kitchensink/client/pages/index.vue (resolved id: ./$_dev/$_js_projects/vue-kitchensink/C:/$_dev/$_js_projects/vue-kitchensink/client/pages/index.vue) in /:routes.js. Does the file exist? 12:54:15 [vite] Pre-transform error: Failed to load url ./$_dev/$_js_projects/vue-kitchensink/C:/$_dev/$_js_projects/vue-kitchensink/client/pages/form/[id].vue (resolved id: ./$_dev/$_js_projects/vue-kitchensink/C:/$_dev/$_js_projects/vue-kitchensink/client/pages/form/[id].vue) in /:routes.js. Does the file exist?
12:54:15 [vite] Pre-transform error: Failed to load url ./$_dev/$_js_projects/vue-kitchensink/C:/$_dev/$_js_projects/vue-kitchensink/client/pages/client-only.vue (resolved id: ./$_dev/$_js_projects/vue-kitchensink/C:/$_dev/$_js_projects/vue-kitchensink/client/pages/client-only.vue) in /:routes.js. Does the file exist?

Any help??

Steps to Reproduce

Just make a fresh starter install and run

Expected Behavior

The resolved ID path in my project should be: C:/$_dev/$_js_projects/vue-kitchensink/client/* and not ./$_dev/$_js_projects/vue-kitchensink/C:/$_dev/$_js_projects/vue-kitchensink/client/**

agorem commented 8 months ago

Hi, I think I have located the bug The problem is in fastify > vue > plugin.cjs globalPattern routing property

The reference to vue pages should be relative and not absolute.

Kind regards...Antonio

agorem commented 8 months ago

In virtual>layout.vue there is the same problem in the layout pattern: const appLayouts = import.meta.glob('/layouts/*.vue', { eager: true })

Shyam-Chen commented 8 months ago

This is the known issue. (https://github.com/fastify/fastify-vite/pull/141)

The issue arises from the injected path:

I'm currently working on developing another version of vite-plugin-vue-routes and vite-plugin-fastify-routes for use with @fastify/vite.

agorem commented 8 months ago

Thanks @Shyam-Chen, I'll wait for the update. Meanwhile, I assume that I can bypass the problem using my own routes,js.

galvez commented 8 months ago

Yes you can!

justekoro commented 5 months ago

hi, does not seem to be fixed yet?