lib/uglifier.rb in uglifier-3.0.2 vs lib/uglifier.rb in uglifier-3.0.3

- old
+ new

@@ -36,11 +36,12 @@ :beautify => false, # Beautify output :indent_level => 4, # Indent level in spaces :indent_start => 0, # Starting indent level :space_colon => false, # Insert space before colons (only with beautifier) :width => 80, # Specify line width when beautifier is used (only with beautifier) - :preamble => nil # Preamble for the generated JS file. Can be used to insert any code or comment. + :preamble => nil, # Preamble for the generated JS file. Can be used to insert any code or comment. + :wrap_iife => false # Wrap IIFEs in parenthesis. Note: this disables the negate_iife compression option. }, :mangle => { :eval => false, # Mangle names when eval of when is used in scope :except => ["$super"], # Argument names to be excluded from mangling :sort => false, # Assign shorter names to most frequently used variables. Often results in bigger output after gzip. @@ -220,14 +221,23 @@ ) conditional_option( @options[:compress] || @options[:squeeze], defaults, - :keep_fnames => keep_fnames?(:compress) + { :keep_fnames => keep_fnames?(:compress) }.merge(negate_iife_block) ) end + # Prevent negate_iife when wrap_iife is true + def negate_iife_block + if output_options[:wrap_iife] + { :negate_iife => false } + else + {} + end + end + def comment_options case comment_setting when :all, true true when :jsdoc @@ -330,10 +340,10 @@ def sanitize_map_root(map) if map.nil? nil elsif map.is_a? String - sanitize_map_root(JSON.load(map)) + sanitize_map_root(JSON.parse(map)) elsif map["sourceRoot"] == "" map.merge("sourceRoot" => nil) else map end