executablebooks / sphinx-tabs

Tabbed views for Sphinx
https://sphinx-tabs.readthedocs.io
MIT License
264 stars 68 forks source link

Uncaught TypeError: exports is undefined #128

Closed Martiix closed 3 years ago

Martiix commented 3 years ago

Describe the bug

I am using sphinx tabs in a sphinx project and it works nicely.

However in the network tab under "inspect element" in the browser I see the following error: image image

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://support.zivid.com/latest/rst/reference-articles/zivid-3d-camera-technology/calculate-3d-capture-speed.html
  2. Right click and press inspect
  3. Open the network tab
  4. Refresh page
  5. See error

Atm these can be displayed on the website on this url: https://support.zivid.com/latest/rst/reference-articles/zivid-3d-camera-technology/calculate-3d-capture-speed.html or https://support.zivid.com/latest/rst/academy/samples.html remember to reload the page while the network tab is open to reproduce.

It also appears when building the documentation using localhost with the auto-build expansion

Expected behavior

No errors, like corresponding pages without tabs: image

Actual behavior:

image

Environment

Additional context

Nothing

welcome[bot] commented 3 years ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

foster999 commented 3 years ago

Thanks for raising this! 😊

The export statements aren't required for functionality (the tabs still work) and are only there to allow us to unit test the functions.

That said, it's not ideal that this is creating errors on every site. My JS knowledge isn't great, so would be grateful for any advice on this one. I believe that it's because we've used common JS syntax that the browser doesn't support, so might require using a different export/import syntax for our tests.

TheTripleV commented 3 years ago

Would including

if (typeof exports === 'undefined') {
    exports = {};
}

above those lines be an acceptable workaround?

foster999 commented 3 years ago

Thanks @TheTripleV, that looks ideal 😊

Would you like to add it through a PR? If not, I'm happy to add it when I get a moment.