google/closure-compiler

require with a substitution-free template string is not recognized by process_common_js_modules

Open

#2.626 geöffnet am 21. Aug. 2017

Auf GitHub ansehen
 (4 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Java (1.197 Forks)batch import
P2help wanted

Repository-Metriken

Stars
 (7.176 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 3T 4h) (1 gemergte PR in 30 T)

Beschreibung

I'm using the compiler with the process_common_js option set to true.

The following code works fine:

/** @const */
const update = require( "./update.js" );

However, switching to a substitution-free template string breaks:

/** @const */
const update = require( `./update.js` );

resulting in:

src/main.js:8: ERROR - variable require is undeclared
const update = require( `./update.js` );
               ^^^^^^^

The code style of the project I'm working on imposes template strings wherever syntactically possible (only object keys get a pass and can use double quotes). Of course, this does include paths in require statements. Sadly, it seems the CommonJS machinery does not recognize such statements as processable.

As a workaround, I can break from the code style but it is clearly not ideal and it would be really nice if the compiler was able to handle this.

Contributor Guide