Search code examples
javascriptgoogle-closure-compilergoogle-closure-library

Closure goog.require. Compile error


I use Google closure library and compiler in my project.

I get strange error on next string:

if (!properties.name) {
    throw {message: 'Widget name expected'};
}
properties.name = properties.name.toLowerCase();
goog.require('DOMless.' + properties.parent);

goog.require('DOMless.' + properties.parent);
// ERROR - Syntax error in JS String literal

What is wrong?


Solution

  • goog.require is a specific instruction for the Closure compiler, which will be removed from the script.

    As it's not interpreted by the JavaScript engine, I think you simply can't use something's else than a string as argument.