Slidebars
Slidebars copied to clipboard
Add AMD/RequireJS and CommonJS
This PR add support for AMD/RequireJS and CommonJS. Now we can use this script with npm, webpack,... :
var slidebars = require('slidebars');
var controller = new slidebars();
Fix the issue #256 and partially the #122 without break the actual code
We need this one for sure!
agreed!
please merge this pull request!
If you're still waiting for this merge and using Webpack 2 you can use exports-loader
I've included slidebars using exports-loader and the webpack provide plugin:
...
new Webpack.ProvidePlugin({
slidebars: 'exports-loader?slidebars!slidebars/dist/slidebars',
}),
...
This makes sidebars globally available, which can be initialized like so:
$(document).ready(() => {
const controller = new slidebars()
controller.init()
})
@Nubuck : Thanks, it's works well !
Any plan of merging this? Seems like a much needed feature!
If you don't want to use the plugin @Nubuck mentions above, you can depend on my fork which includes CommonJS/AMD support and plays nice with webpack out of the box. Just change your package.json
to depend on:
"slidebars": "git+ssh://[email protected]/jaredh159/Slidebars.git#3.0.0"
And then yarn
or npm install
.
I have sent an email to Adam (owner / creator) to ask if he can merge this request! 🤞
Another way to import slidebars instead of using the provide plugin to make it globally available (which I find a bit too magical), you can:
- Install exports-loader plugin:
npm install exports-loader --save-dev
- In your js file, compiled by webpack:
var slidebars = require('exports-loader?slidebars!slidebars/dist/slidebars');
Note sure if it's best practice or not though.