FormidableLabs / spectacle

A React-based library for creating sleek presentations using JSX syntax that gives you the ability to live demo your code.
https://commerce.nearform.com/open-source/spectacle/
MIT License
9.76k stars 692 forks source link

Highlight.js throwing `global is not defined` error via `core.js` #1045

Open mikestopcontinues opened 3 years ago

mikestopcontinues commented 3 years ago

Describe Your Environment

What version of Spectacle are you using? 8.3.0 What version of React are you using? 17.0.13 What browser are you using? Chrome (up to date) What machine are you on? Mac

Describe the Problem

I'm trying to bundle a set of similar slide decks for the web using Vite (for guests to visit later, to download references, etc). But I've hit the following error:

core.js:221 Uncaught ReferenceError: global is not defined
    at capture (core.js:221)
    at node_modules/refractor/core.js (core.js:5)
    at __require (chunk-4YJPEX7N.js?v=66018443:9)
    at hljs.js:891

As you can see, it's core.js, called via highlight.js. If you run the app without importing spectacle (e.g. plain react), it works fine.

Here's the test repo: https://github.com/mikestopcontinues/slides

Expected behavior: I should work. Actual behavior: It doesn't work. ;)

Additional Information

Because syntax highlighting takes up so much darn space in the repo, I think it should be offered as a separate install anyway.

gksander commented 2 years ago

Tracking via #1118