[Vuejs]-Why do I get an error when I use the Vue 2 Composition API in a Vue 2 component library built with vue-sfc-rollup?

2👍

The issue was that rollup needs to be told that the library has an external dependency.

In the build/rollup.config.js search for const external and add @vue/composition-api to the list.

const external = [
  'vue',
  '@vue/composition-api',  // <-- add this!
]

Then just build, publish to npm, npm update the package in the project consuming the package and it should work without error.

Thanks to this post on Github that steered me to the external config and
this example rollup.config.js the post links to that showed exactly where it should go.

👤Soviut

Leave a comment