This can be reproduced by 3 simple steps.
Create a new Create React App:
npx create-react-app myApp
Install Google Closure Library:
npm install google-closure-library
Import closure library into App.js:
require('google-closure-library');
Now running the react app with npm start
we get an exception in the browser console. Uncaught SyntaxError: Identifier 'module' has already been declared
.
Trying to use goog.require(...)
or anything similar results in a compiler error stating: Failed to compile. 'goog' is not defined
. This is probably a side effect of the first error.
There seems to be a module
variable in the google closure library that does not play well with another module
variable already existing in the react app.
Is google-closure-library simply incompatible with create-react-app or what is going on here?