Skip to content

[ENHANCEMENT] Support Bun#10701

Merged
NullVoxPopuli merged 1 commit intoember-cli:masterfrom
hexadecy:bun-support
Jun 10, 2025
Merged

[ENHANCEMENT] Support Bun#10701
NullVoxPopuli merged 1 commit intoember-cli:masterfrom
hexadecy:bun-support

Conversation

@hexadecy
Copy link
Contributor

@hexadecy hexadecy commented May 21, 2025

When using Bun, the process (outerProcess) is not an instance of EventEmitter but an object with the same methods. So, to make it more compatible with other runtimes, we should duck type check the object.

Should fix #10371 and #10444.

% node bin/ember version
ember-cli: 6.5.0-beta.0-bun-support-e37f6d1f5d
node: 20.18.1
os: darwin arm64

% bun --bun bin/ember version
ember-cli: 6.5.0-beta.0-bun-support-e37f6d1f5d
node: 22.6.0
os: darwin arm64

% deno --unstable-detect-cjs bin/ember version
✅ Granted all sys access.
✅ Granted all env access.
✅ Granted all read access.
ember-cli: 6.5.0-beta.0-bun-support-e37f6d1f5d
node: 22.14.0
os: darwin arm64

Tested on

Bun 1.2.12
Deno 2.3.1
Node 20.18.1
macOS 15.4.1

@hexadecy hexadecy changed the title [ENHANCEMENT] Bun support [ENHANCEMENT] Support Bun May 21, 2025
@NullVoxPopuli
Copy link
Contributor

NullVoxPopuli commented Jun 10, 2025

Do you know if booting an app is any faster with bun?

@hexadecy
Copy link
Contributor Author

hexadecy commented Jun 10, 2025

node bin/ember version 0.28s user 0.09s system 98% cpu 0.376 total
deno --unstable-detect-cjs -A bin/ember version 0.22s user 0.13s system 112% cpu 0.305 total
bun --bun bin/ember version 0.18s user 0.08s system 108% cpu 0.235 total

Bun initializes faster for sure.
As for a real app, I'm still on 5.12.0 LTS. I was waiting for you to merge this PR to conduct further tests and identify any other incompatibilities.

@NullVoxPopuli
Copy link
Contributor

for using the version of ember-cli that this code is on, you'll need a git reference, as it'll be a bit before this makes it out to stable release.

Example:

"ember-cli": "github:ember-cli/ember-cli#main"

thank you for exploring this!

@NullVoxPopuli NullVoxPopuli merged commit baa1e11 into ember-cli:master Jun 10, 2025
69 checks passed
}

function isEventEmitterCompatible(obj) {
return (
Copy link

@MrChocolatine MrChocolatine Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we have kept the test with instanceof, out of safety?

const isValidInstance = obj instanceof EventEmitter;
const isDuckTyped = /* your Boolean & typeof checks */;

return isValidInstance || isDuckTyped;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "if" was not necessary, as it limited the compatibility.
So I don't think we need to check more for an exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

incompatible with bun (or bun is incompatible)

3 participants