loaders.gl icon indicating copy to clipboard operation
loaders.gl copied to clipboard

rollup bundling issues

Open ibgreen opened this issue 3 years ago • 4 comments

Regarding issue reported in deck.gl https://github.com/visgl/deck.gl/issues/6494 by @diego-antonelli

rollup support is not something we test regularly.

We do have a rollup example in loaders.gl, https://github.com/visgl/loaders.gl/tree/master/examples/get-started/get-started-rollup but it referenced very old loaders.gl version.

I bumped the loaders.gl dependencies in that example and I get a lot of errors that seem to stem from rollup not respecting package.json browser fields. It tries to bundle files that are marked as excluded on non-node builds.

ibgreen avatar Dec 09 '21 20:12 ibgreen

Thanks a lot @ibgreen for looking into this. Unfortunately I have to use rollup on the deck.gl project I am working on. If you can think of any workaround for this issue for the moment, that would be wonderful. Otherwise I will continue to investigate what is wrong with Rollup!

Arthurgoujon avatar Dec 10 '21 14:12 Arthurgoujon

Actually, just to follow up on this, my friend found a workaround. In the rollup config file, when setting up options for the plugin noderesolve, do not include 'modules'.

nodeResolve({ preferBuiltins: false, mainFields: ["browser", "main"] })

Arthurgoujon avatar Dec 11 '21 12:12 Arthurgoujon

Adding mainFields: ["browser", "main"] (and keeping everything else the same) raises Right-hand side of 'instanceof' is not callable error. The error happens on interacting with the map: I have a MeshLayer, presumably this happens on picking.

Error
copy-and-blit.js:353 Uncaught TypeError: Right-hand side of 'instanceof' is not callable
    at getFramebuffer$3 (copy-and-blit.js:353:15)
    at readPixelsToArray (copy-and-blit.js:47:25)
    at DeckPicker._drawAndSample (deck-picker.js:415:34)
    at DeckPicker._pickClosestObject (deck-picker.js:204:47)
    at DeckPicker.pickObject (deck-picker.js:74:19)
    at Deck._pick (deck.js:388:42)
    at Deck._pickAndCallback (deck.js:581:32)
    at Deck._onRenderFrame (deck.js:741:12)
    at AnimationLoop.onRender (animation-loop.js:315:51)
    at AnimationLoop._renderFrame (animation-loop.js:422:21)
getFramebuffer$3 @ copy-and-blit.js:353
readPixelsToArray @ copy-and-blit.js:47
_drawAndSample @ deck-picker.js:415
_pickClosestObject @ deck-picker.js:204
pickObject @ deck-picker.js:74
_pick @ deck.js:388
_pickAndCallback @ deck.js:581
_onRenderFrame @ deck.js:741
onRender @ animation-loop.js:315
_renderFrame @ animation-loop.js:422
redraw @ animation-loop.js:201
renderFrame @ animation-loop.js:348
requestAnimationFrame (async)
requestAnimationFrame$1 @ request-animation-frame.js:10
_requestAnimationFrame @ animation-loop.js:406
renderFrame @ animation-loop.js:350
requestAnimationFrame (async)
requestAnimationFrame$1 @ request-animation-frame.js:10
_requestAnimationFrame @ animation-loop.js:406
renderFrame @ animation-loop.js:350
...

saravanabalagi avatar Jun 06 '22 11:06 saravanabalagi

Hi, yes, same thing happened to me. For now the manual fix I found was to copy function copyToDataUrl to framebuffer.js to avoid importing it from copy-and-blit.js. (https://github.com/visgl/luma.gl/issues/1549) in order to resolve the circular dependency.

Arthurgoujon avatar Jun 06 '22 13:06 Arthurgoujon