1

I'm trying to send configuration parameters into my package's main.js file and it doesn't seem to be working. What am I doing wrong? Here's the files and path information

/config.js

require.config({
    baseUrl : '../src',
    config : {
        'AAM' : {
            get : null,
            set : null
        }
    },
    packages : [ 'AAM']
});

/src/AAM/main.js

require.config({
    paths : {
        AAMAsPermission : 'AAM/perms/asPermission'
    }
});

// Start the main app logic.
requirejs(['AAMAsPermission'], function(AAMAsPermission) {

});

/src/AAM/perms/asPermission

define(['module'], function(module) {
    module.config() // empty object.  Why?
    ....
});

In /src/AAM/perms/asPermission, the object returned from module.config() is empty. Why?

frio80
  • 1,293
  • 3
  • 14
  • 23

1 Answers1

2

According to the documentation:

For passing config to a package, target the main module in the package, not the package ID:

So you should configure it like this:

require.config({
    baseUrl : '../src',
    config : {
        // target the module, not the package
        'AAM/perms/asPermission' : {
            get : null,
            set : null
        }
    },
    packages : [ 'AAM']
});

If that doesn't meet your needs, you might also try a separate global module for holding the singleton: Using RequireJS, how do I pass in global objects or singletons around?

Community
  • 1
  • 1
explunit
  • 18,967
  • 6
  • 69
  • 94