tinyify
tinyify copied to clipboard
Empty output file
I'm having issues trying to get this to generate a minified output file. The mentioned output file is empty. I've tried these options. None work.
browserify -p tinyify src/main.js > foobar.min.js
browserify -p tinyify src/main.js -o foobar.min.js
browserify -p tinyify -o foobar.min.js src/main.js
browserify src/main.js -p tinyify -o foobar.min.js
And they all result in an empty foobar.min.js file. What am I doing wrong?
How does src/main.js
look like?
Sometimes modules don't have side effects. Like if they're just doing:
function initApp () {
// stuff here
}
module.exports = initApp
tinyify would consider all of this unused code and remove this. To check if this is what happening, try adding a --standalone
/-s
flag to the browserify command, because then the export would not be considered unused.
browserify -p tinyify -s MyApp src/main.js > foobar.min.js
Thank you @goto-bus-stop. That did the trick. Except it then defines the resulting lib as a UMD. I'd like a way to stop Tinyify from removing dead code. But apparently there's no flag for this in this plugin.
If you do window.MyApp = initApp
in your main file it should also work.