cljsjs

2017-01-05T02:18:33.000415Z

does anyone know a polyfill package in cljsjs land?

2017-01-05T02:18:40.000416Z

something like babel/polyfill

upgradingdave 2017-01-05T14:14:02.000423Z

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!)

upgradingdave 2017-01-05T14:14:22.000424Z

I just realized that the aws-cognito-identity-js lib is a ES 6 module

upgradingdave 2017-01-05T14:15:16.000425Z

What’s the status with using ES 6 modules in clojurescript? Are there any examples of cljsjs packages that package ES 6 modules?

juhoteperi 2017-01-05T14:16:23.000426Z

@upgradingdave In most cases the ES6 JS is transpiled to ES5 using webpack or such

juhoteperi 2017-01-05T14:16:35.000428Z

(or perhaps in all cases)

upgradingdave 2017-01-05T14:17:20.000429Z

ah, ok, so I probably need to transpile to ES5 first, then I can use that ES5 to generate the exports?

juhoteperi 2017-01-05T14:18:12.000430Z

Hmm probably, I'm not sure how people usually generate externs for those libraries

upgradingdave 2017-01-05T14:18:30.000431Z

oops, right yeah, sorry I meant externs

juhoteperi 2017-01-05T14:18:42.000432Z

If you run extern generator in browser supporting es6, probably it can generate externs for es6 code also

upgradingdave 2017-01-05T14:19:28.000433Z

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

juhoteperi 2017-01-05T14:20:27.000434Z

okay, then you probably need to transpile it to es5

juhoteperi 2017-01-05T14:20:39.000435Z

you'll want to transpile to ES5 for browser use anyway

juhoteperi 2017-01-05T14:21:30.000436Z

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

upgradingdave 2017-01-05T14:22:29.000438Z

I think aws-cognito-sdk.js is a subset of aws-sdk (which is already in cljsjs)

upgradingdave 2017-01-05T14:22:36.000439Z

so I’m trying to package up this one:

juhoteperi 2017-01-05T14:23:13.000442Z

that would be es5 also

upgradingdave 2017-01-05T14:23:20.000443Z

oh really? hmm, ok

juhoteperi 2017-01-05T14:24:08.000444Z

did you load all the dependencies of the lib in extern generator?

upgradingdave 2017-01-05T14:24:42.000445Z

aha, I did not load the dependencies, yeah, maybe that was the problem then!

juhoteperi 2017-01-05T14:25:24.000446Z

also, another easy mistake is to try to load the file directly from github url

juhoteperi 2017-01-05T14:25:38.000447Z

github serves JS files with text/plain content-type so browser won't eval them

juhoteperi 2017-01-05T14:25:56.000448Z

checking browser console should give some idea about problems with evaluating the file

upgradingdave 2017-01-05T14:26:28.000449Z

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

juhoteperi 2017-01-05T14:26:38.000450Z

yep

upgradingdave 2017-01-05T14:27:24.000451Z

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?

juhoteperi 2017-01-05T14:28:22.000452Z

It is supported in theory, but I think npm dependency resolution is working only with CommonJS modules for now

juhoteperi 2017-01-05T14:28:39.000453Z

e.g. import * as sjcl from 'sjcl'; Closure doesn't know about sjcl

upgradingdave 2017-01-05T14:29:59.000454Z

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!