Skip to content
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

Babili's sourcemaps causes error in collapseSourcemaps.js #1254

Closed
Comandeer opened this issue Jan 12, 2017 · 1 comment
Closed

Babili's sourcemaps causes error in collapseSourcemaps.js #1254

Comandeer opened this issue Jan 12, 2017 · 1 comment

Comments

@Comandeer
Copy link
Contributor

I've created simple plugin for babili, however sourcemaps don't work.

Stack trace
TypeError: Cannot read property 'traceSegment' of undefined
      at node_modules/rollup/dist/rollup.js:8902:23
      at Array.forEach (native)
      at node_modules/rollup/dist/rollup.js:8900:8
      at Array.map (native)
      at Link.traceMappings (node_modules/rollup/dist/rollup.js:8897:31)
      at collapseSourcemaps (node_modules/rollup/dist/rollup.js:9026:19)
      at Bundle$$1.render (node_modules/rollup/dist/rollup.js:9611:10)
      at Object.generate (node_modules/rollup/dist/rollup.js:9800:26)
      at rollup.then (tests/index.js:97:26)

It can be simply reproduced by running tests from my plugin, especially ones dedicated to sourcemaps.

After some investigation I discovered that Babili often returns last line mapping with only one segment:

Example Babili's output
[ [ [ 0, 0, 0, 0, 0 ],
    [ 8, 0, 0, 8, 1 ],
    [ 11, 0, 0, 0 ],
    [ 12, 0, 0, 13 ],
    [ 16, 0, 0, 0 ],
    [ 17 ] ] ]

This causes that source variable inside Link.traceMappings is undefined, so all efforts to use that variable (especially the very next line of code) just fails.

The simplest fix would be probably to just check if source variable is really set before trying to use it.

I also know that this issue seems to be very similar to #961 but my very quick research with GCC shows that the fix does not apply there and GCC still produces invalid sourcemaps.

@Rich-Harris
Copy link
Contributor

Released 0.41.5 with the fix — thanks, and sorry for the delay in merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants