question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rollup can't import Snabbdom

See original GitHub issue

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} 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:closed
  • Created 6 years ago
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
StreetStridercommented, Sep 9, 2017

@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.

1reaction
caridycommented, Jul 19, 2017

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, the exports object is ambiguous due to the double exports everywhere.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found