bun icon indicating copy to clipboard operation
bun copied to clipboard

express support

Open evanwashere opened this issue 2 years ago • 7 comments

required to make express work:

  • [x] polyfill require('depd')
  • [x] fix require('iconv-lite');
  • [x] fix require('object-inspect')
  • [x] polyfill require('node:net').isIP
  • [x] polyfill require('node:http') apis
  • [x] polyfill setImmediate (used by express)

optional:

  • [ ] polyfill require('node:https') apis
  • [ ] polyfill Error.captureStackTrace (only used by depd)

express bugs:

  • [ ] router misbehaving (calls app.get('/') handler but returns Cannot get / page)

fixes #405

evanwashere avatar Jul 09 '22 13:07 evanwashere

when i tried to run express : i found https://github.com/oven-sh/bun/issues/747 with error Cannot found module "./utils.inspect" and then i tried putting __dirname in front of "./utils.inspect" the issue is solved it means some how bun is failed to import js file of same dir after issue solved another issue occurred Screenshot from 2022-07-18 12-10-28

here is error on line no 43 Screenshot from 2022-07-18 12-52-27

prolaxu avatar Jul 18 '22 07:07 prolaxu

Function setImmediate is part of many packages too. For example: https://www.npmjs.com/package/glob

adamjosefus avatar Jul 23 '22 06:07 adamjosefus

Seems there is a problem with Oak, too. I tried using it because it was born for Deno, that should have similar web request/response API of Bun, but that's not so.

Anyone knows a library working with Bun that makes simple make servers like Express or Oak?

Bellisario avatar Jul 25 '22 11:07 Bellisario

@Bellisario Try look for this https://github.com/apvarun/awesome-bun. Hope it helps

adamjosefus avatar Jul 25 '22 11:07 adamjosefus

Thanks @adamjosefus, this helps!!!

Maybe for now I'll use Bao.js, seems it's very similar to Express and Oak!

Bellisario avatar Jul 25 '22 11:07 Bellisario

when i tried to run express : i found #747 with error Cannot found module "./utils.inspect" and then i tried putting __dirname in front of "./utils.inspect" the issue is solved it

This worked for me too although there are some follow-up issues.

0x4a61636f62 avatar Jul 28 '22 09:07 0x4a61636f62

i just want to comment that as of 0.1.7, express slightly works, but i want to note that this code doesn't work yet.

import express from 'express';

const app = express();
app.get('/', (req, res) => {
  res.send('Hello World!'); // wont cause the response to end, which will hang any client requests. calling .end fixes it.
});
app.listen(3000, () => {
  console.log('http://localhost//3000!');
});

paperclover avatar Aug 07 '22 19:08 paperclover

Any updates for that issue would like to use express with bun

frodoe7 avatar Aug 19 '22 14:08 frodoe7

Any updates for that issue would like to use express with bun

The above example works in v0.1.10, you could give it a try :)

zhuzilin avatar Aug 20 '22 00:08 zhuzilin

@evanwashere I found an https polyfill, it uses the http module, which is already polyfilled: https://github.com/substack/https-browserify/blob/master/index.js

I can't help more because I'm not a Zig programmer, but I'm ready for any other JS/TS help!

Bellisario avatar Aug 20 '22 09:08 Bellisario

This is fixed

Jarred-Sumner avatar Sep 04 '22 02:09 Jarred-Sumner