Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty output file #23

Open
mig82 opened this issue Jan 28, 2020 · 3 comments
Open

Empty output file #23

mig82 opened this issue Jan 28, 2020 · 3 comments

Comments

@mig82
Copy link

mig82 commented Jan 28, 2020

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?

@goto-bus-stop
Copy link
Member

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

@mig82
Copy link
Author

mig82 commented Jan 29, 2020

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.

@goto-bus-stop
Copy link
Member

If you do window.MyApp = initApp in your main file it should also work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants