requirejs / almond

A minimal AMD API implementation for use after optimized builds
Other
2.42k stars 169 forks source link

module config specified in mainConfigFile is empty during runtime #92

Closed crishushu closed 9 years ago

crishushu commented 9 years ago

Hi, I did not find anything that mentions to not use module config with almond. So I assume that the following runtime configuration referred by the build config file using 'mainConfigFile' option should work:

require.config({
    config: {
            'configurationManager': {
                fileUrl: 'config/app.json'
            }
    },
    paths: {
        'configurationManager': 'manager/settings/configurationManager'
    },
    shim: {
        'dust': {
            exports: 'window.dust'
        },
        'constants': {
            exports: 'mmir.Constants'
        }
    }
});

Unfortunately it doesn't and this is the console output of the involved variables inside the module in consideration ('configurationManager'):

module.config: {}
module.config().fileUrl = undefined 

Thanks in advance for any hints!

jrburke commented 9 years ago

module config works, there is a test for it, however, note that the requirejs.config() call needs to be included in the built file with almond. The r.js optimizer does not auto-include mainConfigFile files in the output automatically, you likely need to use include or set the file that has the config call as the name and set the main modue in include for it to work.