-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Notebooks 5.x breaks widget calls #2977
Comments
I would guess it's more likely to be down to the require version - requirejs is after all supposed to add |
Unfortunately, I am not an expert in this area @jcb91. Below is what it currently looks like:
|
Ok, I can't say I'm an expert either really 😂 but the thing that stands out for me from the config you've posted is the proxying stuff - do you know whether you're actually going through a proxy? I suspect this SO question is relevant, it seems to be an issue regarding using the text plugin with cross-domain requests... |
Ps, if it's the requirejs text plugin, newer versions of notebook already bundle it (and moment had been included for some time), so you could skip loading from the CDN/nbextension path altogether |
We are not going through a proxy. |
Well, without a minimal working example, my current best guess is:
What version of requirejs/text are you providing? Have you set any config for it? |
We're providing RequireJS text 2.0.12. The config is what Bill had shared above. |
A minimal working example is attached. Your assessment above ("your config will get ignored") is spot on... from our debugging it seems that the require config for 'text' isn't being used - onXhr is never called. How can we work around this issue? Thanks for your help with this. |
Thanks @rohitgeo for that example. So, the simple way that I can get this to work is by just removing all of the requirejs text config along with the dojo/text mapping, so essentially just by using dojo/text as dojo & dijit expect. The config call then looks like: require.config({
// Define path mappings for modules
paths: {
// [1] Modules hosted on Esri CDN.
"dojo": esriCDN + "dojo",
"dojox": esriCDN + "dojox",
"dijit": esriCDN + "dijit",
"esri": esriCDN + "esri",
"dgrid": esriCDN + "dgrid",
"xstyle": esriCDN + "xstyle",
"put-selector": esriCDN + "put-selector",
"moment": esriCDN + "moment",
},
urlArgs: "client=gsrs",
}); Was there a pressing reason that you wanted to use requirejs text instead of dojo's? I tried removing your moment path-config, in favour of using notebook's builtin moment, but it appears some of your other cdn-hosted stuff is relying on finding things at |
As far as I can tell, the text plugin only reads its config once, at load time (it assumes all config-setting will be done before it's loaded - see text.js#L22). The only halfway-reasonable way I can think of to get around this is to undefine the module before loading it again to get the new config applied - see this SO answer for details on reloading modules. This would then give something like require.config({
// my new config here
});
// unload the text plugin module
require.undef('text');
// now text should get loaded again by the next require call that asks for it:
require(['text!some/resource/wanted/here.html'], function (txt) {
console.log('do something with', txt);
}); |
Thank you @jcb91 for this fix of simplifying the require config. I believe we were using our version of requirejs/text as there's a small tweak we've done to it. However, it might have been for handling some niche case that I'm not aware of. I'd be more than happy to use this simpler require configuration. Thank you so much for your help! Another thing I tried was to change "text" to "mytext", and it works! |
No problem, glad there's a suitable solution for you :)
I'm not sure what you mean by this, which "text" did you change? And why did you use "mytext" for that matter, is that just arbitrary, to avoid colliding with the existing "text"? |
Hmmm... perhaps I spoke too soon. I just tried replacing the require config with the simple version you had but it's still not working for me. I'm wondering how it works for you. I used notebook v 5.2.1. Please see the attachment below. I replaced text to mytext (arbitrary name) to avoid colliding with the existing text. This is what I used as my require config:
|
Unfortunately, on that one, your guess is as good as mine for now! I always clear all outputs, save the notebook, reset the kernel & refresh the page after changing things, just to ensure nothing's stale. You can find the version that's worked for me in this gist...
Ah, I see, to keep a custom mapping to another arbitrarily-named version of text, good idea! edit: I'm also on Jupyter 5.2.1, with ipywidgets 7.0.0 |
We have developed our own custom widget that displays a map inside of a Jupyter Notebook. As part of that widget development, we use require.js for a few things. Prior to Notebooks 5.x, this has worked as expected. However, with Notebooks 5.1/5.2, we are now seeing poorly formed calls. For example, require.js used to make a call like the following:
http://js.arcgis.com/3.17amd/dijit/form/templates/TextBox.html?client=gsrs
And this works. However, with no changes in our Notebook widget call, the call now looks like:
http://js.arcgis.com/3.17amd/dijit/form/templates/TextBox.html.js?client=gsrs
It has appended a
.js
to the path. Has anyone seen this before? Can any suggest why this might be happening with the newer Notebook versions?The text was updated successfully, but these errors were encountered: