Open late-warrior opened 1 year ago
Same here, but I'm using FileSystemRouter from Bun.
const router = new Bun.FileSystemRouter({
style: 'nextjs',
dir: './server/endpoints'
});
Bun.serve({
port: Settings.server.port,
hostname: Settings.server.hostname,
development: true,
async fetch(req, server) {
const url = new URL(req.url);
const path = url.pathname;
const match = router.match(path);
if(!match) return Utils.jsonResponse(Errors.getJson(404), 404);
const { src } = match;
try{
const module = await import('./endpoints/' + src);
return await module.default(req, match);
}catch{
return Utils.jsonResponse(Errors.getJson(404), 404);
}
}
});
Works great with bun run server/index.ts
, but it doesn't work after I bundle it with: bun build server/index.ts --compile --minify --outfile ./rabbitchat
Project structure:
What version of Bun is running?
1.0.6+969da088f5db3258a803ec186012e30f992829b4
What platform is your computer?
Darwin 23.0.0 arm64 arm
What steps can reproduce the bug?
A dynamic import in code like below (
trial/components
) is not resolved correctly in the output bundle -bun build --splitting --outdir=static ./src/index.js
Complete reproducer in https://github.com/late-warrior/bun-dyn-import-bug.
What is the expected behavior?
static/index.js
) -What do you see instead?
No response
Additional information
Tried setting a few options like
--public-path
and also varying the location of the entry point to see if that has an effect but could not figure out.