Skip to content

Instantly share code, notes, and snippets.

@rchanou
Last active January 8, 2018 22:10
Show Gist options
  • Save rchanou/7c9adc9ac95b5adadd70833ab07a32c8 to your computer and use it in GitHub Desktop.
Save rchanou/7c9adc9ac95b5adadd70833ab07a32c8 to your computer and use it in GitHub Desktop.
Boilerplate HTML for app that can use ES2015+/NPM modules (useful for quick one-off apps and experimenting)
<head>
<script type="text/javascript"> var process = { env: { NODE_ENV: 'production' } }; </script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.13.0/polyfill.min.js" integrity="sha256-1xJxekKA6MkBUKinJgsgPe3sTGMsKK6MzTzr+hKxMfI=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.15.0/babel.min.js" integrity="sha256-mxaL+9zRy1U6ZxZsba9703g+UH0v8Tjo/GUhpGpAjSc=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js" integrity="sha256-KJq4gv89+lNKzudhvvq6QJDLlFycaheMHYEf3UnTa2c=" crossorigin="anonymous"></script>
<script type='text/babel' data-presets='es2015,stage-0'>
'use strict';
(async () => {
// example of requesting an npm module import
const importIcepickTask = SystemJS.import('https://unpkg.com/icepick');
// wait for import to complete
const I = await importIcepickTask;
// do your thang!
const test = I.freeze([1,2,3]);
console.log(I.setIn(test, [1], 'apple'));
})();
</script>
</head>
@rchanou
Copy link
Author

rchanou commented Apr 1, 2017

The little var process = { env: { NODE_ENV: 'production' } }; script is specifically needed for icepick; it won't "build" unless it thinks it's in node. You may have to do similar hacks for other libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment