Search code examples
javascriptfunctioncompiler-errorsgoogle-closure-compiler

Imported JS file - ERROR - [JSC_UNDEFINED_VARIABLE] variable Pagination is undeclared


I'm using Google Closure's advanced compiler and I get returned the following error.app.js:3:

 ERROR - [JSC_UNDEFINED_VARIABLE] variable Pagination is undeclared
  const pagination        = Pagination();
                            ^^^^^^^^^^

I'm not sure how to resolve this....

Pagination() relates to a seperate JS file I have - pagination.js - where I'm storing/importing a load of functions.

And const pagination = Pagination();, is where I'm calling/using these functions in a seperate app.js file.

How can I resolve this?

Thanks, Reena


Solution

  • Thank you @mrstack999 - User error, but I realised all I needed to do, was compile the second file also :p

    So sorry, but thank you for your help and time :)

    npx google-closure-compiler --js=app.js --js=pagination.js  --compilation_level ADVANCED_OPTIMIZATIONS --js_output_file=minified.js