Reputation: 1272
Trying to wrap my head around Webpack. I was able to set it up and get it working (combines my scripts and styles just fine), but I'm having trouble with a lazy loading plugin called bLazy, which I installed via npm. Here's the code in the file that I've defined as the entry point:
// Stylesheets
import './style.scss';
// Scripts
import 'salvattore';
import 'blazy';
var bLazy = new Blazy(); // This is the documented way to initialize bLazy.
I am getting the error: Uncaught ReferenceError: Blazy is not defined
. The Salvattore plugin, which is self-initializing, works fine. I'm also using jQuery, but bLazy is written in Javascript, so there shouldn't be any conflicting issues.
What am I doing wrong?
+++ UPDATE +++
I've changed the way I posed my question because apparently it's about ES6 and not Webpack, like I thought it was.
Upvotes: 1
Views: 513
Reputation: 1426
In the script you want to import you should "export" a value, like this:
class Blazy {...}
export default Blazy;
Then in script where you want to use it, you need to "import" this value:
import Blazy from './blazy'; // Note the path in quotes is relative to your current script file
let blazy = new Blazy();
Upvotes: 1