does anyone know a polyfill package in cljsjs land?
something like babel/polyfill
Hi all, I’m not very familiar with various ways of packaging javascript, so please bear with me. I’m working on packaging the aws-cognito-identity-js library so I can use it from cljs. (btw, thanks for the hints about packaging jsbn dependencies!)
I just realized that the aws-cognito-identity-js lib is a ES 6 module
What’s the status with using ES 6 modules in clojurescript? Are there any examples of cljsjs packages that package ES 6 modules?
@upgradingdave In most cases the ES6 JS is transpiled to ES5 using webpack or such
(or perhaps in all cases)
ah, ok, so I probably need to transpile to ES5 first, then I can use that ES5 to generate the exports?
Hmm probably, I'm not sure how people usually generate externs for those libraries
oops, right yeah, sorry I meant externs
If you run extern generator in browser supporting es6, probably it can generate externs for es6 code also
ok, cool, that’s what I am struggling with: I’m trying to use this site to generate externs: http://michaelmclellan.me/javascript-externs-generator/ but I don’t think it understands es6 modules
okay, then you probably need to transpile it to es5
you'll want to transpile to ES5 for browser use anyway
except if the library already provides file for browser use: https://github.com/aws/amazon-cognito-identity-js/blob/master/dist/aws-cognito-sdk.js
I think aws-cognito-sdk.js is a subset of aws-sdk (which is already in cljsjs)
so I’m trying to package up this one:
https://github.com/aws/amazon-cognito-identity-js/blob/master/dist/amazon-cognito-identity.min.js
that would be es5 also
oh really? hmm, ok
did you load all the dependencies of the lib in extern generator?
aha, I did not load the dependencies, yeah, maybe that was the problem then!
also, another easy mistake is to try to load the file directly from github url
github serves JS files with text/plain content-type so browser won't eval them
checking browser console should give some idea about problems with evaluating the file
oh right, yeah, been bitten by that too! I figured out that you can get the proper mime type by replacing <http://raw.github.com|raw.github.com>
with <http://rawgit.com|rawgit.com>
, that seems to work nicely
yep
I’ve seen mentioned (I think there was a google summer of code project) to be able to use ES 6 modules directly from cljs? Do you know if that’s available yet?
It is supported in theory, but I think npm dependency resolution is working only with CommonJS modules for now
e.g. import * as sjcl from 'sjcl';
Closure doesn't know about sjcl
hmm, interesting, I need to learn more about the different packaging strategies (common js, es6, etc) to understand the specifics, but thanks again for your help!