oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.06k stars 2.76k forks source link

SvelteKit build fails with bun, works with npm #13776

Open danielniccoli opened 1 month ago

danielniccoli commented 1 month ago

What version of Bun is running?

1.1.26+0a37423ba

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

bun run build

What is the expected behavior?

This is what I get with npm run build. I expect a successful build step with bun, too.

> myproject@0.0.1 build
> vite build

vite v5.4.3 building SSR bundle for production...
✓ 99 modules transformed.
vite v5.4.3 building for production...
✓ 115 modules transformed.
.svelte-kit/output/client/_app/version.json                                    0.03 kB │ gzip:  0.05 kB
.svelte-kit/output/client/.vite/manifest.json                                  2.54 kB │ gzip:  0.49 kB
.svelte-kit/output/client/_app/immutable/entry/start.DoGVdIum.js               0.07 kB │ gzip:  0.08 kB
.svelte-kit/output/client/_app/immutable/nodes/2.Yqw3PtIM.js                   0.15 kB │ gzip:  0.15 kB
.svelte-kit/output/client/_app/immutable/nodes/0.Coa5a1jm.js                   0.45 kB │ gzip:  0.34 kB
.svelte-kit/output/client/_app/immutable/chunks/disclose-version.CbVFpK9_.js   0.95 kB │ gzip:  0.55 kB
.svelte-kit/output/client/_app/immutable/nodes/1.C9r6ZGyx.js                   1.45 kB │ gzip:  0.75 kB
.svelte-kit/output/client/_app/immutable/chunks/render.LAT_rLme.js             2.29 kB │ gzip:  1.26 kB
.svelte-kit/output/client/_app/immutable/entry/app.lGfKuVtx.js                 8.10 kB │ gzip:  3.75 kB
.svelte-kit/output/client/_app/immutable/chunks/runtime.C87AGrYa.js           10.56 kB │ gzip:  4.35 kB
.svelte-kit/output/client/_app/immutable/chunks/entry.qS9co_cT.js             26.25 kB │ gzip: 10.53 kB
✓ built in 304ms
.svelte-kit/output/server/.vite/manifest.json                  1.78 kB
.svelte-kit/output/server/entries/pages/_layout.js             0.05 kB
.svelte-kit/output/server/entries/pages/_page.svelte.js        0.10 kB
.svelte-kit/output/server/internal.js                          0.31 kB
.svelte-kit/output/server/entries/fallbacks/layout.svelte.js   0.40 kB
.svelte-kit/output/server/entries/fallbacks/error.svelte.js    1.66 kB
.svelte-kit/output/server/chunks/index.js                      3.59 kB
.svelte-kit/output/server/chunks/exports.js                    5.94 kB
.svelte-kit/output/server/chunks/internal.js                  36.44 kB
.svelte-kit/output/server/index.js                            93.33 kB
✓ built in 906ms

Run npm run preview to preview your production build locally.

> Using @sveltejs/adapter-static
  Wrote site to "build"
  ✔ done

What do you see instead?

$ vite build
vite v5.4.3 building for production...
✓ 0 modules transformed.
x Build failed in 8ms
error during build:
Could not resolve entry module "index.html".
    at getRollupError (file:///C:/myproject/node_modules/rollup/dist/es/shared/parseAst.js:392:41)
    at error (file:///C:/myproject/node_modules/rollup/dist/es/shared/parseAst.js:388:42)
    at ModuleLoader.loadEntryModule (file:///C:/myproject/node_modules/rollup/dist/es/shared/node-entry.js:19276:20)
    at async Promise.all (index 0)
error: script "build" exited with code 1

Additional information

package.json

{
  "name": "myproject",
  "version": "0.0.1",
  "scripts": {
    "dev": "vite dev",
    "build": "vite build",
    "preview": "vite preview",
...
danielniccoli commented 1 month ago

I accidentally ran bun run build from a child directory. When running it from the project root directory, it works. I am not sure if this is intentional. But since it is meant to be a drop-in replacement for npm, and the npm command from that same child directory works, I'll leave this issue open for review.

ptrxyz commented 1 month ago

before you run bun run build, delete the build directory. SK outputs the build files in the folder build and when you run bun run build bun wants to run the files in build instead of the script build defined in your package json.

So either delete the folder each time before you run build or rename the script to something else.

danielniccoli commented 1 month ago

before you run bun run build, delete the build directory. SK outputs the build files in the folder build and when you run bun run build bun wants to run the files in build instead of the script build defined in your package json.

So either delete the folder each time before you run build or rename the script to something else.

No, that's not the cause. The issue is reproducible whether or not the build folder exists. It's purely related to the path from where I run bun run build.