question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tippy as a VueJS directive : webpack compilation error (_tippy2.default is not a constructor)

See original GitHub issue

Hi !

First, thanks for your great tooltip library 😃 I don’t know if my problem comes from tippy, vuejs, webpack… So i try my chance here ^^

I’m trying to create a vuejs directive, to generate tippy tooltips into my SPA (compiled with webpack2)

My Vuejs Directive file :

import Vue from 'vue'
import Tippy from 'tippy'

Vue.directive('tippy', {
        inserted(el) {
            const tooltip = new Tippy(el, {
                arrow: true
            })
        }
})

In my Webpack.config file, i created an alias to resolve the tippy.js dist file only, cuz i don’t want to import the scss file too :

...
  resolve: {
    alias: {
      'vue$': 'vue/dist/vue.common.js',
      tippy$: 'tippy.js/dist/tippy.js'
    }
  }
...

When compiling, Webpack returns an error : TypeError: _tippy2.default is not a constructor...

WORKAROUND : If i include tippy.js into my index.html file, and remove my import Tippy from ‘tippy’ in my directive file tooltips works !!

index.html : <script src="node_modules/tippy.js/dist/tippy.js"></script> My directive file :

import Vue from 'vue'

Vue.directive('tippy', {
        inserted(el) {
            const tooltip = new Tippy(el, {
                arrow: true
            })
        }
})

My wish is to include Tippy from my directive file, and remove it from my index.html file. Please can someone could telle me where i am wrong ? Thanks 😃

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ALPIXELMaikicommented, Apr 16, 2017

Not again 😦

But after a search, i found it : http://stackoverflow.com/questions/20534702/node-js-use-of-module-exports-as-a-constructor

Since you can attach a function directly to module.exports you can essentially return a function and like any function it could be managed as a constructor

So i tried to modifiy your dist file by adding (at the very end) : module.exports = o;window.Tippy=o AND IT WORKS.

So, in your source code, i think you have to write this : (in src/js/tippy.js, at the very end of the file)

module.exports = Tippy
window.Tippy = Tippy

Add the module.exports line, compile and submit a v0.5.0 😃

Regards,

0reactions
ALPIXELMaikicommented, Apr 17, 2017

It works now 😃

Thanks for your work !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue is not a constructor error, using Typescript & webpack
1 Answer 1. Sorted by: Reset to default. Highest score (default) ...
Read more >
TypeError: Vue is not a constructor · Issue #5470 - GitHub
I was using Vue 2.1.8 with webpack2 and loading vue in my backbone router with require.ensure function provided by webpack for code splitting....
Read more >
Vue is not a constructor - Laracasts
Whenever i open up dev tool, there is an error saying 'Vue is not a constructor'. resources/js/app.js require('./bootstrap'); wind.
Read more >
Is not a constructor - Auth0 Community
I get this error within router/index.js. Any ideas? index.js?61a1:14 Uncaught TypeError: WEBPACK_IMPORTED_MODULE_6__auth_Auth.a is not a ...
Read more >
External Script: not a constructor error - Get Help - Vue Forum
I'm trying to get a third party JS script working on our Vue.JS project and failng because "TypeError: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found