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 Jiti #4071

Closed
birkskyum opened this issue Aug 8, 2023 · 2 comments
Closed

Support Jiti #4071

birkskyum opened this issue Aug 8, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@birkskyum
Copy link
Collaborator

birkskyum commented Aug 8, 2023

jiti - GitHub

What version of Bun is running?

0.7.3

What platform is your computer?

Darwin 22.5.0 arm64 arm

What steps can reproduce the bug?

  • Create a typescript file (can even be left empty): index.ts
  • Run the file with jiti: bun --bun x jiti index.ts

What is the expected behavior?

The file will be ran. If empty, no output expected.

What do you see instead?

bun --bun x jiti indextest.ts
4261 |               return debug("[native]", filename), _interopDefault(nativeRequire(id));
4262 |             } catch (error) {
4263 |               debug("Native require error:", error), debug("[fallback]", filename), source = transform({ filename, source, ts: isTypescript });
4264 |             }
4265 | 
4266 |           const mod = new external_module_.Module(filename);
             ^
TypeError: undefined is not a constructor (evaluating 'new external_module_.Module(filename)')
      at evalModule (/Users/admin/repos/histoire-vue3-starter/node_modules/jiti/dist/jiti.js:1:0)
      at jiti (/Users/admin/repos/histoire-vue3-starter/node_modules/jiti/dist/jiti.js:1:0)
      at /Users/admin/repos/histoire-vue3-starter/node_modules/jiti/bin/jiti.js:16:0
      at globalThis (/Users/admin/repos/histoire-vue3-starter/node_modules/jiti/bin/jiti.js:16:13)
error: "jiti" exited with code 1 (SIGHUP)
End of debug log
[SYS] fstat(5) = 0
[SYS] read(5, 55) = 39 (0.005ms)
[SYS] read(5, 16) = 0 (0.001ms)
[SYS] close(5)
[CPP] ZigString__toExternalValue
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[CPP] JSGlobalObject__vm
[CPP] VM__collectAsync
[CPP] VM__blockBytesAllocated
[CPP] JSGlobalObject__vm
[CPP] JSInternalPromise__status
[CPP] JSGlobalObject__vm
[CPP] JSInternalPromise__status
[CPP] JSGlobalObject__vm
[CPP] JSInternalPromise__result
[CPP] JSGlobalObject__vm
[CPP] JSValue__isException
[CPP] JSValue__isAggregateError
[CPP] JSValue__jsType
[CPP] JSValue__toZigException
[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] ref (src/string.zig:107)
[fs] openat(0, /Users/admin/repos/jiti-test/node_modules/jiti/dist/jiti.js) = 5
[fs] stat(5) = 258095
[fs] pread(5, 258095) = 258095
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] deref (src/string.zig:95)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] deref (src/string.zig:95)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
4261 |               return debug("[native]", filename), _interopDefault(nativeRequire(id));
[JSC] deref (src/string.zig:95)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
4262 |             } catch (error) {
[JSC] deref (src/string.zig:95)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
4263 |               debug("Native require error:", error), debug("[fallback]", filename), source = transform({ filename, source, ts: isTypescript });
[JSC] deref (src/string.zig:95)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
4264 |             }
[JSC] deref (src/string.zig:95)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
4265 | 
[JSC] deref (src/string.zig:95)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
4266 |           const mod = new external_module_.Module(filename);
             ^
TypeError: undefined is not a constructor (evaluating 'new external_module_.Module(filename)')
[JSC] deref (src/string.zig:95)
[CPP] JSValue__jsType
[CPP] JSValue__getIfPropertyExistsImpl
[CPP] JSValue__getIfPropertyExistsImpl
[CPP] JSValue__getIfPropertyExistsImpl
[CPP] JSValue__getIfPropertyExistsImpl
[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)
      at evalModule ([JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
/Users/admin/repos/jiti-test/node_modules/jiti/dist/jiti.js:1:0[JSC] deref (src/string.zig:95)
)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[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)
      at jiti ([JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
/Users/admin/repos/jiti-test/node_modules/jiti/dist/jiti.js:1:0[JSC] deref (src/string.zig:95)
)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
      at [JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
/Users/admin/repos/jiti-test/node_modules/jiti/bin/jiti.js:16:0[JSC] deref (src/string.zig:95)

[JSC] deref (src/string.zig:95)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
      at globalThis ([JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
/Users/admin/repos/jiti-test/node_modules/jiti/bin/jiti.js:16:13[JSC] deref (src/string.zig:95)
)
[JSC] deref (src/string.zig:95)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
      at asyncFunctionResume (:1:20)
[JSC] deref (src/string.zig:95)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
      at promiseReactionJobWithoutPromiseUnwrapAsyncContext (:1:20)
[JSC] deref (src/string.zig:95)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
      at promiseReactionJob (:1:20)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] dispatchOnExit (src/bun.js/javascript.zig:362)
error: "jiti" exited with code 1 (SIGHUP)

Additional information

This is blocking:

Related to:

@paperdave
Copy link
Member

Should be fixed now, but I notice Jiti runs extremely slow because Bun ends up re-transpiling the code when running it While it works for compatibility, really should just be using import("./module.ts") or bun run.

@paperdave
Copy link
Member

i mispoke there is an extra detail i didnt consider but it's a one line change and will be done next few minutes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants