vitejs / vite

Next generation frontend tooling. It's fast!
http://vitejs.dev
MIT License
67.44k stars 6.07k forks source link

transformIndexHtml errors with "No matching HTML proxy module found" when referencing entry point as import #18228

Open ricardo-devis-agullo opened 2 hours ago

ricardo-devis-agullo commented 2 hours ago

Describe the bug

Scaffold any SSR example from create-vite-extra and to the following changes:

Wrap the code of the client entry point in

// client-entry.js
export default function render() {
  // previous code...
}

Change the script src to manually import the function

<!-- <script type="module" src="src/client-entry.js"></script> -->
<script type="module">
import render from "./src/client-entry.js"

render();
</script>

This will fail with: "No matching HTML proxy module found from /?html-proxy&index=0.js"

There is a similar issue on https://github.com/vitejs/vite/issues/5061, but it's considered closed, so I'm not sure if this particular case is different, not supported or a bug, since the same changes work on non ssr normal examples.

Reproduction

https://stackblitz.com/edit/stackblitz-starters-7m9qws?file=index.html

Steps to reproduce

Run npm install followed by npm run dev

System Info

System:
    OS: macOS 14.6.1
    CPU: (12) arm64 Apple M2 Max
    Memory: 691.38 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.8.0 - ~/.volta/tools/image/node/22.8.0/bin/node
    npm: 10.8.2 - ~/.volta/tools/image/node/22.8.0/bin/npm
    pnpm: 8.15.5 - ~/Library/pnpm/pnpm
    bun: 1.1.3 - ~/.bun/bin/bun
  Browsers:
    Chrome: 129.0.6668.60
    Edge: 129.0.2792.65
    Safari: 17.6

Used Package Manager

npm

Logs

No response

Validations

stackblitz[bot] commented 2 hours ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.