windicss / windicss-webpack-plugin

🍃 Windi CSS for webpack ⚡
https://windicss.org/integrations/webpack.html
79 stars 19 forks source link

Lodash is Used but is Not a Dependency #90

Closed philippstucki closed 3 years ago

philippstucki commented 3 years ago

Describe the bug Lodash is used in src/loaders/transform-template.ts but it is not listed as a dependency in package.json. When using this plugin w. Next.js like described in the documentation I get this error:

yarn run v1.22.11
$ next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
error - ./pages/_app.tsx
Error: Cannot find module 'lodash'
Require stack:
- /home(...)/node_modules/windicss-webpack-plugin/dist/loaders/transform-template.js
- /home/(...)/node_modules/next/dist/compiled/webpack/bundle5.js
- /home/(...)/node_modules/next/dist/compiled/webpack/webpack.js
(...)

To Reproduce Steps to reproduce the behavior:

  1. Create a new Next.js app using yarn create next-app
  2. Add windicss-webpack-plugin using yarn add -D windicss-webpack-plugin
  3. Configure windicss as described
  4. Observe error (lodash is not installed)

Expected behavior As windicss-webpack-plugin depends on lodash it should also be installed accordingly.

harlan-zw commented 3 years ago

Hey @philippstucki

Thanks for the issue and good catch!

Not having the lodash dependency is for sure an issue which I'll push up a fix for now.

However, lodash should only be needed if your parsing a template file that html-webpack-plugin is using, which to my understanding does require lodash. Could you tell me what version of html-webpack-plugin you're app is using?

philippstucki commented 3 years ago

Hi @harlan-zw

Thanks for the fix. AFAICT next.js does not use html-webpack-plugin. At least it is not installed as a dependency in my project.

When creating a new app using yarn create next-app html-webpack-plugin is not installed as a dependency.

Let me know if I can assist with more info.