ssrwpo / uglifyjs2

Meteor package that exposes options for UglifyJS2 JS minifier
https://ssrwpo.github.io/uglifyjs2/
MIT License
14 stars 7 forks source link

UGLYFYJS_DEAD is not defined #4

Closed snshn closed 7 years ago

snshn commented 7 years ago

Getting this fatal JS error in my app after compressing with "compress": false: Reference error: UGLYFYJS_DEAD is not defined. I use 'use strict'; in my app, so perhaps that's why it's happening.

Using this config:

  "uglifyjs2": {
    "options": {
      "fromString": false,
      "compress": {
        "properties": false,
        "dead_code": false,
        "drop_debugger": false,
        "conditionals": false,
        "comparisons": false,
        "evaluate": false,
        "booleans": false,
        "loops": false,
        "unused": false,
        "hoist_funs": false,
        "if_return": false,
        "join_vars": false,
        "cascade": false,
        "collapse_vars": false,
        "negate_iife": false,
        "pure_getters": false,
        "drop_console": false,
        "keep_fargs": false,
        "keep_fnames": false,
        "passes": 2,
        "global_defs": {
          "UGLYFYJS_DEAD": false
        }
      }
    }
  }

results in the same error, even though UGLYFYJS_DEAD is set in that case.

PEM-- commented 7 years ago

Indeed, compress is required. It's how you pass your information to Meteor's uglifly.

dnish commented 7 years ago

@PEM-- Having the same issue, even with the standard settings:

  "uglifyjs2": {
    "deadCodes": [
      "_meteor.Meteor.isServer",
      "Meteor.isServer"
    ],
    "fileRemoval": [
      "packages/ddp-server.js",
      "packages/shell-server.js",
      "packages/ssrwpo_uglifyjs2.js"
    ],
    "packageDebug": false,
    "aggressive": true,
    "options": {
      "fromString": true,
      "compress": {
        "properties": true,
        "dead_code": true,
        "drop_debugger": true,
        "conditionals": true,
        "comparisons": true,
        "evaluate": true,
        "booleans": true,
        "loops": true,
        "unused": true,
        "hoist_funs": true,
        "if_return": true,
        "join_vars": true,
        "cascade": true,
        "collapse_vars": true,
        "negate_iife": true,
        "pure_getters": true,
        "drop_console": true,
        "keep_fargs": false,
        "keep_fnames": false,
        "passes": 1,
        "global_defs": {
          "UGLYFYJS_DEAD": false
        }
      }
    }
  }

It happens after adding:

 import socketio from 'socket.io-client';