I'm using Laravel Mix, which uses Webpack 3.6, and I'm trying to install https://atomiks.github.io/tippyjs/.
My SCSS is probably working fine via @import "../../../../node_modules/tippy.js/dist/tippy.css";
.
However, at the top of my javascript file, I have this, which doesn't work:
var $ = require('jquery');
var webcast_helper = require('webcast_helper');
var moment = require('moment');
import tippy from 'tippy.js';
I get error: Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'
How can I import Tippy.js in a way that works with this Webpack approach?
(How to import tippy.js into an html page with webpack 4? obviously doesn't work for me.)
import tippy from 'tippy.js'
uses the ESM version (the"module"
field in package.json).For TippyJs 5.0.1 and Webpack 4, try:
const tippy = require('tippy.js').default;
To use the UMD version (supports CJS)
However I don't recommend using CJS version because treeshaking doesn't work.