nystudio107 / craft-vite

Allows the use of the Vite.js next generation frontend tooling with Craft CMS
MIT License
51 stars 15 forks source link

Error entry does not get injected on twig error #44

Closed angelokeirsebilck closed 2 years ago

angelokeirsebilck commented 2 years ago

Describe the bug

Error entry does not get injected in twig after a twig error occurs which is stopping the dev server and preventing from the page to reload after fixing the twig error.

To reproduce

Steps to reproduce the behaviour:

  1. Spin up dev server
  2. Confirm dev server is running
  3. Produce twig error
  4. Dev server stopped

Expected behaviour

After we produce a twig error, we expect the plugin to inject the errorEntry inside twig so the dev server keeps running and allowing the HMR to take place when we fix the twig error.

Screenshots

Schermafbeelding 2022-09-08 om 07 04 00

I've set the checkDevServer to false and useDevServer to true for testing purpose. Seems like the check on line 166 inside ViteService.php is always false. So the devServerRunning function is always returning false resulting in not injecting the errorEntry.

Happily to provide more info if needed.

Versions

khalwat commented 2 years ago

So this ended up being pretty interesting.

Addressed in: https://github.com/nystudio107/craft-vite/commit/29d4dae6b810828bb62ef4ef701f59d83565512b & https://github.com/nystudio107/craft-vite/commit/2255a0dadcb11f0c34153258bf7d97de74d5edfd

Craft CMS 3:

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-vite": "dev-develop as 1.0.28",

Then do a composer clear-cache && composer update

…..

Craft CMS 4:

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-vite": "dev-develop-v4 as 4.0.3”,

Then do a composer clear-cache && composer update

Verify for me that this works for you, and I will cut a release.