Skip to content

Add the ability to fully specify CDNs for loaded libraries #3251

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

Closed
wants to merge 2 commits into from

Conversation

bsyouness
Copy link
Contributor

@bsyouness bsyouness commented Aug 10, 2021

This PR adds the ability to pass full URLs to resolve modules that we're loading in.

TODO: add documentation to say how to use the feature, e.g. add in html: <script data-jupyter-widgets-module-cdn="bqplot, XXX/share/jupyter/nbextensions/bqplot/index.js"></script>

TODO: figure out if we want to read data-jupyter-widgets-module-cdn first and if it can't be resolved check if the module is present locally (right now it does the opposite, i.e. checks if the module is present in the current directory first)

@bsyouness
Copy link
Contributor Author

@jasongrout FYI

@jasongrout jasongrout added this to the 8.0 milestone Aug 19, 2021
@jasongrout
Copy link
Member

Note: backport this to 7.x after merging.

@jasongrout
Copy link
Member

jasongrout commented Aug 20, 2021

I've been thinking about this, and reminding myself how requirejs works (which is what is used in the html manager).

Would it be enough to just give a requirejs config on the page instead of having this extra script parameter? It looks like we first try to use requirejs to load the module as-is, so presumably we could define this mapping of module to location as a requirejs map. The CDN is only used as a fallback (unless the cdn-only option is used, of course).

As a bonus, perhaps we could make an example that shows how to use the existing requirejs maps for installed nbextensions (which are providing amd modules for various custom widget libraries).

For example, for bqplot, if we wanted to load a locally-installed nbextension for it, we might be able to just either require nbextensions/bqplot/extension (which sets up the require config), or just manually specify the equivalent code manually:

window.require&&window.require.config({map:{"*":{bqplot:"nbextensions/bqplot/index"}}})

If we didn't want a locally-loaded version, we could just give a different URL to load than nbextensions/bqplot/index, perhaps our favorite CDN.

@jasongrout
Copy link
Member

Slightly related: jupyter-widgets/widget-cookiecutter#99 - examining the cookiecutter's hardcoding of CDN URLs.

@jasongrout jasongrout removed this from the 8.0 milestone Sep 17, 2021
@jasongrout
Copy link
Member

In practice, we found that setting the requirejs map as in #3251 (comment) was sufficient to accomplish the goals pursued here, so I'll close this.

@jasongrout jasongrout closed this Feb 9, 2022
@jasongrout
Copy link
Member

(Please correct me if I'm misremembering, @bsyouness...)

@bsyouness bsyouness deleted the modulescdn branch February 9, 2022 15:57
@bsyouness
Copy link
Contributor Author

I think that's right. @mnowacki-b FYI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants