Closed FezVrasta closed 7 years ago
Seems like it happens when sourceMap
is set to true
in Rollup
Yes, it's caused by the source maps. I've just pushed the basic support for them to the master, so you can use (or at least try to use…) the plugin straight from GH:
npm install Comandeer/rollup-plugin-babili
However the support for source maps is still very buggy and it'll probably fail on any more complex ES6 code.
Same error with the version from master 😢
This is the branch where I'm trying to use this plugin, maybe it can help.
https://github.com/FezVrasta/popper.js/tree/v1-dev-babili-plus-jsnext
With alpha3 I get:
Cannot read property 'traceSegment' of undefined
TypeError: Cannot read property 'traceSegment' of undefined
at /Users/federicozivolo/Progetti/popper-js/node_modules/rollup/src/utils/collapseSourcemaps.js:33:26
at Array.forEach (native)
at /Users/federicozivolo/Progetti/popper-js/node_modules/rollup/src/utils/collapseSourcemaps.js:31:9
at Array.map (native)
at Link.traceMappings (/Users/federicozivolo/Progetti/popper-js/node_modules/rollup/src/utils/collapseSourcemaps.js:28:34)
at collapseSourcemaps (/Users/federicozivolo/Progetti/popper-js/node_modules/rollup/src/utils/collapseSourcemaps.js:150:60)
at Bundle.render (/Users/federicozivolo/Progetti/popper-js/node_modules/rollup/src/Bundle.js:436:11)
at generate (/Users/federicozivolo/Progetti/popper-js/node_modules/rollup/src/rollup.js:73:28)
at Object.write (/Users/federicozivolo/Progetti/popper-js/node_modules/rollup/src/rollup.js:102:20)
at /Users/federicozivolo/Progetti/popper-js/node_modules/rollup/bin/rollup:908:18
No idea why the result is different from when I used the GitHub URL...
Sorry, I've forgot that I don't have the dist
directory on GitHub… I've just published new version of package on npm (version 1.0.0-alpha3). Maybe it would help.
If it still won't work, you could – as a workaround – use Babili in Rollup using rollup-plugin-babel with babili preset in a similar manner as I'm doing at the moment. The only issue with such approach is the fact that Rollup is minifying every file separately, not the whole bundle (and that's why I'm trying to create this plugin).
Thanks for the reply. I'm aware of the other method but I don't like the result. Right now I'm simply running babili via command line to get the best result. If you could fix this plugin it would be so much better tho! 🔥
Strangely enough the issue seems to be present only when bundling to the UMD format. When bundling to the ES format, everything is working fine.
It seems more like bug in rollup, not the plugin itself. I'll investigate it further.
Thank you, no rush by me. Once the plugin is ready I'll be happy to switch to it tho 🙂
I've added simple workaround for it and published in v1.0.0 of plugin. I hope that it will work now.
This still occurs. See e.g. github.com/knockout/tko – running MINIFY=1 rollup -c rollup.config.js
results in:
TypeError: Cannot read property 'traceSegment' of undefined at /usr/local/lib/node_modules/rollup/src/utils/collapseSourcemaps.js:33:26 at Array.forEach (native) at /usr/local/lib/node_modules/rollup/src/utils/collapseSourcemaps.js:31:9 at Array.map (native) at Link.traceMappings (/usr/local/lib/node_modules/rollup/src/utils/collapseSourcemaps.js:28:34) at collapseSourcemaps (/usr/local/lib/node_modules/rollup/src/utils/collapseSourcemaps.js:150:60) at Bundle.render (/usr/local/lib/node_modules/rollup/src/Bundle.js:436:11) at generate (/usr/local/lib/node_modules/rollup/src/rollup.js:73:28) at Object.write (/usr/local/lib/node_modules/rollup/src/rollup.js:102:20) at /usr/local/lib/node_modules/rollup/bin/rollup:907:18
I cannot reproduce this issue, both with local installation of rollup 0.41.6 and with global one.
What version of rollup do you have installed? Because this issue is reproducible only on <0.41.5.
Thanks, that was indeed the issue!
This is what I get when I try to use this plugin: