question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sourceMappingURL directive can fail if a bundled module specifies the directive

See original GitHub issue

If a bundled module has a sourceMappingURL directive, browserify will leave it intact, which appears to be worthless or harmful towards getting source maps to work properly in browsers.

Ideally, when browserify is generating source maps it would detect sourceMappingURL directives in bundled modules and include the contents of the targeted source maps in the bundle’s source map. At very least, the directives should be removed during bundling to prevent possible conflicts.

The same issue is present in webpack, so I will refer to the bug report there rather than duplicate it: https://github.com/webpack/webpack/issues/273

The only difference between browserify and webpack with this issue is that browserify does not use the deprecated //@ form of the directive, so it will only see the issue of duplicate sourceMappingURL directives when the bundled module has a directive in the form //# sourceMappingURL=....

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:2
  • Comments:23 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
jeremijacommented, Mar 26, 2019

I just added a sample repo here: https://github.com/jeremija/lerna-ts-example. Instructions provided in README.md.

EDIT I just realized that there is an easier way to do this in TypeScript, without the need for sourceify. The sourceMap property needs to be removed from tsconfig.json, and both inlineSourceMap and inlineSources need to be set to true.

Still, sourceify is useful in cases of 3rd-party libraries which might have source map file references instead of inlined sources.

2reactions
goto-bus-stopcommented, Mar 25, 2019

browser-pack should merge source maps correctly afaik. transforms are individually responsible for reading input source maps and outputting merged ones. i’m not sure what specifically is going wrong for people in this issue, but with a repro i could take a look at it

Read more comments on GitHub >

github_iconTop Results From Across the Web

4 Reasons Why Your Source Maps are Broken - Sentry Blog
To verify your source map directive is present and working, you need to: Locate the sourceMappingURL comment at the very end of the...
Read more >
TSConfig Reference - Docs on every TSConfig option
An error occurs if any of the files can't be found. ... a types inclusion, a /// <reference directive, or being specified in...
Read more >
Build Options - Vite
The default value is a Vite special value, 'modules' , which targets ... Note the build will fail if the code contains features...
Read more >
Source Maps — raven-js 3.4.0 documentation
sourceMappingURL =<url>. When Sentry encounters such a directive, it will resolve the source map URL relative the source file in which it is...
Read more >
how to specify bundle.js.map(source map) file path to devtools
also got other error bundle.js:9463 Refused to connect to ... the following Content Security Policy directive: "default-src 'self'".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found