bun
bun copied to clipboard
bun build --compile with puppeteer. but bun run works well
What version of Bun is running?
0.8.1
What platform is your computer?
Darwin 22.5.0 arm64 arm
What steps can reproduce the bug?
a.js
import fs from 'node:fs';
import os from 'node:os';
import puppeteer from "puppeteer";
console.log(111)
bun add puppeteer
package.json
{ "dependencies": { "puppeteer": "^21.1.1" } }
bun build a.js --compile
./a
What is the expected behavior?
111
What do you see instead?
53899 | }
53900 | }
53901 | }
53902 |
53903 |
53904 | class CDPClientAdapter extends BidiMapper.EventEmitter {
^
TypeError: undefined is not an object (evaluating 'BidiMapper.EventEmitter')
at compiled://root/a:53904:31
Additional information
bun run works well
Is there any solution for this problem yet? I'm facing the same issue.
If I use require instead of import, the code works.
Working code,
const puppeteer = require("puppeteer");
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto("https://example.com/");
console.log(await page.title());
await browser.close();
})();
Command line,
bun build scrape.js --outfile scrape --target node --compile
Non working code,
import puppeteer from "puppeteer";
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto("https://example.com/");
console.log(await page.title());
await browser.close();
})();
Error,
./scrape
17661 | adapter.close();
17662 | }
17663 | }
17664 | }
17665 |
17666 | class CDPClientAdapter extends BidiMapper.EventEmitter {
^
TypeError: undefined is not an object (evaluating 'BidiMapper.EventEmitter')
at /$bunfs/root/scrape:17666:32
1.1.3 the same problem
I can confirm that this still is an issue in bun version 1.1.3
Same here, still broken on 1.1.4
Still broken on v1.1.6