Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of change
Packages
Issue
Resolves #27
Description
Add partial support for Vue 2 by exporting additional submodule
v2
which exports theLiveChatWidget
component compatible with Vue 2. The "hooks" using Composition API will still be Vue 3 exclusive feature as the overall Composition API is a new feature since version 3.The usage in Vue 2 app is as follows:
To achieve compatibility with both Vue 2 and Vue 3 for
LiveChatWidget
component it is defined with an "old" Options API approach (as opposed to Composition API with setup method or setup script).In order to resolve imports issues and no existence of
defineComponent
function invue@2
package but still offer to reach TypeScript support for Vue 3 there is a new dedicated build pipeline for Vue 2 submodule defined inpackages/widget-vue/rollup-vue2.config.js
. Aside from the typical Rollup configuration for input and output files, it includes a custom Babel plugin for removing imports and usages ofdefineComponent
from the output file leaving plain object component definition as an export. That way it can be consumed by Vue 2 application without compatibility error.The
LiveChatWidget
component required some slight adjustments to be both compatible with Vue 2 and 3:PropType
to type constructor (String, Object, Boolean etc.)render()
methods that explicitly return nothing (null
)emits
property which contains a list of events that consumers can listen on this component.this.emit$
directly in handlers and let Babel extractthis
reference binding.