Add UMD support. Fixes #91 #101

Merged
merged 5 commits into from May 23, 2016

Projects

None yet

4 participants

@javan
Member
javan commented May 17, 2016

Define UMD module for Turbolinks to support script / module build tools like webpack, browserify, require.js, etc.

@sstephenson
Contributor

We’ll need to update the documentation too.

@javan
Member
javan commented May 17, 2016

What do you think about removing the Installation Using Webpack documentation since it Just Works now?

@sstephenson
Contributor

I’m fine with removing the Webpack-specific parts, but we should still have a parallel set of instructions for using Turbolinks as a module. You still have to install the package and require it somewhere.

@javan
Member
javan commented May 17, 2016

Updated the docs

@sstephenson
Contributor

Both the iOS and Android adapters, as well as the Rails plugin, depend on Turbolinks being available in the global object. We should either tell people to assign to window.Turbolinks here or do it automatically in the module.

Member

Hmm, probably best to do that in index.coffee: @Turbolinks = window.Turbolinks = { ... }

Member

I'm fine with adding it to the npm docs too. Have a preference?

Member

Went the documentation route: b938b3b

@javan
Member
javan commented May 17, 2016

FYI, I confirmed the compiled .js works normally with <script src="turbolinks.js"></script> and with webpack and browserify:

(function() {
  var Turbolinks = require("./turbolinks");
  console.log("local var Turbolinks =", Turbolinks); // defined
})()

addEventListener("DOMContentLoaded", function() {
  console.log("widow.Turbolinks =", window.Turbolinks) // undefined
})
@TSMMark
TSMMark commented May 19, 2016

As a Browserify user, I thank you! 👍

@sstephenson sstephenson merged commit 44a645f into master May 23, 2016
@sstephenson
Contributor

Thanks for making this possible @javan! 💝🎉

@sstephenson sstephenson deleted the umd branch May 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment