space10-community / conversational-form

Turning web forms into conversations
https://space10-community.github.io/conversational-form/
MIT License
3.8k stars 776 forks source link

Cannot create new cf.EventDispatcher() when loading with ES6 Module Bundler #218

Closed jorditarrida closed 5 years ago

jorditarrida commented 6 years ago

Hi, I am trying to replicate the voice examples on your website. I am loading conversational-form using Webpack on my project with import cf from 'conversational-form'. When I try to instantiate a new cf.EventDispatcher() I get the following error __WEBPACK_IMPORTED_MODULE_0_conversational_form___default.a.EventDispatcher is not a constructor. I'm kind of a newbie in using Webpack as a module bundler so I might be missing some steps, but I'd say the error occurs because the EventDispatcher class is not exported and thus not importable with Webpack. Thanks in advance for your help :) Jordi

jenssogaard commented 6 years ago

Hi @jorditarrida. I'm not exactly sure if you hit a bug or what the problem might be. Let me have a look in the coming days and report back.

jenssogaard commented 6 years ago

@jorditarrida did you ever figure this out?

jorditarrida commented 6 years ago

@jenssogaard nope, if you could check on it that'd be great :)

jenssogaard commented 6 years ago

@jorditarrida alright, I'll have a look.

tonyyb commented 6 years ago

I've got the same issue !

jenssogaard commented 6 years ago

@jorditarrida @tonyyb I experience the same issue. I'll try to debug and figure out what is wrong.

Rchanger commented 6 years ago

I've got the same issue ,any updates on it

jenssogaard commented 6 years ago

@Rchanger no solution yet. I'm still trying to figure it out.

will3 commented 6 years ago

problem is, export function exports cf.ConversationalForm, not cf

jenssogaard commented 6 years ago

@will3 indeed, that is the issue.

@Rchanger @tonyyb @jorditarrida so the issue is that if I change the export to just cf then existing declarations breaks: Before: var myCF = new cf.startTheConversation({}) After: var myCF = new cf.ConversationalForm.startTheConversation({})

EDIT: Or at least the import would be diffent: import {FlowEvents, ConversationalForm, EventDispatcher} from 'conversational-form';

So for the sake of SemVer I see no other option than to wait for a v1.0 release as it is a breaking change. Any other suggestions on how to go about it will be warmly received.

diedea commented 6 years ago

any update/solutions on this? @jenssogaard @jorditarrida @will3 Running into the same problem when using meteor

UPDATE: the form is created and I can apply my personal stylesheet, however I cannot properly modify it since cf seems not to be defined (options in startTheConversation are not applied, event dispatcher doesn't work) Also weird: "cf-questions" in html does not work here within a fieldset of radio buttons (it duplicates the first label as question), but without problems with free text input (and in a normal html project).

diedea commented 6 years ago

I now loaded from the external script and I get the form version and options printed to the console, as well as seeing/being able to use the dialogue. However, none of my options (e.g. robot picture) are applied, and I still get the cf.EventDispatcher is not a constructor error.

jenssogaard commented 6 years ago

@diedea the solution should be clear - fixing the export as described above. However, it must be in a 1.0 beacuse of SemVer. I'll try to get a 1.0 out very soon.

Regarding Meteor - any chance you could put together a very simple example repo for me to look at?

diedea commented 6 years ago

Thanks for your help @jenssogaard - I published a small exemplatory repo here. A real beginner here, so I feel I don't have a lot of insight.

EDIT: created a separate meteor-issue (#249) since there seem to be extra problems that the people using Webpack/React...are not having

rafafotes commented 5 years ago

Any workaround to solve this while 1.0 isn't out?

jenssogaard commented 5 years ago

@rafafotes, unfortunately, you will have to wait until 1.0 is released which will hopefully happen sometime next month.

edlgg commented 5 years ago

Has this been solved? Im still getting the same error 'cf.EventDispatcher is not a constructor' im using nuxt.js in case it has any relevance.

jenssogaard commented 5 years ago

Hi @edlgg. We have had a bit of a delay on rolling out v1.0.0 where this issue is fixed. I hope it will be released in the next 4 weeks. I'm sorry for the delay.

edlgg commented 5 years ago

No worries I! I managed to do what I was trying to do anyways. Thank you for developing this project. It is very useful.

rahulrawat1210 commented 5 years ago

When will v1.0.0 be released? Still getting the error EventDispatcher is not a constructor

jenssogaard commented 5 years ago

@rahulrawat1210 I hope it will be released within 2-3 weeks.