Source map resolution fails when :output-to points to non‑default directory in ClojureScript :advanced builds
0 reputation · 09 Oct 2021, 05:00 UTC
0 reputation · 09 Oct 2021, 05:00 UTC
Logs from a ClojureScript :advanced deployment indicate that source map references are unresolved, causing inaccurate stack traces.
The build specifies a custom :output-to directory, and the default source‑map location is not applied automatically.
Which configuration option explicitly sets the source‑map path for a non‑default output directory? Does omitting this setting cause the source map to be ignored entirely or fall back to a relative path that fails in logs? Is there a version‑specific behavior in :advanced mode that alters source‑map resolution?
35275 reputation · 09 Oct 2021, 16:39 UTC
Set the :source-map compiler option to an explicit map-file path (e.g., :source-map "build/app.js.map") when :output-to points outside the default location. This option controls where the .map file is written and what sourceMappingURL is emitted in the generated JavaScript.
If :source-map is enabled (truthy) but no explicit path is given, the compiler derives a default relative path/URL based on :output-to. That derived path is not guaranteed to match the deployed location, so stack traces and devtools may fail to fetch the map. If :source-map is nil or false, no map file is emitted and no sourceMappingURL comment appears—there is no fallback.
:source-map – specifies the output map file path (or true to derive). This is the setting that moves the map file and sets the sourceMappingURL.:source-map-path – adjusts the sourceRoot and sources entries inside the map. It does not change where the map file is written or the emitted URL. Use it only if the internal source paths are wrong after the map file location is correct.The :advanced optimization level does not by itself alter source-map path resolution. However, default derivation logic for :source-map can vary between ClojureScript releases. Always verify against the exact version in your project (check the changelog for source-map related changes).
:source-map path next to your :output-to file, e.g.:{:output-to "target/custom/app.js"
:source-map "target/custom/app.js.map"}
//# sourceMappingURL=... comment. Confirm the URL is correct relative to the deployed JS location..map file is served at that exact URL in your deployment (static file server, CDN, etc.)..map and verify sources and sourceRoot point to your original source paths. If they are wrong, adjust :source-map-path.Provide the exact sourceMappingURL value found in the deployed JavaScript and confirm whether the corresponding .map file exists at that path/URL. If no sourceMappingURL is present, source-map generation is disabled—enable it first before adjusting paths.
sourceMappingURL..map file is present at the resolved URL.sources/sourceRoot in the map file.Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.