Repository navigation
bundler: compose source maps through an input file's sourceMappingURL map #45638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
robobun
wants to merge
12
commits into
main
Choose a base branch
from
robobun/51308825/bundler-input-sourcemaps
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,435
−110
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6be92b7
bundler: compose output source maps through input sourceMappingURL maps
robobun 91a5028
sourcemap: keep InputSourceMap parse errors as bytes
robobun 8219b55
trim comments
robobun 3a8efb0
silent on a missing sidecar map like esbuild; --compile accepts null …
robobun 93a9640
lexer: a sourceMappingURL value ends at whitespace, not at the first …
robobun e4e1c37
sourcemap: one URL policy for input maps, verbatim URL sources at run…
robobun feee886
shorten a comment
robobun de78233
ci: retrigger
robobun beb91e3
sourcemap: read only regular files for input maps, watch the sidecar,…
robobun 6610413
shorten a comment
robobun ed10a76
Merge remote-tracking branch 'origin/main' into robobun/51308825/bund…
robobun a70f05f
bundler: watch the sidecar map whether or not it loaded, OOM handler …
robobun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 nit (optional): a
bun build --watchuser whose input's sidecar.mapdoes not exist yet at parse time never gets a rebuild when it is written; the output map keeps pointing at the intermediate file. At src/bundler/bundle_v2.rs:7886 theadd_file_by_path_slowresult is discarded, and that call fails for a missing path (macOSopenat src/watcher/Watcher.rs:853-856, Linuxwatch_pathat src/watcher/Watcher.rs:581), so the later creation of the.mapis not observed. Fix: make a sidecar that is absent at parse time still trigger a rebuild when it appears, e.g. let the directory watch react to the registered sidecar basename, or re-stat each sidecar before reusing a build.Why this was flagged
A tool writes
x.jsand thenx.js.map, or a user turns on the upstream tool's source maps whilebun build --watch --sourcemapis running, so the sidecar does not exist when bun's rebuild parsesx.js. src/bundler/input_source_map.rs:77 records the sidecar path and src/bundler/input_source_map.rs:93-100 returns None on ENOENT, soSuccess.input_source_map_sidecaris set and src/bundler/bundle_v2.rs:7879-7887 callsadd_file_by_path_slowwithlet _ =. On macOSbun_sys::openof the missing path fails and the function returns false at src/watcher/Watcher.rs:853-856; on Linuxself.platform.watch_path(slice)?at src/watcher/Watcher.rs:581 fails with ENOENT and src/watcher/Watcher.rs:871-876 returns false. Only the parent directory watch survives (src/watcher/Watcher.rs:734-748), and the reloader's directory handler skips names whose extension has no loader (.mapfalls toLoader::File, src/jsc/hot_reloader.rs:1136-1145), so the.mapwrite never enqueues a reload. The user keeps an output map whosesourcesname the intermediate file until some other watched file changes.Verification: src/bundler/bundle_v2.rs:7883-7886 then does
let _ = this.bun_watcher_mut().unwrap().add_file_by_path_slow(&sidecar);discarding the result. That call fails for a missing path: on macOS/FreeBSD src/watcher/Watcher.rs:853-856bun_sys::open(z, WATCH_OPEN_FLAGS, 0)→Err(_) => return false; on Linux src/watcher/Watcher.rs:581self.platform.watch_path(slice)?→ Err, so no watchlist entry is appended.