🏠 back to Observable

importCell from 'dataflow'

Cell often says “invalid module”

It has actually worked a few times, but I have no idea why and what I was doing (I am trying to debug the issue). I don’t understand it though. Nor can I seem to refine the bug.

I think maybe the imported cell is throwing, and that is cached as a module failure which is unrecoverable? Very strange, not sure how to debug this.

I think this has something to do with how AMD and d3-require need a global define to load JavaScript files. I’m not sure exactly what’s going on here but my guess is that it has something to do with competition over the define global, perhaps because multiple copies of d3-require or some other library are being loaded.

The error happens when https://cdn.jsdelivr.net/npm/htl@0.2.5/dist/htl.min.js is implicitely lazy-loaded via importCell. At the moment d3-require (the one bundled with the separately loaded runtime) tries to pick the module from the top of the d3-require queue (in onload), the queue is empty, because (presumably) the other define was called.

For a debugging guide, see

Difficult to debug as there is the CDN cache to deal with so it not clear what you are importing when iterating. I have at least eliminated the Firebase dependancy in the latest version of Repro / Tom Larkworthy / Observable

I have seen the import bug hit the vanilla import {weblogin} from ‘…’ cell once too!

I found another way to achieve what I was trying to do so I will probably abandon this investigation for now. I also saw htl implicated too but I removed all references to htl and it seemed to work anyway, so not sure how reliable the error report is. Though see CDN discussion, I am not sure if half my experiments tested what I thought they were. I think we would need to add a version parameter to importCell to help with the debug workflow.