You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today, when you generate a bundle with esbuild (with minification disabled), esbuild helpfully generates comments showing which modules are included in the bundle:
$ echo'export const a = 5'> a.js
$ echo'import { a } from "./a.js"; console.log(a)'> b.js
$ esbuild --bundle b.js
(() => { // a.js var a = 5; // b.js console.log(a);})();
(Note the // a.js and // b.js comments above.)
Request
I have a minor DX request: could esbuild change these comments to make it easier to ⌘F them? E.g., something like this would make it easy to find all module boundaries (and only them) by searching for /***:
However, I’m open to any other combination of symbols that will be uncommon in the bundle.
Why I’m requesting this
As a performance engineer, I often have to work with raw JS bundles. A typical bundle I’m working with will have 100K+ lines and dozens of modules.
When I’m debugging something, and the debugger takes me to line 17658 of the bundle, it’s very useful to figure out which module this is. With webpack, this is quick – I can just search for /*** and press “Enter” a few times. With esbuild, this is very hard – if I searched for //, I’d have hundreds of matches with every comment in the bundle.
I hope a special shape of the comment will make this easier.
The text was updated successfully, but these errors were encountered:
Most comments shouldn't be present though, right? Since esbuild doesn't preserve comments by default. I was just curious what comments you're hitting.
Wait, I must be a dummy :) When I was writing the issue, I remembered esbuild uses // for module comments, and remembered I avoided using ⌘F being afraid of too many false positives. But I’m just now realizing I never actually tried ⌘F-ing for //.
Switching it to /*** would still lower the cognitive load a bit, but it’s pretty subjective and probably not worth the effort given the breakage. I’ll close this, thank you!
I'm doing some (questionable) surgery on bundle outputs as part of my build. And the reminder that comments should be stripped in bundles was helpful to me. Thank you.
I hope that the behavior can be relied upon that all comments in bundles can be treated as headers defining which file the code below it is from.
Background
Today, when you generate a bundle with esbuild (with minification disabled),
esbuild
helpfully generates comments showing which modules are included in the bundle:(Note the
// a.js
and// b.js
comments above.)Request
I have a minor DX request: could esbuild change these comments to make it easier to ⌘F them? E.g., something like this would make it easy to find all module boundaries (and only them) by searching for
/***
:The
/***
characters are inspired by webpack. E.g., here’s how a webpack bundle I’m looking at right now wraps each module:However, I’m open to any other combination of symbols that will be uncommon in the bundle.
Why I’m requesting this
As a performance engineer, I often have to work with raw JS bundles. A typical bundle I’m working with will have 100K+ lines and dozens of modules.
When I’m debugging something, and the debugger takes me to line 17658 of the bundle, it’s very useful to figure out which module this is. With webpack, this is quick – I can just search for
/***
and press “Enter” a few times. With esbuild, this is very hard – if I searched for//
, I’d have hundreds of matches with every comment in the bundle.I hope a special shape of the comment will make this easier.
The text was updated successfully, but these errors were encountered: