# importCell from 'dataflow'

**URL:** <https://talk.observablehq.com/t/importcell-from-dataflow/5164>\
**Category:** Help\
**Created:** [June 4, 2021, 8:36pm UTC](https://talk.observablehq.com/t/importcell-from-dataflow/5164 "2021-06-04T20:36:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomlarkworthy](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/tomlarkworthy/32/5940_2.png) [@tomlarkworthy](https://talk.observablehq.com/u/tomlarkworthy)\
**Post date:** [June 4, 2021, 8:36pm UTC](https://talk.observablehq.com/t/importcell-from-dataflow/5164/1 "2021-06-04T20:36:38Z")

</div>

Cell often says “invalid module”

> **[Repro / Tom Larkworthy / Observable](https://observablehq.com/@tomlarkworthy/importcellbug)**
>
> Explore and visualize data. Share and publish your insights. Discover and be inspired.

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.

---

<div class="post-metadata">

**Author:** ![mbostock](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbostock/32/9_2.png) [@mbostock](https://talk.observablehq.com/u/mbostock)\
**Post date:** [June 4, 2021, 9:12pm UTC](https://talk.observablehq.com/t/importcell-from-dataflow/5164/2 "2021-06-04T21:12:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [June 5, 2021, 10:44am UTC](https://talk.observablehq.com/t/importcell-from-dataflow/5164/3 "2021-06-05T10:44:57Z")

</div>

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

> [@importCell conflicts with static import](https://talk.observablehq.com/t/importcell-conflicts-with-static-import/4548/9):
>
> The process was: verify that you can reliably reproduce the error (+1 for that with cache disabled) in your developer tools, open the “Search” drawer and search for “invalid module” (it should appear in two files) prettify each file and set a breakpoint in the corresponding line (you may have to search the file for “invalid module”) reload, and wait for the breakpoint to hit From here on we have two objectives: find out where the error originated find out the nature (and possibly the caus…

---

<div class="post-metadata">

**Author:** ![tomlarkworthy](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/tomlarkworthy/32/5940_2.png) [@tomlarkworthy](https://talk.observablehq.com/u/tomlarkworthy)\
**Post date:** [June 5, 2021, 9:19pm UTC](https://talk.observablehq.com/t/importcell-from-dataflow/5164/4 "2021-06-05T21:19:09Z")

</div>

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](https://observablehq.com/@tomlarkworthy/importcellbug)

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.
