You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are evaluating it for use in our project, and have come across an issue that we could use your help on.
It seems that Vite-Express does not serve inline JS modules (i.e. <script type="module"> tags in HTML) in dev mode. I'm wondering if there's a configuration or setup step that we're missing.
I've created a minimal example application here, with a branch that demonstrates the issue.
(Where /home/timswanson/vite-express-example is the path to the repo.)
This is the mechanism that the Vite Dev Server uses to package inline JS modules. However, when ViteExpress handles this request, it interprets the request as a static-asset request, and serves index.html again.
This creates the following error in the browser console:
Failed to load module script: Expected a JavaScript module script
but the server responded with a MIME type of "text/html".
Strict MIME type checking is enforced for module scripts per HTML spec.
Is there something that needs to be done to get the ViteExpress handler to pass these requests to the Vite Dev Server?
Thank you.
The text was updated successfully, but these errors were encountered:
Note that <script type="module"> is necessary to trigger this issue. Non-module code is not transformed by Vite, and is served literally, so it functions as expected.
Hello. We are a team at Google that found Vite-Express from its listing here in Awesome-Vite:
https://github.com/vitejs/awesome-vite?tab=readme-ov-file#nodejs
(This page is linked from Vite's docs on Backend Integrations)
We are evaluating it for use in our project, and have come across an issue that we could use your help on.
It seems that Vite-Express does not serve inline JS modules (i.e.
<script type="module">
tags in HTML) in dev mode. I'm wondering if there's a configuration or setup step that we're missing.I've created a minimal example application here, with a branch that demonstrates the issue.
https://github.com/timswanson-google/vite-express-example/tree/inline
In this example, the index.html file contains two scripts. One is loaded via a
src
attribute, and the other has its content directly inline.https://github.com/timswanson-google/vite-express-example/blob/4b93508b3ac238172147f79f7ab64cfcc4424545/index.html#L11-L14
When running the server in production mode, everything works fine. The JS is compiled and executes on load.
However, when running in dev mode, only the first module gets executed. The inline script never does.
Specifically, when the index.html page is served, the script tag is rewritten to look like this:
(Where
/home/timswanson/vite-express-example
is the path to the repo.)This is the mechanism that the Vite Dev Server uses to package inline JS modules. However, when ViteExpress handles this request, it interprets the request as a static-asset request, and serves
index.html
again.This creates the following error in the browser console:
Is there something that needs to be done to get the ViteExpress handler to pass these requests to the Vite Dev Server?
Thank you.
The text was updated successfully, but these errors were encountered: