I am currently working on a Vue 2 project developed using Vue CLI, and my goal is to package it as a library. I want to create a wrapper script that abstracts away dependencies and Vue syntax to enable easy interaction like the examples below:
// Mounting the component on a plain JS webpage
const myComponent = new MyComponent('#my-component');
// Handling events from the component in vanilla JS
myComponent.on('load', someHandler);
// (A.) Calling a component method and getting a return value
const processedData = myComponent.process(123);
// (B.) Accessing/mutating reactive component data properties
myComponent.setMessage('Hello world!');
I have attempted to modify the "build target" according to the instructions in the Vue documentation to build a Library or Web Component. While I can successfully mount the library component and handle events, there is no mention of how to interact with the component data externally from the Vue VM (referencing comments A and B).
What is the best approach to accessing Vue component methods and data properties from outside the Vue VM using vanilla JavaScript?