bun icon indicating copy to clipboard operation
bun copied to clipboard

Support VitePress

Open birkskyum opened this issue 2 years ago • 8 comments

VitePress - Website - GitHub

What version of Bun is running?

0.7.0

What platform is your computer?

Darwin 22.5.0 arm64 arm

What steps can reproduce the bug?

  • bun x vitepress init
  • Step through wizard with defaults
  • bun add -d vitepress
  • bun --bun run docs:dev

What is the expected behavior?


➜ bun --bun run docs:dev        

> docs:dev
> vitepress dev

  vitepress v1.0.0-beta.6

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h to show help

What do you see instead?

➜ bun --bun run docs:dev
$ vitepress dev
failed to load config from /Users/admin/repos/vitepress-test-2/.vitepress/config.ts
failed to start server. error:
Error: config must export or return an object.
    at <anonymous> (/Users/admin/repos/vitepress-test-2/node_modules/vite/dist/node/chunks/dep-a8e37fae.js:66014:15)
error: script "docs:dev" exited with code 1 (SIGHUP)
Last part of debug log
Loader [resolve] node:net
[JSC] resolve (src/bun.js/bindings/exports.zig:69)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
Loader [resolve] node:zlib
[JSC] resolve (src/bun.js/bindings/exports.zig:69)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
Loader [resolve] node:http
[JSC] resolve (src/bun.js/bindings/exports.zig:69)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
Loader [resolve] node:constants
[JSC] resolve (src/bun.js/bindings/exports.zig:69)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
Loader [link] /Users/admin/repos/vitepress-test-2/node_modules/vitepress/dist/node/index.js
Loader [link] /Users/admin/repos/vitepress-test-2/.vitepress/config.ts
Loader [evaluate] /Users/admin/repos/vitepress-test-2/node_modules/vitepress/dist/node/index.js
Loader [evaluate] /Users/admin/repos/vitepress-test-2/.vitepress/config.ts
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[CPP] JSValue__isBoolean
[CPP] JSValue__jsType
[CPP] JSGlobalObject__vm
[CPP] JSValue__isCallable
[CPP] JSValue__toZigString
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
failed to load config from /Users/admin/repos/vitepress-test-2/.vitepress/config.ts
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] deref (src/string.zig:95)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[CPP] JSValue__isBoolean
[CPP] JSValue__jsType
[CPP] JSGlobalObject__vm
[CPP] JSValue__isCallable
[CPP] JSValue__toZigString
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
failed to start server. error:
Error: config must export or return an object.
    at <anonymous> (/Users/admin/repos/vitepress-test-2/node_modules/vite/dist/node/chunks/dep-a8e37fae.js:66014:15)
    at asyncFunctionResume (native)
    at promiseReactionJobWithoutPromise (native)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] dispatchOnExit (src/bun.js/javascript.zig:353)
error: script "docs:dev" exited with code 1 (SIGHUP)

Additional information

The config must export or return an object regarding .vitepress/config.ts appear related to:

  • https://github.com/oven-sh/bun/issues/3724
  • https://github.com/oven-sh/bun/pull/3732

birkskyum avatar Jul 24 '23 15:07 birkskyum

Bun 7.1 update - VitePress now returns:

➜ bun --bun run docs:dev
$ vitepress dev
failed to start server. error:
TypeError: fetch() URL is invalid

Bun support to the relevant shiki library has been added here, but it's not release and in VitePress yet:

  • https://github.com/shikijs/shiki/commit/08cade53e0bb5b238a3fa2702039e0a6e34e4889

birkskyum avatar Jul 25 '23 08:07 birkskyum

Basic stuff seems to work fine now. Some of the things that don't work:

  • terminal shortcuts
  • build needs specifying NODE_ENV=production (we have an override in the cli but that doesn't work)
  • functions in themeConfig (bun doesn't properly serialize functions)

brc-dd avatar Aug 20 '23 18:08 brc-dd

I get this, which can be fixed by adding "type":"module" in package.json, and then the dev server runs just fine:

➜ bun --bun run docs:dev
$ vitepress dev
✘ [ERROR] "vitepress" resolved to an ESM file. ESM file cannot be loaded by `require`. See http://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only for more details. [plugin externalize-deps]

    node_modules/vite/dist/node/chunks/dep-df561101.js:66191:25:
      66191 │                         }
            ╵                          ^

    at <anonymous> (/Users/admin/repos/vitepress-test/node_modules/vite/dist/node/chunks/dep-df561101.js:66191:31)
    at <anonymous> (/Users/admin/repos/vitepress-test/node_modules/vite/dist/node/chunks/dep-df561101.js:66160:28)

And for build I get this, which is more problematic:

~/repos/vitepress-test via ⬢ v18.18.0 via 🍞 v1.0.3 took 11.5s 
➜ bun --bun run docs:build
$ vitepress build

  vitepress v1.0.0-rc.15

✓ building client + server bundles...
⠋ rendering pages...

error: Cannot find module "/api-examples.md?t=1695247441877" from "/Users/admin/repos/vitepress-test/.vitepress/.temp/app.js"



error: Cannot find module "/index.md?t=1695247441877" from "/Users/admin/repos/vitepress-test/.vitepress/.temp/app.js"



error: Cannot find module "/markdown-examples.md?t=1695247441877" from "/Users/admin/repos/vitepress-test/.vitepress/.temp/app.js"

birkskyum avatar Sep 20 '23 22:09 birkskyum

Try vitepress build using official docker image 1.0.3, it hangs.

mattjin avatar Sep 26 '23 03:09 mattjin

And for build I get this, which is more problematic:

Most users should be fine with having to manually specify NODE_ENV. Something like this should work fine:

{
  "scripts": {
    "docs:build": "NODE_ENV=production vitepress build docs"
  }
}

brc-dd avatar Sep 26 '23 05:09 brc-dd

And for build I get this, which is more problematic:

Most users should be fine with having to manually specify NODE_ENV. Something like this should work fine:

{
  "scripts": {
    "docs:build": "NODE_ENV=production vitepress build docs"
  }
}

This is useful

here is my configuration

  "scripts": {
    "build": "NODE_ENV=production vitepress build docs"
  },

run command

bun run --bun build

ATQQ avatar Oct 01 '23 03:10 ATQQ

And for build I get this, which is more problematic:

Most users should be fine with having to manually specify NODE_ENV. Something like this should work fine:

{
  "scripts": {
    "docs:build": "NODE_ENV=production vitepress build docs"
  }
}

Using docker, try 1.0.4(and alpine), it still does not work.

  • With 1.0.4, it hangs. And no returns, no error messages
  • With alpine image, it gets an error
[10:35:12] #12 [builder 4/4] RUN bun install && bun docs:build
[10:35:12] #12 sha256:ddefce33e8ce402f0f16abb2b8511dc0979fe1dd8e5b03894391b1804fb34166
[10:35:12] #12 0.125 error: An unknown error ocurred (Unexpected)
[10:35:12] #12 ERROR: executor failed running [/bin/sh -c bun install && bun docs:build]: exit code: 1
[10:35:12] ------
[10:35:12]  > [builder 4/4] RUN bun install && bun docs:build:
[10:35:12] #12 0.125 error: An unknown error ocurred (Unexpected)

mattjin avatar Oct 07 '23 02:10 mattjin

these seem to works

  • bun --bun run docs:dev
  • bun --bun run docs:build

I got a segfault when running the preview like below (css missing), and tried clicking around

➜ bun --bun run docs:preview
$ vitepress preview

  vitepress v1.1.4

Built site served at http://localhost:4173/
============================================================
Bun v1.1.8-canary.1 (3c082012) macOS Silicon
Args: "node", "/Users/admin/repos/bun-kitchensink/vitepress-test/node_modules/.bin/vitepress", "preview"
Features: jsc Bun.stdin(2) Bun.stdout http_server spawn transpiler_cache(7) 
Builtins: "bun:jsc" "bun:main" "node:assert" "node:buffer" "node:child_process" "node:constants" "node:crypto" "node:dns" "node:events" "node:fs" "node:fs/promises" "node:http" "node:https" "node:module" "node:net" "node:os" "node:path" "node:perf_hooks" "node:process" "node:querystring" "node:readline" "node:stream" "node:string_decoder" "node:tls" "node:tty" "node:url" "node:util" "node:util/types" "node:zlib" "node:worker_threads" "ws" "node:v8" 
Elapsed: 6753ms | User: 1294ms | Sys: 75ms
RSS: 0.15GB | Peak: 0.15GB | Commit: 0.85GB | Faults: 71

panic(main thread): Segmentation fault at address 0x43780B2C003FFB10
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

To send a redacted crash report to Bun's team,
please file a GitHub issue using the link below:

 https://bun.report/1.1.8/Mn13c08201A6gghoB__2w1sf+hx0f++8zfmmnzfuomzNmk52J+n12J+x++fA24ylgvjCgx9/H

birkskyum avatar May 08 '24 23:05 birkskyum

It seems like preview also works in the canary release

➜ bun --bun run docs:preview
$ vitepress preview docs

  vitepress v1.2.2

Built site served at http://localhost:4173/

Bun Revision: 1.1.10-canary.1+4b8f89cb7

@mattjin , do you still have issues with the latest canary? The 1.1.11 release hopefully comes soon, so this can be closed.

@brc-dd , how is the themeConfig support at this stage? is the production flag still an issue?

birkskyum avatar May 30 '24 13:05 birkskyum

Seems to work fine with the latest version 👍

brc-dd avatar May 30 '24 13:05 brc-dd

Does the running process of bun show up as a node in ubuntu 24.04? I did not install nodejs separately.

bun run --bun docs:build and bunx --bun vitepress build docs and bun run --smol --bun vitepress build docs and bun run --watch --bun docs:dev --host and bun --bun run docs:build , they all have the same output. all output that node is taking up most of the content instead of bun.

7@SI$40 M952Z(%_ U9D2DG B(827N28MOLJ~D6_N4M7M

{
  "type": "module",
  "license": "BSD-3-Clause",
  "dependencies": {
    "vitepress": "1.2.2",
	"vite-plugin-vitepress-auto-nav": "2.3.2",
	"markdown-it-footnote": "4.0.0",
	"markdown-it-mathjax3-tao": "4.3.2",
	"markdown-it-task-checkbox": "1.0.6"
  },
   "trustedDependencies": [
    "markdown-it-mathjax3-tao",
    "esbuild",
    "vue-demi"
  ],
  "scripts": {
    "docs:dev": "vitepress dev docs",
    "docs:build": "vitepress build docs",
    "docs:preview": "vitepress preview docs"
  }
}
$ bun --revision
1.1.10-canary.1+c3142e1ae
ykla@ykla-ubuntu:~$ cat /etc/os-release 
PRETTY_NAME="Ubuntu 24.04 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo
ykla@ykla-ubuntu:~$ uname -r
6.8.0-31-generic

But in terms of time, flag --bun doesn't work. It even build faster without it.

ykla@ykla-ubuntu:~/taophilosophy.github.io$ bun --bun run  docs:build
$ vitepress build docs

  vitepress v1.2.2

⠋ building client + server bundles...🎈 SUMMARY 解析中...
🎈 SUMMARY 解析完成...
⠋ building client + server bundles...🎈 SUMMARY 解析中...
🎈 SUMMARY 解析完成...
✓ building client + server bundles...
✓ rendering pages...
✓ generating sitemap...
build complete in 411.52s.
ykla@ykla-ubuntu:~/taophilosophy.github.io$ rm -rf docs/.vitepress/dist/
ykla@ykla-ubuntu:~/taophilosophy.github.io$ bun run  docs:build
$ vitepress build docs

  vitepress v1.2.2

⠋ building client + server bundles...🎈 SUMMARY 解析中...
🎈 SUMMARY 解析完成...
⠼ building client + server bundles...🎈 SUMMARY 解析中...
⠴ building client + server bundles...🎈 SUMMARY 解析完成...
✓ building client + server bundles...
✓ rendering pages...
✓ generating sitemap...
build complete in 381.52s.

ykla avatar May 31 '24 06:05 ykla

There should be two, not three, dashes:. '--bun'

birkskyum avatar May 31 '24 08:05 birkskyum

There should be two, not three, dashes:. '--bun'

Sorry for my hand typing mistake, the actual parameter I entered was indeed --. As you can see in the picture and command.

ykla avatar May 31 '24 08:05 ykla

Great work!

My documentation is now being builded with --bun without problems and even faster!

image image

kravetsone avatar Jun 01 '24 16:06 kravetsone