Fork me on GitHub
#cljsjs
<
2017-01-05
>
michael.heuberger02:01:33

does anyone know a polyfill package in cljsjs land?

michael.heuberger02:01:40

something like babel/polyfill

upgradingdave14:01:02

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

upgradingdave14:01:22

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

upgradingdave14:01:16

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

juhoteperi14:01:23

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

juhoteperi14:01:35

(or perhaps in all cases)

upgradingdave14:01:20

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

juhoteperi14:01:12

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

upgradingdave14:01:30

oops, right yeah, sorry I meant externs

juhoteperi14:01:42

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

upgradingdave14:01:28

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

juhoteperi14:01:27

okay, then you probably need to transpile it to es5

juhoteperi14:01:39

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

upgradingdave14:01:29

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

upgradingdave14:01:36

so I’m trying to package up this one:

juhoteperi14:01:13

that would be es5 also

upgradingdave14:01:20

oh really? hmm, ok

juhoteperi14:01:08

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

upgradingdave14:01:42

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

juhoteperi14:01:24

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

juhoteperi14:01:38

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

juhoteperi14:01:56

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

upgradingdave14:01:28

oh right, yeah, been bitten by that too! I figured out that you can get the proper mime type by replacing with , that seems to work nicely

upgradingdave14:01:24

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?

juhoteperi14:01:22

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

juhoteperi14:01:39

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

upgradingdave14:01:59

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!