ladle icon indicating copy to clipboard operation
ladle copied to clipboard

Ladle 5.1 + Vite7+Rolldown + React: HMR doesn't work

Open samavos opened this issue 2 months ago • 0 comments

Describe the bug

We use latest Ladle on our project. We've recently upgraded to Vite v7 + Rolldown (in preview at the moment).

Ladle has then stopped working; we need to set noWatch: true to continue using ladle.

The error messages seen are:

> ladle serve --port=61000

Using configured entrypoint ladle
13:39:36 [vite] (client) Re-optimizing dependencies because lockfile has changed

   ╭────────────────────────────────────────────────────╮
   │                                                    │
   │   🥄 Ladle.dev served at http://localhost:61000/   │
   │                                                    │
   ╰────────────────────────────────────────────────────╯

13:39:41 [vite] Pre-transform error: Missing field `moduleType`
  Plugin: builtin:react-refresh-wrapper
  File: [object Object]
13:39:41 [vite] Pre-transform error: Missing field `moduleType`
  Plugin: builtin:react-refresh-wrapper
  File: [object Object] (x2)
13:39:41 [vite] Internal server error: Missing field `moduleType`
  Plugin: builtin:react-refresh-wrapper
  File: [object Object]
      at wrappedPlugin.<computed> (file:///.../node_modules/rolldown/dist/shared/src-DkvlJJsC.mjs:237:36)
      at EnvironmentPluginContainer.transform (file:///.../node_modules/@ladle/react/node_modules/vite/dist/node/chunks/dep-Bu492Fnd.js:42313:19)
      at async loadAndTransform (file:///.../node_modules/@ladle/react/node_modules/vite/dist/node/chunks/dep-Bu492Fnd.js:35738:27)

The browser just sees HTTP 404 errors.

Note that HMR works normally with vite dev in our project: the problems only seem to occur when using Ladle.

Reproduction

A mimimal reproduction can be found here:

https://stackblitz.com/edit/ladle-5dbsbcry?file=.ladle%2Fconfig.mjs

❯ pnpm install && pnpm run dev
Lockfile is up to date, resolution step is skipped
Already up to date
Done in 1.5s

> [email protected] dev /home/projects/ladle-kfgha4hg
> ladle serve --port 4123

(node:73) ExperimentalWarning: WASI is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

   ╭───────────────────────────────────────────────────╮
   │                                                   │
   │   🥄 Ladle.dev served at http://localhost:4123/   │
   │                                                   │
   ╰───────────────────────────────────────────────────╯

(node:73) ExperimentalWarning: WASI is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
14:01:16 [vite] Pre-transform error: Missing field `moduleType`
  Plugin: builtin:react-refresh-wrapper
  File: [object Object]
14:01:16 [vite] Pre-transform error: Missing field `moduleType`
  Plugin: builtin:react-refresh-wrapper
  File: [object Object] (x2)
14:01:17 [vite] Pre-transform error: Missing field `moduleType`
  Plugin: builtin:react-refresh-wrapper
  File: [object Object] (x3)
14:01:17 [vite] Pre-transform error: Missing field `moduleType`
  Plugin: builtin:react-refresh-wrapper
  File: [object Object] (x4)
14:01:17 [vite] Internal server error: Missing field `moduleType`
  Plugin: builtin:react-refresh-wrapper
  File: [object Object]
      at napi_create_error (/tmp/rolldown-1.0.0-beta.41/node_modules/.pnpm/@emnapi+cor
...

Environment

  • OS: Linux
  • Browser: Chrome / any
  • Version: 5.1.0

samavos avatar Oct 10 '25 13:10 samavos