Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Nitro (nitropack) #3793

Closed
birkskyum opened this issue Jul 24, 2023 · 10 comments · Fixed by #4098 or nitrojs/nitro#1606
Closed

Support Nitro (nitropack) #3793

birkskyum opened this issue Jul 24, 2023 · 10 comments · Fixed by #4098 or nitrojs/nitro#1606
Labels
bug Something isn't working node.js Compatibility with Node.js APIs

Comments

@birkskyum
Copy link
Collaborator

birkskyum commented Jul 24, 2023

Nitro - 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 --bun x giget@latest nitro nitro-app
  • cd nitro-app
  • bun i
  • bun --bun run dev

What is the expected behavior?


➜ bun --bun run dev      
$ bun x nitropack dev

  > Local:    http://localhost:3000/ 
  > Network:  http://192.168.0.115:3000/
  > Network:  http://[2a02:a317:e440:2c80:1463:d84f:69c5:ac27]:3000/
  > Network:  http://[2a02:a317:e440:2c80:6c04:d94d:e2fb:8671]:3000/

✔ Nitro built in 169 ms   

What do you see instead?


➜ bun --bun run dev
$ bun x nitropack dev
SyntaxError: Import named 'formatWithOptions' not found in module 'node:util'.
error: "nitropack" exited with code 1 (SIGHUP)
error: script "dev" exited with code 1 (SIGHUP)

Additional information

Requires node util.formatWithOptions() which isn't implemented.

@birkskyum birkskyum added the bug Something isn't working label Jul 24, 2023
@robobun robobun added the node.js Compatibility with Node.js APIs label Jul 24, 2023
@birkskyum
Copy link
Collaborator Author

birkskyum commented Aug 10, 2023

With util.formatWithOptions in place I now get this output:

 ERROR  The "original" argument must be of type Function                                                                                               10:19:18 PM

  at promisify (node:util:356:101)
  at <anonymous> (node_modules/rollup-plugin-visualizer/dist/plugin/compress.js:30:34)
  at global code (node_modules/rollup-plugin-visualizer/dist/plugin/compress.js:66:8)
more debug log
[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)
[JSC] toJS (src/string.zig:501)
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1858)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1976)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1888)
[ModuleLoader] transpileFile: /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/pss.js
[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)
[fs] openat(0, /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/pss.js) = 5
[fs] stat(5) = 7854
[fs] pread(5, 7854) = 7854
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] fromJS (src/string.zig:479)
[JSC] fromJS (src/string.zig:479)
[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)
[JSC] toJS (src/string.zig:501)
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1858)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1976)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1888)
[ModuleLoader] transpileFile: /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/ed25519.js
[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)
[fs] openat(0, /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/ed25519.js) = 5
[fs] stat(5) = 24941
[fs] pread(5, 24941) = 24941
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] fromJS (src/string.zig:479)
[JSC] fromJS (src/string.zig:479)
[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)
[JSC] toJS (src/string.zig:501)
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1858)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1976)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1888)
[ModuleLoader] transpileFile: /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/sha512.js
[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)
[fs] openat(0, /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/sha512.js) = 5
[fs] stat(5) = 17133
[fs] pread(5, 17133) = 17133
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] fromJS (src/string.zig:479)
[JSC] fromJS (src/string.zig:479)
[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)
[JSC] toJS (src/string.zig:501)
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1858)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1976)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1888)
[ModuleLoader] transpileFile: /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/asn1-validator.js
[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)
[fs] openat(0, /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/asn1-validator.js) = 5
[fs] stat(5) = 2295
[fs] pread(5, 2295) = 2295
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] fromJS (src/string.zig:479)
[JSC] fromJS (src/string.zig:479)
[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)
[JSC] toJS (src/string.zig:501)
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1858)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1976)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1888)
[ModuleLoader] transpileFile: /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/kem.js
[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)
[fs] openat(0, /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/kem.js) = 5
[fs] stat(5) = 5217
[fs] pread(5, 5217) = 5217
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] fromJS (src/string.zig:479)
[JSC] fromJS (src/string.zig:479)
[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)
[JSC] toJS (src/string.zig:501)
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1858)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1976)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1888)
[ModuleLoader] transpileFile: /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/log.js
[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)
[fs] openat(0, /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/log.js) = 5
[fs] stat(5) = 9264
[fs] pread(5, 9264) = 9264
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] fromJS (src/string.zig:479)
[JSC] fromJS (src/string.zig:479)
[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)
[JSC] toJS (src/string.zig:501)
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1858)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1976)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1888)
[ModuleLoader] transpileFile: /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/md.all.js
[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)
[fs] openat(0, /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/md.all.js) = 5
[fs] stat(5) = 251
[fs] pread(5, 251) = 251
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] fromJS (src/string.zig:479)
[JSC] fromJS (src/string.zig:479)
[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)
[JSC] toJS (src/string.zig:501)
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1858)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1976)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1888)
[ModuleLoader] transpileFile: /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/pkcs7.js
[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)
[fs] openat(0, /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/pkcs7.js) = 5
[fs] stat(5) = 39869
[fs] pread(5, 39869) = 39869
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] fromJS (src/string.zig:479)
[JSC] fromJS (src/string.zig:479)
[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)
[JSC] toJS (src/string.zig:501)
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1858)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1976)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1888)
[ModuleLoader] transpileFile: /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/ssh.js
[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)
[fs] openat(0, /Users/admin/repos/nitro-test/nitro-app2/node_modules/node-forge/lib/ssh.js) = 5
[fs] stat(5) = 7163
[fs] pread(5, 7163) = 7163
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
Loader [fetch] /Users/admin/repos/nitro-test/nitro-app2/node_modules/ignore/index.js
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1858)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1976)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1888)
[ModuleLoader] transpileFile: /Users/admin/repos/nitro-test/nitro-app2/node_modules/ignore/index.js
[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)
[fs] openat(0, /Users/admin/repos/nitro-test/nitro-app2/node_modules/ignore/index.js) = 5
[fs] stat(5) = 16073
[fs] pread(5, 16073) = 16073
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
Loader [fetch] /Users/admin/repos/nitro-test/nitro-app2/node_modules/slash/index.js
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1858)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1976)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1888)
[ModuleLoader] transpileFile: /Users/admin/repos/nitro-test/nitro-app2/node_modules/slash/index.js
[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)
[fs] openat(0, /Users/admin/repos/nitro-test/nitro-app2/node_modules/slash/index.js) = 5
[fs] stat(5) = 285
[fs] pread(5, 285) = 285
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
Loader [fetch] /Users/admin/repos/nitro-test/nitro-app2/node_modules/webpack-sources/lib/index.js
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1858)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1976)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1888)
[ModuleLoader] transpileFile: /Users/admin/repos/nitro-test/nitro-app2/node_modules/webpack-sources/lib/index.js
[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)
[fs] openat(0, /Users/admin/repos/nitro-test/nitro-app2/node_modules/webpack-sources/lib/index.js) = 5
[fs] stat(5) = 956
[fs] pread(5, 956) = 956
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
Loader [fetch] /Users/admin/repos/nitro-test/nitro-app2/node_modules/webpack-virtual-modules/lib/index.js
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1858)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1976)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1888)
[ModuleLoader] transpileFile: /Users/admin/repos/nitro-test/nitro-app2/node_modules/webpack-virtual-modules/lib/index.js
[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)
[fs] openat(0, /Users/admin/repos/nitro-test/nitro-app2/node_modules/webpack-virtual-modules/lib/index.js) = 5
[fs] stat(5) = 10826
[fs] pread(5, 10826) = 10826
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
Loader [fetch] /Users/admin/repos/nitro-test/nitro-app2/node_modules/local-pkg/dist/shared.mjs
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1858)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1976)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1888)
[ModuleLoader] transpileFile: /Users/admin/repos/nitro-test/nitro-app2/node_modules/local-pkg/dist/shared.mjs
[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)
[fs] openat(0, /Users/admin/repos/nitro-test/nitro-app2/node_modules/local-pkg/dist/shared.mjs) = 5
[fs] stat(5) = 8690
[fs] pread(5, 8690) = 8690
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
Loader [fetch] /Users/admin/repos/nitro-test/nitro-app2/node_modules/flat/index.js
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1858)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1976)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1888)
[ModuleLoader] transpileFile: /Users/admin/repos/nitro-test/nitro-app2/node_modules/flat/index.js
[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)
[fs] openat(0, /Users/admin/repos/nitro-test/nitro-app2/node_modules/flat/index.js) = 5
[fs] stat(5) = 3970
[fs] pread(5, 3970) = 3970
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
Loader [fetch] node:net
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1858)
loader [parsing] /Users/admin/repos/nitro-test/nitro-app2/node_modules/ignore/index.js
loader [parsing] /Users/admin/repos/nitro-test/nitro-app2/node_modules/slash/index.js
loader [parsing] /Users/admin/repos/nitro-test/nitro-app2/node_modules/webpack-sources/lib/index.js
loader [parsing] /Users/admin/repos/nitro-test/nitro-app2/node_modules/webpack-virtual-modules/lib/index.js
[JSC] fromJS (src/string.zig:479)
[JSC] fromJS (src/string.zig:479)
[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)
[JSC] toJS (src/string.zig:501)
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1858)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1976)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1888)
[ModuleLoader] transpileFile: /Users/admin/repos/nitro-test/nitro-app2/node_modules/webpack-virtual-modules/lib/virtual-stats.js
[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)
[fs] openat(0, /Users/admin/repos/nitro-test/nitro-app2/node_modules/webpack-virtual-modules/lib/virtual-stats.js) = 5
[fs] stat(5) = 1407
[fs] pread(5, 1407) = 1407
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
loader [parsing] /Users/admin/repos/nitro-test/nitro-app2/node_modules/local-pkg/dist/shared.mjs
Loader [resolve] node:fs
[JSC] resolve (src/bun.js/bindings/exports.zig:70)
[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:path
[JSC] resolve (src/bun.js/bindings/exports.zig:70)
[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:url
[JSC] resolve (src/bun.js/bindings/exports.zig:70)
[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:process
[JSC] resolve (src/bun.js/bindings/exports.zig:70)
[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 [parsing] /Users/admin/repos/nitro-test/nitro-app2/node_modules/flat/index.js
loader [parsing] node:net
[JSC] clearTimeout (src/bun.js/api/bun.zig:4138)
[JSC] clearTimer (src/bun.js/api/bun.zig:4102)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[CPP] JSValue__isAnyInt
[JSC] fromJS (src/bun.js/bindings/generated_classes.zig:4888)
[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
[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
[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] 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
[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] JSGlobalObject__getCachedObject
[SYS] fstat(2) = 0
[JSC] toJS (src/bun.js/bindings/generated_classes.zig:71)
[JSC] fromJS (src/bun.js/bindings/generated_classes.zig:36)
[CPP] JSGlobalObject__putCachedObject
[CPP] JSValue__jsType
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[CPP] JSValue__jsType
[CPP] JSValue__jsType
[CPP] JSValue__getIfPropertyExistsImpl
[CPP] JSValue__getIfPropertyExistsImpl
[CPP] JSValue__getIfPropertyExistsImpl
[SYS] fstat(2) = 0
[JSC] createObject (src/bun.js/webcore/streams.zig:1948)
[CPP] FileSink__createObject
[JSC] updateRef (src/bun.js/webcore/streams.zig:2264)
[JSC] write (src/bun.js/webcore/streams.zig:2027)
[JSC] fromJS (src/bun.js/webcore/streams.zig:1954)
[CPP] FileSink__fromJS
[CPP] JSValue__asArrayBuffer_
[CPP] JSValue__jsType
[CPP] JSValue__toZigString
[JSC] le (src/bun.js/bindings/bun-simdutf.zig:243)
[STR] UTF16 892 - UTF8 892

 ERROR  The "original" argument must be of type Function                                                                                               10:19:18 PM

  at promisify (node:util:356:101)
  at <anonymous> (node_modules/rollup-plugin-visualizer/dist/plugin/compress.js:30:34)
  at global code (node_modules/rollup-plugin-visualizer/dist/plugin/compress.js:66:8)
  at anonymous (native)
  at require (:1:11)
  at require (native)
  at <anonymous> (node_modules/rollup-plugin-visualizer/dist/plugin/index.js:11:6)
  at global code (node_modules/rollup-plugin-visualizer/dist/plugin/index.js:118:8)
  at parseModule (native)
  at <anonymous> (:11:43) 


[SYS] write(2, 892) = 892
[FileSink] Wrote 892 bytes (fd: 2, head: 0, 0/892)
[JSC] flush (src/bun.js/webcore/streams.zig:2149)
[JSC] fromJS (src/bun.js/webcore/streams.zig:1954)
[CPP] FileSink__fromJS
[CPP] JSValue__isBoolean
[JSC] clearTimeout (src/bun.js/api/bun.zig:4138)
[JSC] clearTimer (src/bun.js/api/bun.zig:4102)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[CPP] JSValue__isAnyInt
[JSC] fromJS (src/bun.js/bindings/generated_classes.zig:4888)
[JSC] write (src/bun.js/webcore/streams.zig:2027)
[JSC] fromJS (src/bun.js/webcore/streams.zig:1954)
[CPP] FileSink__fromJS
[CPP] JSValue__asArrayBuffer_
[CPP] JSValue__jsType
[CPP] JSValue__toZigString
[STR] UTF16 195 - UTF8 195

 ERROR  The "original" argument must be of type Function                                                                                               10:19:18 PM

[SYS] write(2, 195) = 195
[FileSink] Wrote 195 bytes (fd: 2, head: 0, 0/1087)
[JSC] flush (src/bun.js/webcore/streams.zig:2149)
[JSC] fromJS (src/bun.js/webcore/streams.zig:1954)
[CPP] FileSink__fromJS
[CPP] JSValue__isBoolean
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] dispatchOnExit (src/bun.js/javascript.zig:362)
error: script "dev" exited with code 1 (SIGHUP)

@Jarred-Sumner
Copy link
Collaborator

Sounds like an issue with our util.promisify implementation.

bun/src/js/node/util.js

Lines 449 to 497 in 2aecc8d

var promisify = function promisify(original) {
if (typeof original !== "function") throw new TypeError('The "original" argument must be of type Function');
if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
var fn = original[kCustomPromisifiedSymbol];
if (typeof fn !== "function") {
throw new TypeError('The "util.promisify.custom" argument must be of type Function');
}
Object.defineProperty(fn, kCustomPromisifiedSymbol, {
value: fn,
enumerable: false,
writable: false,
configurable: true,
});
return fn;
}
function fn() {
var promiseResolve, promiseReject;
var promise = new Promise(function (resolve, reject) {
promiseResolve = resolve;
promiseReject = reject;
});
var args = [];
for (var i = 0; i < arguments.length; i++) {
args.push(arguments[i]);
}
args.push(function (err, value) {
if (err) {
promiseReject(err);
} else {
promiseResolve(value);
}
});
try {
original.apply(this, args);
} catch (err) {
promiseReject(err);
}
return promise;
}
Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
if (kCustomPromisifiedSymbol)
Object.defineProperty(fn, kCustomPromisifiedSymbol, {
value: fn,
enumerable: false,
writable: false,
configurable: true,
});
return Object.defineProperties(fn, getOwnPropertyDescriptors(original));
};

@birkskyum
Copy link
Collaborator Author

birkskyum commented Aug 10, 2023

Just a thought, but could it be that the promisify is correct, but that rollup is missing some functions that it expect, like watchFile and it thus isn't a Function in it's current implementation?

@Jarred-Sumner
Copy link
Collaborator

oh yeah that's probably it

we still need to do fs.watchFile

@paperclover
Copy link
Member

will be fixed by #4098 (building doesn't work yet)

@birkskyum
Copy link
Collaborator Author

birkskyum commented Aug 18, 2023

Amazing, the nitropack dev works, and so does the cli create script that was breaking.

The nitropack build (bun --bun run build) gives the following RollupError:

bun --bun run build
$ nitropack build
[nitro 9:59:47 AM] ✔ Generated public .output/public
[nitro 9:59:47 AM] ℹ Building Nitro Server (preset: node-server)

[nitro 9:59:47 AM]  ERROR  RollupError: Unexpected token (Note that you need plugins to import files that are not JavaScript)


4: }
5: 
6: function(key) {
           ^
7:   if (!key)
8:     return "";


[9:59:47 AM]  ERROR  { columns: 47, date: true, colors: false, compact: true } { [RollupError: Unexpected token (Note that you need plugins to import files that are not JavaScript)]
  cause: { [SyntaxError: Unexpected token (6:8)] pos: 31, loc: { line: 6, column: 8 }, raisedAt: 32 },
  code: 'PARSE_ERROR',
  id: '\u0000virtual:#internal/nitro/virtual/server-assets',
  pos: 31,
  loc: 
   { column: 8,
     file: '\u0000virtual:#internal/nitro/virtual/server-assets',
     line: 6 },
  frame: '4: }\n5: \n6: function(key) {\n           ^\n7:   if (!key)\n8:     return "";',
  watchFiles: 
   [ '/Users/admin/repos/nitro-test/nitro-app6/node_modules/nitropack/dist/runtime/entries/node-server.mjs',
     '\u0000virtual:#internal/nitro/virtual/polyfill',
     '/Users/admin/repos/nitro-test/nitro-app6/node_modules/nitropack/dist/runtime/app.mjs',
     '/Users/admin/repos/nitro-test/nitro-app6/node_modules/nitropack/dist/runtime/utils.mjs',
     '\u0000virtual:#internal/nitro/virtual/server-handlers',
     '\u0000virtual:#internal/nitro/virtual/plugins',
     '/Users/admin/repos/nitro-test/nitro-app6/node_modules/nitropack/dist/runtime/shutdown.mjs',
     '/Users/admin/repos/nitro-test/nitro-app6/node_modules/source-map-support/register.js',
     '/Users/admin/repos/nitro-test/nitro-app6/node_modules/nitropack/dist/runtime/cache.mjs',
     '/Users/admin/repos/nitro-test/nitro-app6/node_modules/nitropack/dist/runtime/config.mjs',
     '/Users/admin/repos/nitro-test/nitro-app6/node_modules/nitropack/dist/runtime/route-rules.mjs',
     '\u0000virtual:#internal/nitro/virtual/app-config',
     '/Users/admin/repos/nitro-test/nitro-app6/node_modules/nitropack/dist/runtime/static.mjs',
     '/Users/admin/repos/nitro-test/nitro-app6/node_modules/nitropack/dist/runtime/error.mjs',
     '/Users/admin/repos/nitro-test/nitro-app6/routes/index.ts',
     '/Users/admin/repos/nitro-test/nitro-app6/node_modules/nitropack/dist/runtime/index.mjs',
     '\u0000virtual:#internal/nitro/virtual/public-assets',
     '\u0000virtual:#internal/nitro/virtual/public-assets-data',
     '\u0000virtual:#internal/nitro/virtual/public-assets-node',
     '/Users/admin/repos/nitro-test/nitro-app6/node_modules/nitropack/dist/runtime/storage.mjs',
     '\u0000virtual:#internal/nitro/virtual/storage',
     '\u0000virtual:#internal/nitro/virtual/server-assets',
     '/Users/admin/repos/nitro-test/nitro-app6/node_modules/nitropack/dist/runtime/plugin.mjs',
     '/Users/admin/repos/nitro-test/nitro-app6/node_modules/nitropack/dist/runtime/renderer.mjs' ] } '\n'

@birkskyum
Copy link
Collaborator Author

birkskyum commented Aug 18, 2023

Can this be reopened until the nitropack build works, so it can be used standalone?

@birkskyum birkskyum changed the title Support Nitro (web server) Support Nitro (nitropack) Aug 18, 2023
@paperclover paperclover reopened this Aug 18, 2023
@paperclover
Copy link
Member

nitro/nuxt build is now blocked on #1519 i think

@birkskyum
Copy link
Collaborator Author

birkskyum commented Aug 26, 2023

Update for Nitro 2.6.1 (Release post)

bun --bun x giget@latest nitro nitro-app
bun --bun run dev
bun --bun run build
bun --bun run preview / bun .output/server/index.mjs

The terminal output from build output is:

➜ bun --bun run build
$ nitropack build
✔ Generated public .output/public                                                                                              nitro 6:33:12 PM
ℹ Building Nitro Server (preset: node-server)                                                                                  nitro 6:33:12 PM
✔ Nitro server built                                                                                                           nitro 6:33:13 PM
  ├─ .output/server/chunks/index.mjs (430 B) (228 B gzip)
  ├─ .output/server/chunks/index.mjs.map (210 B) (147 B gzip)
  ├─ .output/server/chunks/multipart-parser.mjs (5.04 kB) (2.1 kB gzip)
  ├─ .output/server/chunks/multipart-parser.mjs.map (210 B) (167 B gzip)
  ├─ .output/server/chunks/nitro/node-server.mjs (255 kB) (65.5 kB gzip)
  ├─ .output/server/chunks/nitro/node-server.mjs.map (3.19 kB) (815 B gzip)
  ├─ .output/server/index.mjs (389 B) (208 B gzip)
  └─ .output/server/package.json (110 B) (103 B gzip)
Σ Total size: 265 kB (69.2 kB gzip)
✔ You can preview this build using node .output/server/index.mjs   

@paperclover
Copy link
Member

i swear nitropack depends on fs.cp but okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node.js Compatibility with Node.js APIs
Projects
None yet
4 participants