fix(optimizer): align relative `build.rollupOptions.input` resolution with rollup
Description
computeEntries resolves relative build.rollupOptions.input from the root.
https://github.com/vitejs/vite/blob/61b6b96b191c6071b9c574ad4c795f97f2646f18/packages/vite/src/node/optimizer/scan.ts#L244-L265
https://github.com/vitejs/vite/blob/61b6b96b191c6071b9c574ad4c795f97f2646f18/packages/vite/src/node/server/pluginContainer.ts#L341-L344
reproduction: https://stackblitz.com/edit/vitejs-vite-nte18shp?file=package.json,vite.config.js&terminal=dev
On the other hand, rollup resolves relative build.rollupOptions.input from process.cwd().
This PR fixes the computeEntries to align the behavior with rollup. I think we should align with rollup, but that would probably have a bigger impact, so I made that a separate PR.
A workaround is to call path.resolve in the config before passing to build.rollupOptions.input.
reported at https://github.com/vitejs/vite/discussions/15834#discussioncomment-13207937 refs #20079
/ecosystem-ci run
📝 Ran ecosystem CI on 7872cfc: Open
| suite | result | latest scheduled |
|---|---|---|
| laravel | :x: failure | :x: failure |
| analogjs | :x: failure | :x: failure |
| vike | :x: failure | :white_check_mark: success |
| vitest | :x: failure | :x: failure |
:white_check_mark: previewjs, ladle, qwik, astro, quasar, marko, react-router, sveltekit, storybook, nuxt, rakkas, histoire, vite-setup-catalogue, unocss, vite-environment-examples, vite-plugin-react, vite-plugin-vue, vitepress, vite-plugin-svelte, vite-plugin-cloudflare, waku, vuepress, vite-plugin-pwa
📝 Ran ecosystem CI on 7872cfc: Open
| suite | result | latest scheduled |
|---|---|---|
| analogjs | :x: failure | :x: failure |
| laravel | :x: failure | :x: failure |
| vike | :x: failure | :white_check_mark: success |
| vitest | :x: failure | :x: failure |
:white_check_mark: astro, histoire, marko, quasar, nuxt, rakkas, react-router, previewjs, ladle, qwik, sveltekit, storybook, unocss, vuepress, vite-plugin-svelte, waku, vite-setup-catalogue, vite-plugin-pwa, vite-environment-examples, vite-plugin-vue, vite-plugin-cloudflare, vite-plugin-react, vitepress
Hmm, it seems vike fails on this branch and passes on latest main (https://github.com/vitejs/vite-ecosystem-ci/actions/runs/151765559389). The error is happening in build, which is strange...
It seems pnpm tsx ecosystem-ci.ts vike --repo sapphi-red/vite --branch fix/optimizer-resolve-relative-build-rollupOptions-input passes, but pnpm tsx ecosystem-ci.ts vike --repo sapphi-red/vite --commit 7872cfc6181bd19fe6f42d8990a0ddfa56dbf8f8 fails.
It seems it passes with rollup 4.38.0 and fails with 4.39.0.
OK. pnpm tsx ecosystem-ci.ts vike --repo sapphi-red/vite --branch fix/optimizer-resolve-relative-build-rollupOptions-input sets overrides.rollup: '4.40.1' and pnpm tsx ecosystem-ci.ts vike --repo sapphi-red/vite --commit 7872cfc6181bd19fe6f42d8990a0ddfa56dbf8f8 sets overrides.rollup: '^4.40.0' (because it uses pkg.pr.new), and there was a bug in rollup 4.39.0 - 4.40.0. So the failure is not caused by this PR.
/ecosystem-ci run
📝 Ran ecosystem CI on 3105302: Open
| suite | result | latest scheduled |
|---|---|---|
| analogjs | :x: failure | :x: failure |
| histoire | :x: failure | :x: failure |
| astro | :x: failure | :x: failure |
| previewjs | :x: failure | :x: failure |
| vike | :x: failure | :x: failure |
| sveltekit | :x: failure | :x: failure |
| vite-plugin-cloudflare | :x: failure | :x: failure |
:white_check_mark: laravel, react-router, quasar, qwik, ladle, nuxt, unocss, storybook, vite-plugin-pwa, vite-plugin-react, rakkas, vite-environment-examples, vite-setup-catalogue, vitepress, marko, vitest, vite-plugin-svelte, vuepress, waku, vite-plugin-vue
vike is failing with a different error but the reason is same with https://github.com/vitejs/vite/pull/20080#issuecomment-2899825610 and not caused by this PR.