Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOM driver imports both ES and CommonJS snabbdom modules #925

Open
mightyiam opened this issue Jan 23, 2020 · 2 comments
Open

DOM driver imports both ES and CommonJS snabbdom modules #925

mightyiam opened this issue Jan 23, 2020 · 2 comments

Comments

@mightyiam
Copy link

import {init} from 'snabbdom';

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:

import {h} from 'snabbdom/h';
import {VNode, VNodeData} from 'snabbdom/vnode';

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.

@mightyiam
Copy link
Author

Would be fixed by #944.

@wclr
Copy link
Contributor

wclr commented Jul 10, 2020

Just as current workaround with webpack it can be fixed by using:

new webpack.NormalModuleReplacementPlugin(
   /snabbdom\/[^\/]*$/, 
   (resource) => {
      resource.request = resource.request.replace(/snabbdom\//, 'snabbdom/es/' )
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants