elm-pages icon indicating copy to clipboard operation
elm-pages copied to clipboard

Vite Pre-transform error after upgrade

Open Mousaka opened this issue 2 years ago • 9 comments

Problem

After upgrade elm pages to 10.0.3 and vite to "^5.0.11" I started getting this error in my project on page loads on the dev server. I get the same error both in my personal project and in elm-pages-starter.

[vite] Pre-transform error: Failed to load url /elm-pages.js (resolved id: /elm-pages.js). Does the file exist? (x2)
1 /: 35.617ms

The site still runs and elm-pages.js gets downloaded without errors in the browser.

Search results

Found this Issue on another project which might be related https://github.com/storybookjs/storybook/issues/25256 . Seems like it has to do with some change in version 5 of vite. This was the "fix" they did in that project https://github.com/storybookjs/storybook/pull/25329/files . Not sure how and if this translates to elm-pages or if it's related at all.

Workaround

From/inspired by https://github.com/vitejs/vite/issues/15374#issuecomment-1859842971

// in elm-pages.config.mjs
  vite: defineConfig({
    assetsInclude: ['/elm-pages.js']
  }),

Mousaka avatar Jan 13 '24 14:01 Mousaka

Some more digging. ~Maybe a fix is on its way https://github.com/vitejs/vite/issues/15354#issuecomment-1874899619~ Edit the fix for this seems to have been merged in 5.0.11 already so it probably did not help us https://github.com/vitejs/vite/pull/15361

Mousaka avatar Jan 13 '24 15:01 Mousaka

Oh nice, that's very helpful! Thank you for looking into that and saving me the time @Mousaka! 🙏

dillonkearns avatar Jan 16 '24 20:01 dillonkearns

Updated the issue:

  1. Added a workaround I found.
  2. Added to problem description that I do not only get this in my personal project, I also get it in elm-pages-starter.

Mousaka avatar Jan 19 '24 20:01 Mousaka

Edit the fix for this seems to have been merged in 5.0.11 already so it probably did not help us https://github.com/vitejs/vite/pull/15361

How do you know it endedd up in 5.0.11?

dillonkearns avatar Jan 20 '24 17:01 dillonkearns

I couldn't tell immediately from looking at the issue which release it would be a part of. Worth checking and seeing when the next release comes out if it's fixed.

dillonkearns avatar Jan 20 '24 18:01 dillonkearns

Oh yes, I see it now in https://github.com/vitejs/vite/blob/v5.0.12/packages/vite/CHANGELOG.md#5011-2024-01-05.

Strange that it's still there then. Maybe not related to that fix at all.

dillonkearns avatar Jan 20 '24 18:01 dillonkearns

I'm not sure why this is needed now, but it's easy enough to add that to the built-in Vite defaults so I'll go ahead and do that. Thanks for figuring out the fix!

dillonkearns avatar Jan 21 '24 02:01 dillonkearns

This will go out with the next elm-pages release.

dillonkearns avatar Jan 21 '24 02:01 dillonkearns

Looks like that Vite fix didn't resolve it, but I believe this open Vite issue tracks the problem: https://github.com/vitejs/vite/issues/6582

dillonkearns avatar Apr 21 '24 23:04 dillonkearns