Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ See docs/process.md for more on how version tagging works.
3.1.46 (in development)
-----------------------
- libunwind updated to LLVM 16.0.6. (#20088)
- The `--minify=0` commnad line flag will now preserve comments as well as
whitespace. This means the resulting output can then be run though closure
compiler or some other tool that gives comments semantic meaning. (#20121)

3.1.45 - 08/23/23
-----------------
Expand Down
20 changes: 20 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -13705,3 +13705,23 @@ def test_memory64_proxies(self):
'-Wno-experimental',
'--extern-post-js', test_file('other/test_memory64_proxies.js')])
self.run_js('a.out.js')

def test_no_minify(self):
# Test that comments are preserved with `--minify=0` is used, even in `-Oz` builds.
# This allows the output of emscripten to be run through the closure compiler as
# as a seperate build step.
create_file('pre.js', '''
/**
* This comment should be preserved
*/
console.log('hello');
''')
comment = 'This comment should be preserved'

self.run_process([EMCC, test_file('hello_world.c'), '--pre-js=pre.js', '-Oz'])
content = read_file('a.out.js')
self.assertNotContained(comment, content)

self.run_process([EMCC, test_file('hello_world.c'), '--pre-js=pre.js', '-Oz', '--minify=0'])
content = read_file('a.out.js')
self.assertContained(comment, content)
2 changes: 1 addition & 1 deletion tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def acorn_optimizer(filename, passes, extra_info=None, return_output=False):
cmd = config.NODE_JS + [optimizer, filename] + passes
# Keep JS code comments intact through the acorn optimization pass so that JSDoc comments
# will be carried over to a later Closure run.
if settings.USE_CLOSURE_COMPILER:
if settings.USE_CLOSURE_COMPILER or not settings.MINIFY_WHITESPACE:
cmd += ['--closureFriendly']
if settings.EXPORT_ES6:
cmd += ['--exportES6']
Expand Down