codymikol / karma-webpack

Karma webpack Middleware
MIT License
830 stars 222 forks source link

webpack 5 error: "Cannot find module 'webpack/lib/dependencies/SingleEntryDependency' " #431

Closed edmorley closed 3 years ago

edmorley commented 4 years ago

Expected Behavior

karma-webpack does not give errors about missing modules under webpack 5 beta.

Actual Behavior

 $ karma start --single-run
  14 12 2019 20:11:51.063:ERROR [plugin]: Error during loading "/tmp/create-project__preact___airbnb___karma_5gjvdzjeg85/node_modules/karma-webpack/dist/index.js" plugin:
    Cannot find module 'webpack/lib/dependencies/SingleEntryDependency'
  14 12 2019 20:11:51.327:ERROR [preprocess]: Can not load "webpack", it is not registered!
    Perhaps you are missing some plugin?

  START:
  14 12 2019 20:11:51.386:INFO [karma-server]: Karma v4.4.1 server started at http://0.0.0.0:9876/
  14 12 2019 20:11:51.387:INFO [launcher]: Launching browsers ChromeCI with concurrency unlimited
  14 12 2019 20:11:51.388:ERROR [karma-server]: Error: Found 2 load errors
      at Server.webServer.listen (/tmp/create-project__preact___airbnb___karma_5gjvdzjeg85/node_modules/karma/lib/server.js:192:27)
      at Object.onceWrapper (events.js:286:20)
      at Server.emit (events.js:203:15)
      at emitListeningNT (net.js:1314:10)
      at process._tickCallback (internal/process/next_tick.js:63:19)
  error Command failed with exit code 1.

Code

I can export a Neutrino config if really necessary, but this is reproduceable with any config.

How Do We Reproduce?

https://travis-ci.com/neutrinojs/neutrino/jobs/267299372

edmorley commented 4 years ago

https://github.com/webpack/changelog-v5#minor-changes says:

SingleEntryPlugin and SingleEntryDependency removed MIGRATION: use EntryPlugin and EntryDependency

samal-rasmussen commented 3 years ago

No commit or PR merge since june 10 2019. There was a PR for fixing this issue, but it was closed by the submitter. I don't know why, but I guess because of inactivity. This project looks dead. It is unfortunate now that Webpack 5 is out, and it is blocked on this issue.

EDIT: Ok I have pulled in rahcusa's fix into a fork here: https://github.com/samal-rasmussen/karma-webpack

I added some other minor changes too, which you can see in the commit log.

Npm is able to pull in packages directly from github, so you can use it directly in you package.json just like this: "karma-webpack": "samal-rasmussen/karma-webpack#49410439564034bf2c89c5c13ba71a763f592380"

That points to a specific commit in the github fork, so you know what you are getting.

himanshuapril1 commented 3 years ago

Team is already working on fixing. You can use https://github.com/ryanclark/karma-webpack/tree/next for latest Webpack5 configuration updates

himanshuapril1 commented 3 years ago

No commit or PR merge since june 10 2019. There was a PR for fixing this issue, but it was closed by the submitter. I don't know why, but I guess because of inactivity. This project looks dead. It is unfortunate now that Webpack 5 is out, and it is blocked on this issue.

EDIT: Ok I have pulled in rahcusa's fix into a fork here: https://github.com/samal-rasmussen/karma-webpack

I added some other minor changes too, which you can see in the commit log.

Npm is able to pull in packages directly from github, so you can use it directly in you package.json just like this: "karma-webpack": "samal-rasmussen/karma-webpack#49410439564034bf2c89c5c13ba71a763f592380"

That points to a specific commit in the github fork, so you know what you are getting.

@samal-rasmussen Right now it's throwing error with that src directory you have made in above commit id. Can you please fix it?

samal-rasmussen commented 3 years ago

That is great news.

Right now it's throwing error with that src directory you have made in above commit id. Can you please fix it?

I just tried clearing node_modules and fetching all packages again and rebuilding and running my tests in my project again. No issues. Could you share a bit more details about the issue you are seeing?

himanshuapril1 commented 3 years ago

Please refer screenshot for error, which works fine if I change src to dist here https://github.com/samal-rasmussen/karma-webpack/blob/master/package.json#L10. I guess this is mainly because that src directory doesn't gets published while installing from package.

Capture

Directory listing of node_modules after doing clean sweep.

ls node_modules/karma-webpack/
CHANGELOG.md  dist  LICENSE  node_modules  package.json  README.md
codymikol commented 3 years ago

To limit confusion, I am combining all threads for webpack 5 / karma6 support over here ==> https://github.com/ryanclark/karma-webpack/issues/475

codymikol commented 3 years ago

v5 is now available