Slidebars icon indicating copy to clipboard operation
Slidebars copied to clipboard

Add AMD/RequireJS and CommonJS

Open matthieuy opened this issue 8 years ago • 9 comments

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

matthieuy avatar Oct 28 '16 16:10 matthieuy

We need this one for sure!

ghost avatar Mar 02 '17 07:03 ghost

agreed!

jonny-harte avatar Mar 08 '17 22:03 jonny-harte

please merge this pull request!

justijndepover avatar Apr 03 '17 08:04 justijndepover

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 avatar Jun 25 '17 17:06 Nubuck

@Nubuck : Thanks, it's works well !

matthieuy avatar Jul 03 '17 16:07 matthieuy

Any plan of merging this? Seems like a much needed feature!

pkid169 avatar Sep 27 '17 05:09 pkid169

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.

jaredh159 avatar Oct 03 '17 22:10 jaredh159

I have sent an email to Adam (owner / creator) to ask if he can merge this request! 🤞

justijndepover avatar Oct 05 '17 14:10 justijndepover

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:

  1. Install exports-loader plugin:
    npm install exports-loader --save-dev
    
  2. 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.

deltoss avatar Feb 25 '19 13:02 deltoss