javascript - requirejs, is it possible to create a shim that loads deps after path -


here trying achieve.

i have primary library needs loaded several other libraries need loaded after primary library.

all secondary libraries require primary library loaded.

is there reverse of shim deps?

primarylib.js secondarylib1.js secondarylib2.js secondarylib3.js secondarylib4.js secondarylib5.js ....

i call like:

require(['primarylib'], function(){  }) 

primarylib.js should loaded first , of secondary libraries should loaded.

if use normal shim method need set each secondary library require primary lib. when want call libs need call of secondary libraries in require() call instead of single lib avoid @ costs.


edit: additional comments , context


i trying implement blueimp's file uploader.

it crying load-image dependancies.

the final config load-image files looks this.

        "load-image": {             "path": "lib\/blueimp-load-image\/load-image"         },         "load-image-exif-map": {             "path": "lib\/blueimp-load-image\/load-image-exif-map",             "shim": {                 "deps": [                     "load-image"                 ]             }         },         "load-image-exif": {             "path": "lib\/blueimp-load-image\/load-image-exif",             "shim": {                 "deps": [                     "load-image"                 ]             }         },         "load-image-ios": {             "path": "lib\/blueimp-load-image\/load-image-ios",             "shim": {                 "deps": [                     "load-image"                 ]             }         },         "load-image-meta": {             "path": "lib\/blueimp-load-image\/load-image-meta",             "shim": {                 "deps": [                     "load-image"                 ]             }         },         "load-image-orientation": {             "path": "lib\/blueimp-load-image\/load-image-orientation",             "shim": {                 "deps": [                     "load-image"                 ]             }         } 

would great if worked:

        "load-image": {             "path": "lib\/blueimp-load-image\/load-image",             "shim": {                 "post-deps": [                     "lib\/blueimp-load-image\/load-image-exif-map",                     "lib\/blueimp-load-image\/load-image-exif",                     "lib\/blueimp-load-image\/load-image-ios",                     "lib\/blueimp-load-image\/load-image-meta",                     "lib\/blueimp-load-image\/load-image-orientation"                 ]             }         } 

see how config has had done accomplish this.

why can't require have post-deps key loads post path dependencies?

there several libraries have come across causing needing loaded in fashion unnecessarily inflating config file.

when want call libs need call of secondary libraries in require() call instead of single lib avoid @ costs.

that's sort of point of library require, forces define dependencies of script couple of reasons

  • ensures lib loaded before it's used dependant module
  • provides visibility on libs particular module needs work

if understand problem correctly, don't idea of having do

require(['secondarylib1', 'secondarylib2', 'secondarylib3', ...], function(...) {     ... }); 

whenever want load libs. assuming each secondarylib requires primarylib simplest way avoid have "bootstrapper" lib loads dependant libraries e.g.

bootstrapper.js

require(['secondarylib1', 'secondarylib2', 'secondarylib3', ...], function() {}); 

main.js

require(['bootstrapper'], function() {     // libs loaded     ... }); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -