LinbuduLab / esbuild-plugins

ESBuild plugins by @LinbuduLab
MIT License
113 stars 18 forks source link

[nx-plugin-vite] Missing dependencies declaration #87

Closed ricardocosta closed 1 year ago

ricardocosta commented 1 year ago

Hello,

I'm trying to use the nx-plugin-vite on a brand new NX monorepo and the following command is failing: yarn nx g nx-plugin-vite:app sandbox --framework=react --dryRun

Output

>  NX  Generating nx-plugin-vite:app

  >  NX   Cannot find module 'lodash/merge'

   Require stack:
   - /Users/ricardo/Workspace/bank/node_modules/nx-plugin-devkit/src/lib/generator-utils/package-json.js
   - /Users/ricardo/Workspace/bank/node_modules/nx-plugin-devkit/src/index.js
   - /Users/ricardo/Workspace/bank/node_modules/nx-plugin-vite/src/generators/app/generator.js
   - /Users/ricardo/Workspace/bank/node_modules/nx/src/config/workspaces.js
   - /Users/ricardo/Workspace/bank/node_modules/nx/src/config/configuration.js
   - /Users/ricardo/Workspace/bank/node_modules/nx/src/command-line/generate.js
   - /Users/ricardo/Workspace/bank/node_modules/nx/src/command-line/nx-commands.js
   - /Users/ricardo/Workspace/bank/node_modules/nx/bin/init-local.js
   - /Users/ricardo/Workspace/bank/node_modules/nx/bin/nx.js
   Pass --verbose to see the stacktrace.

If I add lodash and esbuild as devDependencies in the top-level package.json, then the command succeeds.

Since it is nx-plugin-devkit that requires esbuild and lodash as dependencies, I believe nx-plugin-vite should include them in dependencies so that users of the plugin do not need to worry about those dependencies.

Expected Output

>  NX  Generating nx-plugin-vite:app

CREATE apps/sandbox/project.json
CREATE apps/sandbox/index.html
CREATE apps/sandbox/package.json
CREATE apps/sandbox/src/App.css
CREATE apps/sandbox/src/App.tsx
CREATE apps/sandbox/src/favicon.svg
CREATE apps/sandbox/src/index.css
CREATE apps/sandbox/src/logo.svg
CREATE apps/sandbox/src/main.tsx
CREATE apps/sandbox/src/vite-env.d.ts
CREATE apps/sandbox/tsconfig.json
CREATE apps/sandbox/vite.config.ts
UPDATE package.json

NOTE: The "dryRun" flag means no changes were made.

None of these warnings being shown when running yarn install:

➤ YN0002: │ nx-plugin-vite@npm:2.2.1 [47fe8] doesn't provide @nrwl/devkit (paf740), requested by nx-plugin-devkit
➤ YN0002: │ nx-plugin-vite@npm:2.2.1 [47fe8] doesn't provide @nrwl/node (p7e761), requested by nx-plugin-devkit
➤ YN0002: │ nx-plugin-vite@npm:2.2.1 [47fe8] doesn't provide @nrwl/tao (pdd3db), requested by nx-plugin-devkit
➤ YN0002: │ nx-plugin-vite@npm:2.2.1 [47fe8] doesn't provide @nrwl/workspace (p7d1f4), requested by nx-plugin-devkit
➤ YN0002: │ nx-plugin-vite@npm:2.2.1 [47fe8] doesn't provide esbuild (p955e1), requested by nx-plugin-devkit

NX Report

 >  NX   Report complete - copy this into the issue template

   Node : 18.10.0
   OS   : darwin arm64
   yarn : 3.2.3

   nx : 14.8.3
   @nrwl/angular : Not Found
   @nrwl/cypress : Not Found
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.8.3
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 14.8.3
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 14.8.3
   @nrwl/js : 14.8.3
   @nrwl/linter : 14.8.3
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : 14.8.3
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : 14.8.3
   @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 : 14.8.3
   @nrwl/workspace : 14.8.3
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:
     @nx-extend/playwright: 1.1.0
     @nxext/vitest: 14.0.2
     nx-plugin-vite: 2.2.1