I am using “define” in my project. My js code woks when I don’t use the optimzer. When I run the optimizer all files are included se below
require(["jquery", "modals", "registermodule", "bootstrap", "personsmodule", "datemodule", "./jquery-ui-1.8.18.custom.min"], function($) {});
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/main-built.js
----------------
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/jquery.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/modals.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/ajaxmodule.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/jquery-ui-1.8.18.custom.min.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/datemodule.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/validationmodule.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/guimodule.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/registration_util.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/registermodule.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/bootstrap.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/tablesort.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/personsmodule.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/main.js
When I load my page with the uglified script i get datepicker not defined. How can this happend when the file is included here jquery-ui-1.8.18.custom.min.js?
Problem is that jquery-ui-1.8.18.custom.min.js isn’t AMD module.
Solution 1: Wrap code of jquery-ui to AMD module
Solution 2: remove dependency in your code and include it manually.
There is other solutions how to work with non-AMD dependencies but I don’t know how optimizer will work in that cases.