Skip to content

Empty output file #23

Open
Open

Description

@mig82

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?

Activity

  1. goto-bus-stop commented on Jan 28, 2020

    @goto-bus-stop
    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
    
  2. mig82 commented on Jan 29, 2020

    @mig82
    Author

    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.

  3. goto-bus-stop commented on Feb 24, 2020

    @goto-bus-stop
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions