Rollup can't import Snabbdom
See original GitHub issueI’ve been trying to use this with Rollup. I installed it in a project with npm
. I’m using syntax like this:
import {snabbdom} from 'snabbdom'
But Snabbdom never gets included in the final bundle. I also tried the following, to no avail:
import {init, h} from 'snabbdom'
I notice all the examples are using CommonJS require
. Is it possible to load this as ES6 modules? If so, are there some working examples somewhere?
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (4 by maintainers)
Top Results From Across the Web
Rollup can't import Snabbdom · Issue #319
I've been trying to use this with Rollup. I installed it in a project with npm. I'm using syntax like this: import {snabbdom}...
Read more >rollup-plugin-node-externals
Automatically declare NodeJS built-in modules and npm dependencies as 'external' in Rollup config. Latest version: 5.0.3, last published: 8 ...
Read more >snabbdom/snabbdom
Good morning, I want to add jsnext:main and module to the snabbdom's package.json to make it easier to treeshake snabbdom with Rollup. Does...
Read more >Snabbdom Renderer
Snabbdom Renderer. The default renderer is a small virtual DOM library that allows component authors to express their component's view as a function...
Read more >Recently Active 'rollup' Questions
Rollup build a React project import the modules in Node.js environment and get "TypeError: Cannot set properties of undefined (setting 'Headers')".
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@caridy, great thanks for your workaround, that helps me alot. I must notice that there is a little vacuum here for people who using ES6 modules, but not using TS. You can’t use origin
.ts
files, since you’re not in TS world, but processed files are already transpiled and may be ambiguous for Rollup. I believe, good solution would be to create additional es6 target (ts → es6), which would rid of all the typedefs but still be in ES6 modules syntax.Anyway, workaround is just working, and I’m OK until it is so. Have nothing against TS, just not using it in every project.
This is a common problem with rollup when the compiled bundle is ambiguous. We have been battling the same thing, and we have tried to fix it via https://github.com/snabbdom/snabbdom/pull/247, but we have no traction on that PR at the moment. Basically, Rollup will check if the CJS has a
default
export or not to try to understand the shape of the package. In the case of snabbdom, theexports
object is ambiguous due to the double exports everywhere.