google / google/closure-compiler

Add option to disable string array literal peephole optimization

Open
#2,953 3 comments 1 reaction 0 assignees View on GitHub
internal-issue-created triage-done
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

This was initially posted [to mailing list](https://groups.google.com/forum/#!topic/closure-compiler-discuss/NAJEIwckYeE), but no one replied, so here is the feature request.

I have AMD module with following line:

```javascript
define(['@detox/crypto', '@detox/dht', '@detox/utils', 'ronion', 'fixed-size-multiplexer', 'async-eventer', 'pako'], Wrapper)
```

The issue is that starting with 6th depedency Closure Compiler in advanced mode decides that it is a good idea to replace that array with splitted string like this:

```javascript
define("@detox/crypto @detox/dht @detox/utils ronion fixed-size-multiplexer async-eventer pako".split(" "),A)
```

Which makes sense in general, but fails when I try to use minified result with https://github.com/requirejs/r.js, which doesn't understand such construction and requires explicit array of dependencies.

It would be very useful to have an option to disable this particular optimization in advanced mode.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.