ZachJW34 / nx-plus

Collection of Nx Community Plugins
MIT License
300 stars 52 forks source link

[vite] `appRootPath` is undefined in `vite.config.ts` #282

Open HipyCas opened 1 year ago

HipyCas commented 1 year ago

Current Behavior

I created a fresh project with @nx-plus/vite and Vue. It worked, until I added a path alias to tsconfig.base.json. Now, it is giving me the following error when executing:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:388:5)
    at validateString (node:internal/validators:114:11)
    at join (node:path:1172:7)
    at /home/hipy/ceebi/code2/apps/admin/vite.config.ts:73:57
    at Array.map (<anonymous>)
    at /home/hipy/ceebi/code2/apps/admin/vite.config.ts:73:22
    at Array.reduce (<anonymous>)
    at Object.<anonymous> (/home/hipy/ceebi/code2/apps/admin/vite.config.ts:70:72)
    at Module._compile (node:internal/modules/cjs/loader:1112:14)
    at _require.extensions.<computed> [as .js] (file:///home/hipy/ceebi/code2/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:63154:24)

Which seems to come from the following import at the top:

import { appRootPath } from '@nrwl/tao/src/utils/app-root';

I installed @nrwl/tao as a dev dependency, but it didn't fix it and appRootPath is showing up as undefined.

Expected Behavior

Use some way that does not use part of a library that is not exported and thus undefined.

Steps to Reproduce

  1. Create a new project in a fresh workspace.
  2. Define a path in tsconfig.base.json in the workspace root, for example "@code/*": ["libs/*/src/index.ts"] (the one that nx defines for libs).
  3. Run either nx serve my-app or nx build my-app and see it fail.

Failure Logs

Already included above, I have no more logs to show

Environment

Plugin name and version: @nx-plus/vite@15.0.0-rc.0

>  NX   Report complete - copy this into the issue template

   Node : 18.4.0
   OS   : linux x64
   npm  : 8.12.1

   nx : 15.5.1
   @nrwl/angular : Not Found
   @nrwl/cypress : 15.5.1
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.5.1
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.5.1
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.5.1
   @nrwl/js : 15.5.1
   @nrwl/linter : 15.5.1
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : 15.0.2
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/rollup : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/webpack : Not Found
   @nrwl/workspace : 15.5.1
   @nrwl/vite : Not Found
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:
         @nx-plus/vite: 15.0.0-rc.0