Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

bug: wrong file path when creating route in monorepo #53

Open
2 tasks done
HigherOrderLogic opened this issue Jan 10, 2023 · 1 comment
Open
2 tasks done

bug: wrong file path when creating route in monorepo #53

HigherOrderLogic opened this issue Jan 10, 2023 · 1 comment

Comments

@HigherOrderLogic
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.11.0

Plugin version

@fastify/vite: ^3.0.4, @fastify/vue: ^@0.1.0

Node.js version

18.x

Operating system

Windows

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

10

Description

When building project inside monorepo, file path is wrong.

Error
vite v4.0.4 building for production...
✓ 11 modules transformed.
Could not resolve "./project/name/app/frontend/D:/project/name/app/frontend/src/pages/index.vue" from "../../../../../dx:routes.js"
file: /dx:routes.js
error during build:
RollupError: Could not resolve "./project/name/app/frontend/D:/project/name/app/frontend/src/pages/index.vue" from "../../../../../dx:routes.js"
    at error (file:///D:/project/name/node_modules/rollup/dist/es/shared/rollup.js:1967:30)
    at ModuleLoader.handleInvalidResolvedId (file:///D:/project/name/node_modules/rollup/dist/es/shared/rollup.js:23095:24)
    at file:///D:/project/name/node_modules/rollup/dist/es/shared/rollup.js:23058:26

Steps to Reproduce

  • Folder structure:
app/
|
|_backend/
|	|_package.json
|	|_src/
|
|_frontend/
|	|_vite.config.ts
|	|_client/
|
|_package.json
|_node_modules/
  • Step to reproduce: Run build command inside frontend folder.

Expected Behavior

Build success.

@dkamorin
Copy link

Got similar error. My case is Win 10 and fresh boilerplate Vue project from this repo.

As I can see the issue happens in transformGlobImport method at node_modules/@fastify/vite/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:35470, but I have no understanding how it can be fixed.

There's a row let importPath = relative(dir, file) in this method, where relative is POSIX method (defined in a code above).
Finally for

dir='/'
file='C:/Users/myusername/projectname/client/pages/client-only.vue'

I get

importPath='Users/myusername/projectname/C:/Users/myusername/projectname/client/pages/client-only.vue'

Right now after number of hours I found that it works with

let importPath = path$o.relative(dir, file);

instead of

let importPath = relative(dir, file);

(where path$o.relative is cross-platform node:path method). But I don't know yet how to prepare this in PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants