bun
bun copied to clipboard
bun build with puppeteer dependency fails
What version of Bun is running?
1.0.3+25e69c71e70ac8a0a88f9cf15b4057bd7b2a633a
What platform is your computer?
Linux 5.4.0-113-generic x86_64 x86_64
What steps can reproduce the bug?
Trying to bun build --target bun
a simple script that uses puppeteer 21.3.6 and then build run
fails with TypeError: The superclass is not a constructor.
.
Directly running bun run index.js
works as expected.
Repro case: https://github.com/EmielM/bun-build-repro
This is probably some issue with puppeteer: if you look at node_modules/puppeteer-core/lib/esm/puppeteer/api/JSHandle.js
, you see it's pretty convoluted/generated javascript.
But flagging here as
- I think puppeteer is not some marginal library :), so will probably impact others
- shouldn't
bun build --target bun --outfile out.js index.js && bun run out.js
always be behaviourally identical tobun run index.js
in all cases?
What is the expected behavior?
A successful run (generated chrome.png)
What do you see instead?
52593 | init_Serializer();
52594 | });
52595 |
52596 | // node_modules/puppeteer-core/lib/esm/puppeteer/bidi/JSHandle.js
52597 |
52598 | class BidiJSHandle extends JSHandle {
^
TypeError: The superclass is not a constructor.
at /home/emiel/bun-repro/out.js:52598:0
Additional information
No response
same problem here
same
I'm encountering this error message as well. For build target node
and bun
exactly same problem here..
Same issue here. Do we have an update on this?
Here's an isolated repro: for this code bun build
emits code of the form:
class MyComponent extends React.Component {
// ...
}
var React, MyComponent_default;
var init_MyComponent = __esm(() => {
React = __toESM(require_react(), 1);
MyComponent_default = MyComponent;
});
-
init_MyComponent
that initializesReact
and thusReact.Component
, is called is called after the class definition. - So runtimes crashes after encountering the
class ... extends
definition, eg in chrome:Uncaught TypeError: Cannot read properties of undefined (reading 'Component')
Same issue here on bun 1.0.18
. Any updates on this? Because of that I cannot dockerize bun. Same with tsx
files using puppeteer.
Same problem here with bun 1.0.26
same with latest version of bun :/
Seems to happen with multiple packages, like @solana/web3,js
(https://github.com/oven-sh/bun/issues/8925) AWS CDK (https://github.com/oven-sh/bun/issues/3088) and probably more
same here
Update: this still happens on the latest bun, basically making it unusable as bundler for web for most react applications, at least where a few old-style components (extends React.Component
) are used.
same, no solution? with supabase auth
Still happening
113044 | await client.send("Runtime.releaseObject", { objectId: remoteObject.objectId }).catch((error2) => {
113045 | debugError(error2);
113046 | });
113047 | }
113048 |
113049 | class CdpJSHandle extends JSHandle {
^
TypeError: The superclass is not a constructor.
for
bun --version
1.1.20