0

I'm working on a production Preact application that also uses Webpack. In that project, trying to run preact build <args> from an npm build script failed.

Following that, I created a minimal Preact application using npx preact-cli create default preact-test, installed Webpack 5, and now preact build throws the following error, which is the same one I was trying to reproduce:

Cannot find module 'webpack/lib/MultiEntryPlugin'
Require stack:
- /Users/<my name>/projects/preact-test/node_modules/babel-esm-plugin/src/index.js
- /Users/<my name>/projects/preact-test/node_modules/preact-cli/lib/lib/webpack/webpack-client-config.js
- /Users/<my name>/projects/preact-test/node_modules/preact-cli/lib/lib/webpack/run-webpack.js
- /Users/<my name>/projects/preact-test/node_modules/preact-cli/lib/commands/build.js
- /Users/<my name>/projects/preact-test/node_modules/preact-cli/lib/commands/index.js
- /Users/<my name>/projects/preact-test/node_modules/preact-cli/lib/index.js

I saw a post that Webpack 5 has deprecated this internal plugin, but that's the most useful info I've found anywhere. I would appreciate if anyone has a solution to resolving this issue.

Lightning
  • 386
  • 3
  • 15
  • Just as a note, there's no reason why you should be doing this. Preact-CLI is a preconfigured build tool that's ready to go. You can edit the configuration, but installing your own version of Webpack is not something that'd ever work. Preact-CLI and your own Webpack install are mutually exclusive. Have to pick only one. – rschristian Jun 19 '21 at 00:16

1 Answers1

2

After giving this a day and researching it with fresh eyes, I found that this is simply not possible yet; the preact-cli team has not migrated to Webpack 5, and there are no immediate plans to do so: https://github.com/preactjs/preact-cli/issues/1579

Lightning
  • 386
  • 3
  • 15