Closed reidlai closed 10 years ago
Any reason you choose to use packages
instead of paths
in the RequireJS config? The packages is designed to be used to load CommonJS Packages but you seems to use it to load plain RequireJS files?
The documentation does not mention shim
under packages
so I wonder if it is supported.
Macro,
Thx, it works now. I just guessed there is no difference. Anyway, thanks for your help
Cheers
I have create a file called RequireJSConfig.js like below:
requirejs.config({ baseUrl: ".", packages: [ {"name": "app", "location": "app", "main": "app"}, {"name": "angular", "location": "bower_components/angular", "main": "angular"}, {"name": "angularAMD", "location": "bower_components/angularAMD", "main": "angularAMD"} ], shim: { 'angularAMD': ['angular'] }, deps: ["app/app.js"] });
And load it using script tag in head of my index.html
when the my page is loading RequireJSConfig.js, it complains that cannot find angular. My app/app.js show as below:
/* Error message: Uncaught ReferenceError: angular is not defined */ define(["angularAMD"], function(angularAMD) { var app = angular.module("AppStartup", []); console.log("App loaded"); return angularAMD.bootstrap(app); });
/* The following works fine */ define(["angularAMD", "angular"], function(angularAMD) { var app = angular.module("AppStartup", []); console.log("App loaded"); return angularAMD.bootstrap(app); });
If i add angular in module array, everyting works fine. Does it mean shim doesn't load module dependency? Thanks for your advice