vike: plugin-legacy breaks vike build (missing _temp_manifest.json)

Description

Hi 👋

repro here 👉 https://github.com/kazuma1989/repro-vike-vite-plugin-legacy

I met an issue saying:

repro-vike-vite-plugin-legacy % npm run build

> build
> vite build

vite v4.4.9 building for production...
✓ 173 modules transformed.
computing gzip size (0)...[vike:buildConfig] [vike@0.4.142][Bug] You stumbled upon a bug in Vike's source code. Go to https://github.com/vikejs/vike/issues/new and copy-paste this error; a maintainer will fix the bug (usually under 24 hours).
✓ built in 3.81s
error during build:
Error: [vike@0.4.142][Bug] You stumbled upon a bug in Vike's source code. Go to https://github.com/vikejs/vike/issues/new and copy-paste this error; a maintainer will fix the bug (usually under 24 hours).
    at Object.writeBundle (file:///Users/kazuma/kazuma1989/repro-vike-vite-plugin-legacy/node_modules/vike/dist/esm/node/plugin/plugins/buildConfig.js:54:17)
    at file:///Users/kazuma/kazuma1989/repro-vike-vite-plugin-legacy/node_modules/rollup/dist/es/shared/node-entry.js:25544:40
    at async Promise.all (index 2)
    at PluginDriver.hookParallel (file:///Users/kazuma/kazuma1989/repro-vike-vite-plugin-legacy/node_modules/rollup/dist/es/shared/node-entry.js:25472:9)
    at file:///Users/kazuma/kazuma1989/repro-vike-vite-plugin-legacy/node_modules/rollup/dist/es/shared/node-entry.js:26792:13
    at catchUnfinishedHookActions (file:///Users/kazuma/kazuma1989/repro-vike-vite-plugin-legacy/node_modules/rollup/dist/es/shared/node-entry.js:25910:16)
    at build (file:///Users/kazuma/kazuma1989/repro-vike-vite-plugin-legacy/node_modules/vite/dist/node/chunks/dep-df561101.js:48011:22)
    at CAC.<anonymous> (file:///Users/kazuma/kazuma1989/repro-vike-vite-plugin-legacy/node_modules/vite/dist/node/cli.js:822:9)

The file file:///Users/kazuma/kazuma1989/repro-vike-vite-plugin-legacy/node_modules/vike/dist/esm/node/plugin/plugins/buildConfig.js:54:17 in the stack trace corresponds to https://github.com/vikejs/vike/blob/v0.4.142/vite-plugin-ssr/node/plugin/plugins/buildConfig.ts#L72.

After investigating, I found that this occurs because the writeBundle hook will be called twice when using the plugin-legacy. When the hook is called the first time, Vite won’t emit manifestEntry (e.g. _temp_manifest.json) yet. cf. https://github.com/vitejs/vite/blob/v4.4.9/packages/vite/src/node/plugins/manifest.ts#L155

Cloud you please fix this? 🙏

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 27 (15 by maintainers)

Commits related to this issue

Most upvoted comments

If I change the condition like below, everything works

This temporary workaround is released as vike@0.4.142-commit-ebf6e2d. Let me know if you still get issues.

I’ll implement a proper fix later this week.

I’ll have a look at it this week. As always: let me know if it’s urgent.

yes, I think it is urgent。 Because,without legacy plugin, we can’t use vike in prod environment

Hm, seems like there is some kind regression on Vite’s part. I’ll check your reproduction later. Let me know if it’s urgent (I can pre-release your workaround until I implement a proper fix).