Skip to content

Instantly share code, notes, and snippets.

@fjeldstad
Last active October 5, 2016 09:40
Show Gist options
  • Save fjeldstad/69cf5992fb5bdfa5b4e85b46bb652c3b to your computer and use it in GitHub Desktop.
Save fjeldstad/69cf5992fb5bdfa5b4e85b46bb652c3b to your computer and use it in GitHub Desktop.
A practical choo app starter kit with ES2015 support and reasonably small bundle footprint.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>hello-choo</title>
</head>
<body>
<script src="static/bundle.js"></script>
</body>
</html>
require("regenerator-runtime/runtime");
const choo = require('choo');
const html = require('choo/html');
const { Promise } = require('./utils.js');
// Choo app using promises, generator functions (with co, perhaps)
// and whatever ES2015 features you like.
// ...
{
"name": "hello-choo",
"version": "1.0.0",
"description": "A practical choo app starter kit with ES2015 support and reasonably small bundle footprint.",
"main": "index.js",
"scripts": {
"start": "budo index.js:static/bundle.js --pushstate --live --open -- -t sheetify/transform -t babelify",
"build": "rm -rf dist && mkdir -p dist/static && cp index.html dist && NODE_ENV=production browserify -e index.js -t sheetify/transform -t yo-yoify -t babelify -t envify -g unassertify -g uglifyify | uglifyjs > dist/static/bundle.js"
},
"author": "Anders Fjeldstad (https://twitter.com/hihaj)",
"license": "MIT",
"babel": {
"plugins": [
"transform-runtime"
],
"presets": [
"es2015"
]
},
"dependencies": {
"babel-runtime": "^6.11.6",
"choo": "^3.3.0",
"es6-promise": "^4.0.3",
"regenerator-runtime": "^0.9.5"
},
"devDependencies": {
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.14.0",
"babelify": "^7.3.0",
"browserify": "^13.1.0",
"budo": "^9.2.0",
"envify": "^3.4.1",
"sheetify": "^5.1.0",
"uglifyify": "^3.0.3",
"uglifyjs": "^2.4.10",
"unassertify": "^2.0.3",
"yo-yoify": "^3.4.1"
}
}
const { Promise } = require('es6-promise');
Promise.fromCallback = (fn) => {
return new Promise((resolve, reject) => {
try {
fn((error, result) => {
if (error) {
reject(error);
} else {
resolve(result);
}
});
} catch (error) {
reject(error);
}
});
};
module.exports = {
Promise,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment