Closed silva96 closed 1 month ago
How can I get what I use to have using esbuild
in package.json:
"scripts": { "build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds" }
This would look like this in chrome developer tools:
There I can add breakpoints to debug each individual stimulus controller.
Now that I'm using Bun
package.json:
"scripts": { "build": "bun bun.config.js" }
Default generated bun.config.js
import path from 'path'; import fs from 'fs'; const config = { sourcemap: "external", entrypoints: ["app/javascript/application.js"], outdir: path.join(process.cwd(), "app/assets/builds"), }; const build = async (config) => { const result = await Bun.build(config); if (!result.success) { if (process.argv.includes('--watch')) { console.error("Build failed"); for (const message of result.logs) { console.error(message); } return; } else { throw new AggregateError(result.logs, "Build failed"); } } }; (async () => { await build(config); if (process.argv.includes('--watch')) { fs.watch(path.join(process.cwd(), "app/javascript"), { recursive: true }, (eventType, filename) => { console.log(`File changed: ${filename}. Rebuilding...`); build(config); }); } else { process.exit(0); } })();
Currently only one file in the chrome console, no individual controllers.
You can provide a list of files to entrypoints: https://bun.sh/docs/bundler#entrypoints
entrypoints
How can I get what I use to have using esbuild
in package.json:
This would look like this in chrome developer tools:
There I can add breakpoints to debug each individual stimulus controller.
Now that I'm using Bun
package.json:
Default generated bun.config.js
Currently only one file in the chrome console, no individual controllers.