chartist: Import not working with webpack+babel

I’d like to use chartist in the manner below. My workflow uses webpack and babel.

import Chartist from ‘chartist’;

This throws the following in the browser: Uncaught TypeError: Cannot set property 'Chartist' of undefined

I have got around this by forking chartist and tweaking the factory code in the manner described here: https://github.com/gregjacobs/Autolinker.js/issues/86#issuecomment-74487812

It would be great if this could be incorporated into the master branch.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 23 (1 by maintainers)

Most upvoted comments

three years later, and this still seems to be an issue. why is this closed? both import Chartist from 'chartist' and require('chartist') lead to this error for me

edit: using 0.10.1

Import works flawlessly. As stated in another issue, not all plugins return functions.

import Chartist from 'chartist' worked perfectly.

Ok, I’ll create a task to update to the latest grunt-umd.

For me this is still broken with latest version 0.10.1.

Uncaught TypeError: Cannot set property 'Chartist' of undefined

When using latest Webpack 2 + Babel + babel-preset-es2015

import Chartist from 'chartist'

Update: Problem gets resolved when updating to babel-preset-es2016, but this is not ideal.

Any ideas on how to solve this?