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

Bun overrides "ws" package even when --target=node #3844

Closed
jackson-bean opened this issue Jul 27, 2023 · 5 comments · Fixed by #4163
Closed

Bun overrides "ws" package even when --target=node #3844

jackson-bean opened this issue Jul 27, 2023 · 5 comments · Fixed by #4163
Labels
bug Something isn't working bundler Something to do with the bundler good first issue Something that would be good for new contributors

Comments

@jackson-bean
Copy link

What version of Bun is running?

0.7.1

What platform is your computer?

Microsoft Windows NT 10.0.22621.0 x64 | Using WSL

What steps can reproduce the bug?

  • bun init
// index.ts
import { WebSocket } from "ws";

console.log(WebSocket);
  • bun build --target=node --outdir=dist index.ts
// dist/index.js
import {WebSocket} from "ws";
console.log(WebSocket);

What is the expected behavior?

Bun should bundle the original/node "ws" package since --target=node.

What do you see instead?

The bundle contains the import without the "ws" package bundled with it.

Additional information

No response

@jackson-bean jackson-bean added the bug Something isn't working label Jul 27, 2023
@jackson-bean
Copy link
Author

Trying to get around this by using a plugin in the meantime. I don't know if it's just that I don't know much about making plugins, but when I try to build with the plugin, no output files are generated and no errors are thrown. And yes, "outdir" is specified. Don't know if this is an issue with me or bun.

@Jarred-Sumner
Copy link
Collaborator

confirming that it is a bug that it is using bun's module list to mark as external when --target=node instead of using a different list for node

@paperclover
Copy link
Member

resolver.zig line 592 is where we are using .Aliases, which contains ws and all the bun modules. should we just make a separate comptime list for this?

@robobun robobun added the bundler Something to do with the bundler label Jul 30, 2023
@paperclover paperclover added the good first issue Something that would be good for new contributors label Aug 3, 2023
@paperclover
Copy link
Member

this is also a problem for @vercel/fetch or any other module we override at runtime.

@Hanaasagi
Copy link
Collaborator

trying to work on this

Hanaasagi added a commit to Hanaasagi/bun that referenced this issue Aug 15, 2023
Hanaasagi added a commit to Hanaasagi/bun that referenced this issue Aug 15, 2023
Hanaasagi added a commit to Hanaasagi/bun that referenced this issue Aug 15, 2023
Hanaasagi added a commit to Hanaasagi/bun that referenced this issue Aug 18, 2023
Hanaasagi added a commit to Hanaasagi/bun that referenced this issue Aug 20, 2023
Jarred-Sumner pushed a commit that referenced this issue Aug 20, 2023
* Fix(bundler): use different alias mappings based on the target.
Close: #3844

* chore: reduce duplicated code.

* chore: split to two separate ComptimeStringMap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bundler Something to do with the bundler good first issue Something that would be good for new contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants