Closed webpro closed 9 years ago
This completely confuses curl it seems.
Can you elaborate? This feature works fine in my tests.
curl.config({ packages: [{ name: 'bar', location: 'foo', main: 'core', config: {foo:1} }] });
//... later, in a module in the bar package:
var cfg = module.config ? module.config() : {};
var foo = cfg.foo;
A bit time-consuming to set up a proper test case, but I will if needed.
If I put a config
property like you did, and after this I'm doing another call to curl.config()
(also containing packages
), then that second config is not applied. If I combine the configs into one call, it works fine.
Interesting. That's the opposite of what I would have expected. As a work-around until I test this, you could try something like the following if there is only one module that needs module.config()
(curl 0.8 or higher):
curl.config({
paths: {
'core/module-that-needs-config': { location: 'core/module-that-needs-config', config: { foo: 1 } }
}
});
Thanks for the work-around, that works fine. Obviously I'm interested in a possible fix.
Yes. Let's keep this issue open until I have a chance to look into the problem further. :)
I've been grappling with similar:
Specifically, curl package will not use paths:{} not defined in the original config object.
This, taken from my bootstrapping config.js.config.js has no effect:
{
name: 'MyPkg',
location: 'path/to/templates',
main: 'js/my-package.source',
// config options specific to MyPkg
config: {
paths: {
foo: 'path/to/foo',
bootstrap: 'sample/path/to/bootstrap.js'
}
}
}
...and doing this in the above package module throws error (see below)
curl.config({
paths: {
bootstrap: 'path/to/bower_components/bootstrap-sass-official/assets/javascripts/bootstrap.js'
}
});
define(['firstPkg', 'some/js/module.source', 'js!bootstrap'], function(exposure1, exposure2) {
// sidenote: module property is not available here in a package 'module'?
return exposure1;
});
Error thrown:
// adds the path matching regexp onto the cfg or plugin cfgs.
function convertPathMatcher (cfg) {
var pathMap = cfg.pathMap;
cfg.pathRx = new RegExp('^(' +
cfg.pathList.sort(function (a, b) { return pathMap[b].specificity - pathMap[a].specificity; } )
X Uncaught TypeError: Cannot read property 'specificity' of undefined
.join('|')
.replace(/\/|\./g, '\\$&') +
')(?=\\/|$)'
);
delete cfg.pathList;
}
To be clear, defining the 'bootstrap' path in the paths hash of the mentioned bootstrapping config.js works fine.
Hey @CNSKnight,
I think it's highly unlikely that curl will offer per-package paths
and packages
configuration as you've shown. When implementing the per-package configuration feature, we realized that the complexity of curl's internals would increase significantly. Of course, we could refactor and/or rewrite curl's internals, but that would take some time.
At the moment, we're spending most of our module-focused efforts on rave. Rave already handles per-package mappings automatically (without configuration).
Yes, rave is still under development, but it sounds like you have a work-around that you can use for now?
I'm going to close this issue, but please keep posting if you need additional help on your work-around.
Regards,
-- John
Gotit. Meantime, let's update the docs to to that effect. Still makes it challenging to do tru drop-in modular development but I'll work w/what we got & wait a bit on your rave effort.
Best
How can I add module-specific configuration with curl? E.g.
packages: [{ name: 'bar', location: 'foo', main: 'core', config: {foo:1} }]
.This completely confuses curl it seems. The "proposed standard" way also doesn't seem to work (https://github.com/amdjs/amdjs-api/wiki/Common-Config#config-).
I can request
module.config()
in a module, yet I don't know how to add data in the main config.