Skip to content
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

require.js must be loaded into the page for many custom outputs to be displayed. #284

Open
moorepants opened this issue Oct 20, 2020 · 5 comments

Comments

@moorepants
Copy link
Collaborator

Describe the bug

We've seen in several of the new examples added that adding the javascript library require.js is necessary for the custom javascript outputs to display (#283, #262, #269, #265). We've been adding:

<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>

before loading thebe. Maybe thebe should load this by default, so users don't need to.

I'm not sure why this is needed and whether this version of require.js can work with all libraries that display custom js outputs. I guess this is something that Jupyter Notebook or Jupyter Lab would have loaded already.

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

See the examples linked above.

Expected behavior

A clear and concise description of what you expected to happen.

A link to your documentation repository.

If relevant, a minimal example of the input text should be supplied,
together with a screen-shot of the output document and/or command-line output, e.g.

some text...
$ jupyter-book build mybook
ERROR ...

Environment

  • Python Version [e.g. 3.7.1]:
  • Package versions or output of jupyter-book --version:
  • Operating System:

Additional context

Add any other context about the problem here.

@moorepants moorepants added the bug label Oct 20, 2020
@choldgraf
Copy link
Collaborator

Yep - this is totally a product of the specific visualization libraries that one happens to be using. I think many packages in the jupyter ecosystem use require.js because it is available by default in JupyterLab/Notebook. Automatically loading require.js in thebe feels a bit hacky to me, as it's basically just special-casing a few libraries that happen to be common.

One approach we could take is to clearly document this as well as provide instructions for how people could include a few common packages on their own. Another approach is we could add configuration for some common ones. I don't think we should load them by default though, since it's not strictly necessary and folks may be loading require.js from other packages etc.

@choldgraf choldgraf added enhancement and removed bug labels Oct 20, 2020
@moorepants
Copy link
Collaborator Author

Automatically loading require.js in thebe feels a bit hacky to me, as it's basically just special-casing a few libraries that happen to be common.

But shouldn't thebe mimic what is available in Juptyer Notebook/Lab? I think we should expect the same behavior. It seems more hacky to have to paste JS code Jupyter provides by default.

@moorepants
Copy link
Collaborator Author

special-casing a few libraries that happen to be common.

Also, is this the case. Or do all libraries that display custom JS outputs for Jupyter utilize require.js?

@choldgraf
Copy link
Collaborator

But shouldn't thebe mimic what is available in Juptyer Notebook/Lab

That's a good question - if we can say "yes" to this, then I'd be fine loading those libraries by default. I'm curious what @minrk thinks about this? Basically say "thebe will ship with whatever javascript libraries also exist in JupyterLab".

Or do all libraries that display custom JS outputs for Jupyter utilize require.js?

I am not sure :-/ perhaps folks in the JupyterLab world will know?

@minrk
Copy link
Collaborator

minrk commented Oct 28, 2020

I'd ask JupyterLab folks what they think is best - bundle require.js or suggest/document that it may be needed in certain contexts. I'm not sure.

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

No branches or pull requests

3 participants