Skip to content

Fix missing ending semicolon in UglifyJS output#23

Open
thibaudcolas wants to merge 1 commit into
fat:masterfrom
thibaudcolas:patch-1
Open

Fix missing ending semicolon in UglifyJS output#23
thibaudcolas wants to merge 1 commit into
fat:masterfrom
thibaudcolas:patch-1

Conversation

@thibaudcolas

Copy link
Copy Markdown

When files processed with smoosh (UglifyJS) are concatenated to other files, there may be a bug because of a missing semicolon at the end of the compressed output. I encountered this problem when using ded/domready's minified version, which has been created with smoosh.

  • The exact error is: TypeError: (intermediate value)(...) is not a function.
  • Here is a related SO question
  • Here is an archive of the issue in UglifyJS 1 (quite long, but very informative of the pros & cons of adding the semicolon).
  • Here is a fiddle which demonstrates the error with the smoosh output of ded/domready + some example code. The fix is also demonstrated.

The fix is directly taken from the UglifyJS source code. It has to be taken care of in smoosh's code too because smoosh directly uses the UglifyJS v1 API. In UglifyJS, the semicolon is also added after the gen_code(ast) call.

The fix is directly taken from the UglifyJS [source code](https://github.com/mishoo/UglifyJS/blob/master/bin/uglifyjs#L257). It has to be taken care of in smoosh's code too because smoosh directly uses the UglifyJS v1 API.

In UglifyJS, the semicolon is also added after the [gen_code(ast)](https://github.com/mishoo/UglifyJS/blob/master/bin/uglifyjs#L315) call.
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

Successfully merging this pull request may close these issues.

1 participant