source-map-explorer icon indicating copy to clipboard operation
source-map-explorer copied to clipboard

Unable to map a large amount of bytes

Open mdvorscak opened this issue 6 years ago • 32 comments

When running this tool I get: Unable to map 4270596 / 6575223 bytes (64.95%) printed to the console. The report still generates, but most of my bundle is 'unmapped'. This seems related to #47 , since this corresponds to TypeScript code. However, I get no information about any TypeScript code at all. Is this normal?

bundle_analysis

mdvorscak avatar Jan 16 '18 00:01 mdvorscak

Can you share your file? Are you using an inline source map?

danvk avatar Jan 16 '18 05:01 danvk

Unfortunately, cannot share my file. I am using an inline source map. I'll check tomorrow, I might be able to anonymize my source file. So I can give you something similar to it

mdvorscak avatar Jan 16 '18 06:01 mdvorscak

I get similar behavior. I see Unable to map 4098316 / 6530412 bytes (62.76%) and no problems with 1.4. Screenshot of the 1.5.0 results: image

here's my file, zipped up: lighthouse-background.js.zip

paulirish avatar Jan 16 '18 16:01 paulirish

@mdvorscak @paulirish would you be happier seeing that <unmapped> block omitted entirely? If I leave it out, then we run into #47 (number of bytes doesn't match file size). But the only other option is guessing where the unmapped bytes come from, which is problematic in its own ways.

danvk avatar Jan 16 '18 22:01 danvk

I'd rather keep it in with <unmapped> if the issue is really coming from the sourcemap itself. Is this an issue with TypeScript itself or some other third party lib which is producing the map?

mdvorscak avatar Jan 16 '18 23:01 mdvorscak

@mdvorscak I believe it is an issue with the source maps that tsc outputs. See this comment for more details.

I'm a little surprised that it's a majority of bytes in your source map, though. The unmapped bytes are usually just whitespace and return statements.

danvk avatar Jan 17 '18 00:01 danvk

I like labelling unmapped stuff as <unmapped> but think that if we can identify this unmapped bit as the sourcemap then we should say <source map>. regardless, i'm 👎 to omitting, so I think we have consensus there.

btw the map i provided is from browserify, no tsc involved.

paulirish avatar Jan 17 '18 00:01 paulirish

I've got a fix that counts inline source maps separately. Here's what the command line looks like:

$ node index.js /Users/danvk/Downloads/lighthouse-background.js
Inline source map accounts for 4064948 / 6530412 bytes (62.25%)
Unable to map 33368 / 6530412 bytes (0.51%)
Use --only-mapped to exclude these from the visualization.

and the visualization:

image

@paulirish @mdvorscak what do you guys think? Is this more confusing than just omitting the bytes from the inline source map by default?

danvk avatar Jan 17 '18 01:01 danvk

I like this approach since it leaves the possibility to use the option --only-mapped to omit these bytes or not depending on preference

mdvorscak avatar Jan 17 '18 01:01 mdvorscak

My only concern is that when you use SME, it's usually because you want to shrink your JS bundle. In which case the inline source map is a large (in terms of # of bytes) distraction.

If those bytes were excluded from the visualization, it would blur the distinction between running with separate .js / .js.map files and a single .js file with an inline source map.

danvk avatar Jan 17 '18 01:01 danvk

with browserify it's a slight pain to extract the inline sourcemap to a separate file, so i prefer not to do it. The only reason i sometimes build with sourcemaps is to use SME.

I think having the correct filesize up top makes the tool more trustworthy, so I think it's worthwhile to tell the truth even if it makes exploring the data slightly more annoying.

I guess it'd be slightly better if there was a treemap box around the non-inline-sourcemap stuff so i can very quickly exclude that from view. (In this file, there are two siblings rather than just one). Is it reasonable for there to be a (<mapped files>) parent or something? Naming is hard.

paulirish avatar Jan 17 '18 01:01 paulirish

FYI: In our case this was due to comments left by webpack and untouched by uglify, mostly ModuleConcatenationPlugin bailout messages. We solved by turning off pathinfo in webpack config.

joshjg avatar Mar 19 '18 18:03 joshjg

Hi @danvk

Just want to understand what part of code is unmapped code and Are you planning to add better visualisation for a developer to understand it. Is this unmapped code need to be optimised or not? Thanks!

harshjulka avatar May 30 '18 07:05 harshjulka

There should be simple utility that can output bundle lines that are not covered by sourcemap. As a first step to understand "why there are unmapped lines?"

rpokrovskij avatar Sep 15 '18 09:09 rpokrovskij

@mdvorscak @paulirish I just realised that in my case the majority of the unmapped bits were related to json files from my codebase. Could it be also the case in your project?

gpawlik avatar Apr 24 '19 09:04 gpawlik

having the similar issue when analyzing bundle build by create-react-app

> source-map-explorer 'build/static/js/*.*'

build/static/js/2.a9bd8fbb.chunk.js
  Unable to map 130/185977 bytes (0.07%)
build/static/js/main.32bd81bd.chunk.js
  Unable to map 14790/17385 bytes (85.07%)
build/static/js/runtime~main.d653cc00.js
  1. Your source map only contains one source (../webpack/bootstrap).
  This can happen if you use browserify+uglifyjs, for example, and don't set the --in-source-map flag to uglify.
  See https://github.com/danvk/source-map-explorer/blob/master/README.md#generating-source-maps
  2. Unable to map 62/1502 bytes (4.13%)

littlee avatar Jul 17 '19 04:07 littlee

@littlee Running into the same problems over here, 2.1 MB, 64% of the total bundle is unmapped. Screenshot from 2019-09-13 03-40-31

Reproduction steps:

git clone [email protected]:safudex/neologin.git
cd login
npm install
npm run build
npm run analyze

corollari avatar Sep 12 '19 19:09 corollari

Fixed my problem, in my case the unmapped bytes were caused by a package being imported.

corollari avatar Sep 13 '19 02:09 corollari

@littlee , same here. What version of react-scripts are you using? Are you using Typescript?

carpben avatar Nov 06 '19 16:11 carpben

@all

I am using the latest version of react-scirpts & latest version of source-map-explorer now, and I am using this command to analyze, thing has get a lot better, but still a small part of the bundle is unaleb to map

source-map-explorer ./build/static/js/*.js

littlee avatar Nov 06 '19 16:11 littlee

Thanks @littlee, Unfortunately my experience is different. image

carpben avatar Nov 06 '19 19:11 carpben

I have a similar problem Screenshot 2019-11-12 at 16 09 43

cheepo2109 avatar Nov 12 '19 10:11 cheepo2109

I am also getting the null as a js variant. "react-scripts": "^3.2.0", "analyze": "source-map-explorer 'build/static/js/*.js'", Screenshot 2019-11-25 at 3 25 11 PM

uttam23 avatar Nov 25 '19 09:11 uttam23

Please stop posting null issue comments here. There is an issue #142

nikolay-borzov avatar Nov 25 '19 09:11 nikolay-borzov

The issue has been addressed within #146, #140, #129 and #134. Most of the unmapped bytes were actually sourceMappingURL comments or 'null' (generated) source bytes. Closing the issue. Feel free to reopen if you can reproduce the issue in version 2.1.2 or newer

nikolay-borzov avatar Dec 03 '19 16:12 nikolay-borzov

Still seeing this with the latest create-react-app:

  1. npx create-react-app my-app
  2. npm install -g source-map-explorer
  3. cd my-app
  4. npm run build
  5. source-map-explorer 'build/static/js/*.js'

Result:

$ source-map-explorer 'build/static/js/*.js'

build/static/js/2.2594f893.chunk.js
  Unable to map 173/129442 bytes (0.13%)
build/static/js/main.10e23077.chunk.js
  Unable to map 90/1219 bytes (7.38%)
build/static/js/runtime-main.e1daef6b.js
  Unable to map 13/1559 bytes (0.83%)

cmacdonnacha avatar Mar 31 '20 16:03 cmacdonnacha

Still experiencing this issue with create-react-app.

dons20 avatar Jul 16 '20 17:07 dons20

build/static/js/main.99550a42.js Unable to map 83/4010372 bytes (0.00%) build/static/js/my-component.554d7dd9.chunk.js Unable to map 147/604 bytes (24.34%)

reproduce it with CRA 4.0.1 reopen please

prapakou avatar Feb 10 '21 09:02 prapakou

reproduce it with CRA 4.0.2

build/static/js/2.c35a0e8e.chunk.js
  Unable to map 175/1951255 bytes (0.01%)
build/static/js/main.2755ea06.chunk.js
  Unable to map 253/67052 bytes (0.38%)
build/static/js/runtime-main.17e26823.js
  Unable to map 13/1561 bytes (0.83%)
Done in 1.70s.
 rw-r--r--   1   rioshi   rioshi      1 MiB   Thu Feb 25 17:37:19 2021   2.c35a0e8e.chunk.js
  rw-r--r--   1   rioshi   rioshi      1 KiB   Thu Feb 25 17:37:19 2021   2.c35a0e8e.chunk.js.LICENSE.txt
  rw-r--r--   1   rioshi   rioshi      9 MiB   Thu Feb 25 17:37:19 2021   2.c35a0e8e.chunk.js.map
  rw-r--r--   1   rioshi   rioshi     65 KiB   Thu Feb 25 17:37:18 2021   main.2755ea06.chunk.js
  rw-r--r--   1   rioshi   rioshi    118 B     Thu Feb 25 17:37:19 2021   main.2755ea06.chunk.js.LICENSE.txt
  rw-r--r--   1   rioshi   rioshi    155 KiB   Thu Feb 25 17:37:19 2021    main.2755ea06.chunk.js.map
  rw-r--r--   1   rioshi   rioshi      1 KiB   Thu Feb 25 17:37:19 2021  runtime-main.17e26823.js
  rw-r--r--   1   rioshi   rioshi      8 KiB   Thu Feb 25 17:37:19 2021  runtime-main.17e26823.js.map

shikelong avatar Feb 25 '21 08:02 shikelong

same thing here. create-react-app with typescript template, no extra configuration, just a tiny app and unable to get this thing working.

npx source-map-explorer build/**/*.js
build/static/js/2.ea5231d0.chunk.js
  Unable to map 183/1009903 bytes (0.02%)
build/static/js/main.76a6cd7f.chunk.js
  Unable to map 101/53915 bytes (0.19%)
build/static/js/runtime-main.4f382c48.js
  Unable to map 13/1569 bytes (0.83%)

i dont even get a Done message at the end. (WSL2 ubuntu)

// my main packages
"source-map-explorer": "^2.5.2",
"react": "^17.0.1",
"typescript": "^4.1.5"
"react-scripts": "^4.0.3",

kitsunekyo avatar Apr 23 '21 11:04 kitsunekyo