#925·cyclejs

DOM driver imports both ES and CommonJS snabbdom modules

Author: mightyiamCreated Jan 23, 2020Updated Jul 10, 2020
Labelspriority 2 (could)issue is bugscope: dom

https://github.com/cyclejs/cyclejs/blob/9f0cd38f4b583aee31e714afc617727e766d05f5/dom/src/makeDOMDriver.ts#L2

I have examined together with @patomation an analysis of a webpack bundle that includes @cycle/dom and we have found in it that both CommonJS and ES snabbdom modules are included.

From my understanding of imports and webpack and snabbdom, here's what may be wrong: the above line is the only import in @cycle/dom code that is resolved to an ES snabbdom module, possibly because webpack may be reading this:

https://github.com/snabbdom/snabbdom/blob/665d9d39ff874955254d89b381c392a6ae4e94b1/package.json#L9

And all of the rest of the snabbdom imports refer directly to CommonJS module paths inside of the package. For example:

https://github.com/cyclejs/cyclejs/blob/9f0cd38f4b583aee31e714afc617727e766d05f5/dom/src/hyperscript-helpers.ts#L2-L3

So we end up with some duplicate snabbdom modules in the bundle and even worse — most of them are CommonJS.

This while snabbdom does provide an ES modules build.