repro for rollup/rollup-plugin-commonjs#140
Created
December 14, 2016 16:47
-
-
Save Rich-Harris/39128d7fecbc4e62c16f9b692ac52541 to your computer and use it in GitHub Desktop.
This file contains 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
.DS_Store | |
node_modules |
This file contains 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
(function () { | |
'use strict'; | |
var BEEP_DELAY = 500; | |
function beep() { | |
process.stdout.write('\u0007'); | |
} | |
function melodicalBeep(val, cb) { | |
if (val.length === 0) { | |
cb(); | |
return; | |
} | |
setTimeout(function () { | |
if (val.shift() === '*') { | |
beep(); | |
} | |
melodicalBeep(val, cb); | |
}, BEEP_DELAY); | |
} | |
var index = function (val, cb) { | |
if (!process.stdout.isTTY || | |
process.argv.indexOf('--no-beep') !== -1 || | |
process.argv.indexOf('--beep=false') !== -1) { | |
return; | |
} | |
cb = cb || function () {}; | |
if (val === parseInt(val)) { | |
if (val < 0) { | |
throw new TypeError('Negative numbers are not accepted'); | |
} | |
if (val === 0) { | |
cb(); | |
return; | |
} | |
for (var i = 0; i < val; i++) { | |
setTimeout(function (i) { | |
beep(); | |
if (i === val - 1) { | |
cb(); | |
} | |
}, BEEP_DELAY * i, i); | |
} | |
} else if (!val) { | |
beep(); | |
cb(); | |
} else if (typeof val === 'string') { | |
melodicalBeep(val.split(''), cb); | |
} else { | |
throw new TypeError('Not an accepted type'); | |
} | |
}; | |
console.log( `beeper`, index ); | |
}()); |
This file contains 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 beeper from 'beeper'; | |
console.log( `beeper`, beeper ) |
This file contains 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
{ | |
"devDependencies": { | |
"rollup": "^0.37.0", | |
"rollup-plugin-commonjs": "^5.0.5", | |
"rollup-plugin-node-resolve": "^2.0.0" | |
}, | |
"dependencies": { | |
"beeper": "^1.1.1" | |
}, | |
"scripts": { | |
"build": "rollup -c" | |
} | |
} |
This file contains 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 commonjs from 'rollup-plugin-commonjs'; | |
export default { | |
entry: 'index.js', | |
dest: 'bundle.js', | |
format: 'iife', | |
plugins: [ | |
nodeResolve(), | |
commonjs() | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment