RequireJS module attempts to load shim'ed module -


i'm having issue attempting create requirejs shim javascript code written team in organization. script loaded via noraml html script such:

<script src="mycustommodule.js" type="text/javascript"></script> 

my main.js contains following:

requirejs.config({     paths: { 'text': 'durandal/amd/text' },     shim: {         'mycustommodule': { exports: 'my.custom.module' }     } }); 

and have tried accessing custom module in variety of ways, current code:

define(['mycustommodule'], function (require, mycustommodule) {  ... } 

but each time page/app loads error requirejs indicating failed load app/mycustommodule.js (and can see 404 error in console attempted request file server). doing wrong?

you need include mycustommodule in paths:

requirejs.config({     paths: {         'text': 'durandal/amd/text'         'mycustommodule': 'path/to/mycustommodule'     },     shim: {         'mycustommodule': {             exports: 'my.custom.module'         }     } }); 

if don't that, define(['mycustommodule'] (...) dependency in baseurl location, in case: app/mycustommodule.


in other words: shim can't "pick up" global variables not loaded requirejs.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -