aearly/icepick

Using icepick.js in browser directly?

maruilian11 opened this issue ยท 11 comments

hi, I'm from cdnjs. Because your lib is very popular, we want to host it on https://cdnjs.com, can I add icepick.js to cdnjs directly for browser user? or if it doesn't work, can you also provide browserified icepick.js in every git tag(released versions) so that we can use git auto-update to add your lib to cdnjs automatically.
thank you very much!

cdnjs/cdnjs#7680

For anyone who can't wait for this, here is a hackish way to do it with SystemJS and unpkg:

<script> var process = { env: { NODE_ENV: 'production' } }; </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js" integrity="sha256-KJq4gv89+lNKzudhvvq6QJDLlFycaheMHYEf3UnTa2c=" crossorigin="anonymous"></script>
<script>
  'use strict';

  SystemJS.import('https://unpkg.com/icepick').then(function(i){
    const test = i.freeze([1,2,3]);
    console.log(i.setIn(test, [1], 'apple'));
  });
</script>

BTW, I still am considering the best way to support browsers. So far, most people have been using this in node, or with a bundler, so it doesn't matter that the lib is CJS only.

As of v2.1.0 I am publishing icepick.min.js and icepick.dev.js which are UMD bundles ready for the browser. Is there anything else I should do to ease interop with CDNJS?

We're actually using icepick on the frontend. Currently we have to apply our babelify transform globally to icepick to make it compatible with ie11.

It would definitely help if icepick.min.js was compiled down to that already.

Although IE11 doesn't really have much usage anymore, I think it'd help in the future as icepick can continue to use new features available in node as they become available without breaking browser compatibility as it goes.

I needed the ES6 code in icepick to be compiled because otherwise it would throw an error with UglifyJs in my transpiling build stage. Anyways I went ahead and rebuilt the dev/build pipeline so that it uses Webpack and works with my build. While I was at it I also created proper builds for three targets, node, browser, and browser.min. @aearly I'm not sure if you'll want to merge in these changes since it diverges significantly from the current build pipeline, but if you do, give me a shout and I'll create a pr.

Branch: https://github.com/artisin/icepick/tree/pr-%2325

I think that's a pretty big change to the build process when all that we really would need to be added there is a -t es2040 to the build script.

I agree, and like I mentioned these changes revolved around my build needs. I'm simply throwing it out there as another option.

@aearly Thank you. Now we can host the lib. ๐Ÿ‘

As of e9235f0 and v2.2.0, the minified standalone versions are ES5.

I want to keep the main icepick.js ES6, because it has slight performance benefits over ES5.

How about trying https://www.npmjs.com/package/uglify-es to minify for ES6? Thanks!

I was already using that! The two UMD builds are now ES5, so it shouldn't matter.