Last active
October 27, 2016 20:11
-
-
Save mindrones/4a68fb4484600ed50cd6934c5f1c5c16 to your computer and use it in GitHub Desktop.
Browserify build works, Rollup build doesn't (https://github.com/rollup/rollup/issues/1086)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": ["es2015"] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<title>with browserify bundle</title> | |
</head> | |
<body> | |
<div id="main-container"></div> | |
<script src="bundle_browserify.js"></script> | |
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<title>with rollup bundle</title> | |
</head> | |
<body> | |
<div id="main-container"></div> | |
<script src="bundle_rollup.js"></script> | |
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xs from 'xstream'; | |
import sampleCombine from 'xstream/extra/sampleCombine' | |
import {makeDOMDriver, h} from '@cycle/dom'; | |
import {makeHTTPDriver} from '@cycle/http'; | |
import Cycle from '@cycle/xstream-run'; | |
function main(sources) { | |
const input$ = sources.DOM.select('.field').events('input') | |
.map(ev => ev.target.value) | |
.filter(input => input.length > 0) | |
const name$ = sources.DOM.select('.go').events('click') | |
.startWith(null) | |
.compose(sampleCombine(input$)) | |
.map(c => c[1]) | |
const request$ = name$.map(name => ({ | |
url: `https://api.github.com/search/repositories?q=${encodeURI(name)}`, | |
category: 'github', | |
})) | |
const vtree$ = sources.HTTP.select('github') | |
.flatten() | |
.map(res => res.body.items) | |
.startWith([]) | |
.map(results => | |
h('div', [ | |
h('label.label', 'Search GitHub:'), | |
h('input.field', {attrs: {type: 'text'}}), | |
h('button.go', 'Go'), | |
h('ul.search-results', results.map(result => | |
h('li.search-result', [ | |
h('a', {attrs: {href: result.html_url}}, result.name) | |
]) | |
)) | |
]) | |
); | |
return { | |
DOM: vtree$, | |
HTTP: request$, | |
}; | |
} | |
Cycle.run(main, { | |
DOM: makeDOMDriver('#main-container'), | |
HTTP: makeHTTPDriver(), | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "cycle_rollup", | |
"scripts": { | |
"rollup": "rollup -c", | |
"browserify": "browserify main.js -t babelify --outfile bundle_browserify.js", | |
"bundles": "npm run browserify && npm run rollup" | |
}, | |
"devDependencies": { | |
"babel-preset-es2015": "^6.18.0", | |
"babelify": "^7.3.0", | |
"browserify": "^13.1.1", | |
"rollup": "^0.36.3", | |
"rollup-plugin-buble": "^0.14.0", | |
"rollup-plugin-commonjs": "^5.0.5", | |
"rollup-plugin-node-resolve": "^2.0.0", | |
"rollup-plugin-typescript": "^0.8.1" | |
}, | |
"dependencies": { | |
"@cycle/dom": "^13.0.0", | |
"@cycle/http": "^11.1.0", | |
"@cycle/xstream-run": "^3.1.0", | |
"xstream": "^7.0.0" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nodeResolve from 'rollup-plugin-node-resolve' | |
import typescript from 'rollup-plugin-typescript' | |
import commonjs from 'rollup-plugin-commonjs' | |
import buble from 'rollup-plugin-buble'; | |
export default { | |
entry : 'main.js', | |
dest : 'bundle_rollup.js', | |
format : 'iife', | |
plugins : [ | |
nodeResolve({ | |
jsnext: true, | |
main: true, | |
module: true, | |
browser: true | |
}), | |
typescript(), | |
commonjs({ | |
// namedExports: { | |
// 'node_modules/superagent/lib/request-base.js': ['clearTimeout'] | |
// } | |
}), | |
buble() | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment