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

Using poly with no commonjs or amd #34

Closed aeisenberg closed 9 years ago

aeisenberg commented 9 years ago

In our environment, we are not using commonjs or amd (only angularjs modules). I'm not able to load function.js (or any module for that matter) when not using these module systems. Any suggestions on how to do this?

aeisenberg commented 9 years ago

Guess we need a meta-poly to polyfill the polyfill. :)

briancavalier commented 9 years ago

Hey @aeisenberg! Poly was designed to be used in amd and commonjs environments. The simplest option would probably be to browserify whatever poly module you need (like poly/all, poly/es5, or just poly/function if that's all you need). Using browserify's standalone option is usually a good way to build a modular library into a script that's loadable via <script> element.

Here's an example from when.js's package.json of the browserify command that can be used to build when.js for non-modular environments. I bet something similar would work for poly, like: browserify -s poly all.js -o poly.browserified.js

If that doesn't seem like a workable option, you could try es5-shim.

Hope that helps!

aeisenberg commented 9 years ago

Thanks @briancavalier. I'll try browserify. The main reason we want to use poly is for its modularity and so we can keep things small. With es5-shim, we'd have to include the whole shebang, which is not needed in our case.

briancavalier commented 9 years ago

Cool, let us know how it goes.

unscriptable commented 9 years ago

Hey @aeisenberg, here's what another user tried successfully: https://github.com/cujojs/poly/issues/28#issuecomment-29720704

unscriptable commented 9 years ago

I updated the docs: https://github.com/cujojs/poly/blob/master/README.md#can-i-use-poly-without-a-module-loader

Hey @aeisenberg , I'm closing this for now, but please reopen it if you have any further issues. -- John

briancavalier commented 9 years ago

I updated the docs: https://github.com/cujojs/poly/blob/master/README.md#can-i-use-poly-without-a-module-loader

:+1:

aeisenberg commented 9 years ago

Thanks! Works for me!