I have an existing angularJS app that uses RequireJS as a module loader. All is working fine but I am trying to use the optimizer and having an issue, the first module is not being called!
this is my main.js
define(['lib/IE/isIE', 'lib/IE/isIE8', 'lib/IE/isIE9', 'lib/IE/isIE11', 'util/array', 'util/string', 'util/object', 'util/date'], function (isIE, isIE8, isIE9, isIE11) {
...
if (isIE) {
require(['xdomain', 'xhook'], init);
} else {
init({ slaves: function () { } });
}
}
and in the html:
<script data-main="main" data-handle-routes="true" data-html-target="document" src="~/Content/App/lib/requirejs.min.js"></script>
I changed it to (added .min) to use the optimizer:
<script data-main="main.min" data-handle-routes="true" data-html-target="document" src="~/Content/App/lib/requirejs.min.js"></script>
When running the website with the main.min I get the following error:
requirejs.min.js:203 Uncaught Error: No define call for main.min
http://requirejs.org/docs/errors.html#nodefine
at C (requirejs.min.js:203)
at Object.completeLoad (requirejs.min.js:296)
at HTMLScriptElement.onScriptLoad (requirejs.min.js:302)
Looking at the main.min.js file I can see that the module has the following definition:
define('main',['lib/IE/isIE', 'lib/IE/isIE8', 'lib/IE/isIE9', 'lib/IE/isIE11', 'util/array', 'util/string', 'util/object', 'util/date'], function (isIE, isIE8, isIE9, isIE11) {
...
}
So, the module has the 'main' ID. if I replace manually that ID to 'main.min' the application will run.
Any idea how I can change the ID? Is this possible to achieve it by changing the build.js?
question from:
https://stackoverflow.com/questions/65884791/main-module-not-beling-called-when-using-requirejs-optimizer