Vue 3/Vite compatibility
See original GitHub issueWhen trying to use vue-matomo
(v3.14.0-0) with Vue 3/Vite the following error occurs:
[Vue warn]: A plugin must either be a function or an object with an "install" function.
My main.js
import matomo from 'vue-matomo'
import { createApp } from 'vue'
import App from './App.vue'
import './index.css'
createApp(App)
.use(matomo, {
host: 'https://matomo.example.com',
siteId: 42,
})
.mount('#app')
It works when importing src
:
import matomo from 'vue-matomo/src'
which explains, why the example for vue3 in this repository worked.
Steps to reproduce:
$ npm init vite-app vue3-matomo-demo
$ cd vue3-matomo-demo
$ npm install --save vue-matomo
edit main.js
according to the example above
$ npm install
$ npm run dev
Open http://localhost:3000 and check the console
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Getting Started - Vite
Scaffolding Your First Vite Project #. Compatibility Note. Vite requires Node.js version 14.18+, 16+. However, some templates require a higher Node.js version ...
Read more >Vite 3.0 is out!
Compatibility Notes # · Vite no longer supports Node. · Vite is now published as ESM, with a CJS proxy to the ESM...
Read more >Plugins - Vite
Before searching for a Vite or Compatible Rollup plugin, check out the Features Guide. ... Provides Vue 3 JSX support (via dedicated Babel...
Read more >Building for Production - Vite
Browser Compatibility The production bundle assumes support for modern JavaScript. By default, Vite targets browsers which support the native ES Modules, ...
Read more >Features | Vite
Vite provides first-class Vue support: Vue 3 SFC support via @vitejs/plugin-vue; Vue 3 JSX support via @vitejs/plugin-vue-jsx; Vue 2.7 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Seems like something with the type of packager used? Maybe we could export an object with install method, if that doesn’t break compatibility with other setups
Base on this I think it’s intended since it’s only support natif ES import.
And it’s mainly because we are using a default export for the install function.
Another syntax you can use is