Reputation: 115
I am trying to feature flag ckeditor by changing the path dynamically. It is originally set but if a flag is turned on I try to change it. When I do not change the path, the shim works fine and ckeditor is resolved. When I do change the path after checking the flag, ckeditor is undefined.
config.js
require.config({
paths: {
...
ckeditor_core: 'lib/ckeditor/ckeditor',
...
},
shim: {
...
ckeditor_core: {
exports: 'CKEDITOR'
},
...
}
});
if (jx && jx.activeFeatures && !jx.activeFeatures.CKEDITOR_4) {
require.config({
map : {
'*' : {
'ckeditor_core' : ''lib/ckeditor-old/ckeditor''
}
});
}
}
define({});
I have tried making this change to the map in a few different places but I am always getting this same issue:
TypeError: ckeditor is undefined
To me it seems like the shim is broken after I set the path again. While I am in the console I am able to resolve CKEDITOR just fine.
Thank you for the help!
Upvotes: 0
Views: 140
Reputation: 151511
This is the map
configuration you use:
map: {
'*': {
'ckeditor_core': 'lib/ckeditor-old/ckeditor'
}
}
When this map is in effect and RequireJS encounters a request for the module ckeditor_core
, the first thing it does is replace this request with a request for lib/ckeditor-old/ckeditor
. Then RequireJS checks for a shim. Since lib/ckeditor-old/ckeditor
has no shim defined for it, but this is a module which needs a shim, then the value of the module is undefined
. What you need to do is add a shim for it:
'lib/ckeditor-old/ckeditor': {
exports: 'CKEDITOR'
},
Upvotes: 1