Skip to content

Drop the dangling source map reference from underscore.js (#38865) - #41093

Open
lbajsarowicz wants to merge 1 commit into
magento:2.4-developfrom
lbajsarowicz:fix/38865-underscore-source-map
Open

Drop the dangling source map reference from underscore.js (#38865)#41093
lbajsarowicz wants to merge 1 commit into
magento:2.4-developfrom
lbajsarowicz:fix/38865-underscore-source-map

Conversation

@lbajsarowicz

Copy link
Copy Markdown
Contributor

Description (*)

lib/web/underscore.js is underscore's UMD distribution (underscore-umd.js) vendored into Magento under a different file name. The copy kept the build's trailing source map comment:

})));
//# sourceMappingURL=underscore-umd.js.map

The map itself is not vendored — there is no .map file anywhere under lib/web. So any browser with developer tools open follows that comment and requests underscore-umd.js.map next to the deployed underscore.js, which Magento cannot resolve.

Reproduced on 2.4-develop in developer mode:

$ curl -o /dev/null -w "%{http_code}" .../static/adminhtml/Magento/backend/en_US/underscore.js
200
$ curl -o /dev/null -w "%{http_code}" .../static/adminhtml/Magento/backend/en_US/underscore-umd.js.map
404

var/log/system.log:
main.ERROR:    Unable to resolve the source file for 'adminhtml/Magento/backend/en_US/underscore-umd.js.map'
main.CRITICAL: Unable to resolve the source file for 'adminhtml/Magento/backend/en_US/underscore-umd.js.map'

The message comes from Magento\Framework\View\Asset\File::getSourceFile(), reached through Magento\Framework\App\StaticResource when the map is requested. Because underscore is loaded on effectively every admin page, the log fills up with this entry during ordinary development.

This PR removes the dangling comment. Vendoring the upstream map instead was considered and rejected: it describes underscore-umd.js rather than the file Magento actually ships, and its sources point at underscore-esm.js, which is not vendored either — developer tools would then fail on the sources instead of the map.

After the change the deployed asset no longer advertises a map, so the request is never made and the log entry disappears.

Note for reviewers: 27 other vendored bundles under lib/web (hugerte skins, uppy, chartjs, less.min.js, vimeo player) carry the same kind of dangling sourceMappingURL. This PR deliberately stays with the reported file — those are separate third-party bundles and touching them is better done alongside their next library update.

Related Pull Requests

None.

Fixed Issues (if relevant)

  1. Fixes underscore-umd.js.map file is not generating #38865: underscore-umd.js.map file is not generating

Manual testing scenarios (*)

  1. Install Magento in developer mode.
  2. Open any admin page with browser developer tools open.
  3. Before: the network panel shows a 404 for .../en_US/underscore-umd.js.map, and var/log/system.log / var/log/debug.log record Unable to resolve the source file for '.../en_US/underscore-umd.js.map'.
    After: no map request is made and no such entry is logged.
  4. Confirm underscore itself still works — the deployed underscore.js loads and _.VERSION reports 1.13.7.

Questions or comments

The change removes one comment line from a vendored asset; no PHP is touched, so there is no unit or integration test in scope, and lib/web/underscore.js is not part of the ESLint whitelist (dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/magento.txt) since it is third-party code. Verification was done against a running instance as described above, plus a check that the library still parses and evaluates after the edit.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

lib/web/underscore.js is underscore's UMD build vendored under a different
file name, and it kept the trailing sourceMappingURL comment pointing at
underscore-umd.js.map. That map is not shipped, so every browser with
developer tools open requests it and Magento cannot resolve it:

    main.ERROR: Unable to resolve the source file for
    'adminhtml/Magento/backend/en_US/underscore-umd.js.map'

Remove the comment, since there is no map to point at. Shipping the upstream
map instead would not help: it describes underscore-umd.js and references
sources that are not vendored either.

Fixes magento#38865
@m2-assistant

m2-assistant Bot commented Aug 5, 2026

Copy link
Copy Markdown

Hi @lbajsarowicz. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@lbajsarowicz

Copy link
Copy Markdown
Contributor Author

@magento run all tests

@engcom-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Aug 11, 2026
@github-project-automation github-project-automation Bot moved this to Pending Review in Pull Requests Dashboard Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: pending review

Projects

Status: Pending Review

Development

Successfully merging this pull request may close these issues.

underscore-umd.js.map file is not generating

2 participants