create a JS file that require()'s moment.js and then uses it
bundle that js file using Bun with target=browser (bun run build in my repro repo)
Use something like nws to serve the root of the repo as a website, and open it in your browser. Open the devtools console to see the error that is thrown.
Here's the source of the js file in the project:
const moment = require('moment');
function foo() {
console.log(moment().add(5, 'minutes'));
}
foo();
What version of Bun is running?
1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983
What platform is your computer?
Darwin 22.6.0 arm64 arm
What steps can reproduce the bug?
I created a repro repo here: https://github.com/atuttle/bun-bundler-repro
the short version is:
bun install moment
bun run build
in my repro repo)nws
to serve the root of the repo as a website, and open it in your browser. Open the devtools console to see the error that is thrown.Here's the source of the js file in the project:
and package.json:
What is the expected behavior?
a
moment
object should be logged containing a timestamp 5 minutes in the future.What do you see instead?
An error is thrown, because the bundle is not valid / well-organized.
Additional information
No response