Skip to content

Cannot redefine property: $apollo when rebuilding with webpack #358

@LukasBombach

Description

@LukasBombach

Hey, we have a very simple setup with vue-cli (3.0.0) and vue-apollo (using the latest vue-cli-plugin-apollo (0.16.2)). We have a file that adds VueApollo to Vue and create a Vue instance:

main.js

import Vue from 'vue';
import VueApollo from 'vue-apollo';
// ...
Vue.use(VueApollo);

export async function createApp({ context, beforeApp = () => {}, afterApp = () => {} } = {}) {
	const apolloProvider = createApolloProvider({
		ssr: process.server,
	});
	// ...
	const app = new Vue({
		router,
		provide: apolloProvider.provide(),
		render: h => h(Page),
	});
	// ...
}

when we work in our project and webpack triggers a rebuild, everything crashes and we get the error

TypeError: Cannot redefine property: $apollo
    at Function.defineProperty (<anonymous>)
    at Function.install (node_modules/vue-apollo/dist/vue-apollo.esm.js:4031:0)
    at Function.Vue.use (/Users/lbombach/Bild/projects/delivery/red-delivery/red-delivery/node_modules/vue/dist/vue.runtime.common.js:4749:22)
    at Module../src/main.js (src/main.js:22:4)
    ...

Any help would be very appreciated 🖖

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions