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

Vite: Vue single file component imports cause error during build and import.meta.env #995

Closed
gionkunz opened this issue Aug 18, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@gionkunz
Copy link
Contributor

Describe the bug
Since Nx 16.4.0 the @nx/vite build executor runs a TypeScript type check before the vite build. This new behaviour is turned on by default.

See: nrwl/nx@b953565#diff-25207db542ebf5643a1b5bf75c5e812f6503b1026bfc8a156b7fc82b4bb0ab43R24-R28
And: https://github.com/nrwl/nx/blob/master/packages/vite/src/executors/build/build.impl.ts#L47-L53

I think this potentially breaks a lot of projects and should have been introduced with skipTypeCheck=true for 16.* with a warning and switched to skipTypeCheck=false in Nx 17.

image

As a consequence, we need to make the generated projects compatible with a regular TS type check and therefore shim the Vue SFC within an included .d.ts file.

The second issue found in the generated default app in the router config is related to a different issue. The missing type augmentation from vite/client.d.ts for import.meta are not available because the types in tsconfig.app.json override the types specified in tsconfig.json. The best way to fix this would be to add vite/client.d.ts to the types specified in tsconfig.app.json or even remove the types from it completely and let it inherit from tsconfig.json.

To Reproduce

  • Use any version of Nx after 16.4.0
  • Install nxext/vue
  • Generate a new app with the router config turned on
  • Run a build

Expected behavior
The build should complete without any errors.

@gionkunz gionkunz added the bug Something isn't working label Aug 18, 2023
gionkunz added a commit to gionkunz/nx-extensions that referenced this issue Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant