cujojs / poly

Small, fast, awesome. The only ES5-ish set of polyfills (shims) you can mix-and-match because they're individual modules.
Other
139 stars 18 forks source link

Load poly with a normal script #28

Closed jbadeau closed 10 years ago

jbadeau commented 10 years ago

Hi guys,

Do you guys have any plans to allow ploy shims to be loaded using a normal script tag? The problem is that if not using curl then it's hard to make sure poly loads first. Requirejs shim does not order amd dependencies and the order plugin is no longer supported. This means that other library may shim first with an implementation that doesn't work with cujo libs.

jbadeau commented 10 years ago

Perhaps using UMD?of course they would not be able to use poly/all but would need to include them manually. But this is the only way I know how to guarentee poly is loaded first in other and loaders

unscriptable commented 10 years ago

We were planning to use UMD, but for CommonJS compat , not globals.

RequireJS once had a priority config option. There is no equivalent in 2.0?

Can you create a version of require.js that concats the poly modules at the end?

jbadeau commented 10 years ago

Yes, require 2.x supports modules but we are experimenting with other loaders too. In theory a loader may rely on a shim itself. It's not really a problem for us but more if umd was on your roadmap. Most of this crap come from having to support ie 8-9 in enterprise environments :(

unscriptable commented 10 years ago

Have you looked at browserify to convert from AMD to globals? Here's how we're doing it in when.js: https://github.com/cujojs/when#legacy-environments-via-browserify You may be able to just point poly/all or poly/es5 at browserify.

unscriptable commented 10 years ago

@briancavalier says this will likely work for you:

browserify -s 'poly' es5.js -o poly-es5.browserify.js

Where es5.js is the existing poly/es5 module and you're running this from inside the poly/ folder.

Include poly-es5.browserify.js via script tag, and window.poly will be the poly module, and all of the modules that poly/es5 normally loads will have been "installed" (i.e. their polyfills will have been executed) just as if you had loaded poly/es5 via AMD.

Please reopen if this doesn't work.

-- John

jbadeau commented 10 years ago

Hey John,

Cool, this works! Do you have any intention of providing this with the official build?

Cheers, Jose