-
|
Got this error from the minified code from the main Docusourus bundle. 3310: (e,t,n)=>{
"use strict";
n.r(t);
var r = n(2573)
, a = n(6809);
!function(e) {
const {themeConfig: {prism: t}} = a.default
, {additionalLanguages: r} = t;
globalThis.Prism = e,
r.forEach((e=>{
"php" === e && n(6854),
n(4280)(`./prism-${e}`)
}
)),
delete globalThis.Prism
}(r.p1)
}Note that I use PrismJS on my own and I need to be global, I'm not sure why there is an error. I have this script tag loaded with the Helmet: Here is DevBox: https://codesandbox.io/p/devbox/lucid-lake-gjnj4q?file=%2Fsrc%2Fpages%2Findex.tsx%3A37%2C47 The error is in the browser console, it's not visible on the output page. EDIT: If I remove this code before build: sed -i '/delete globalThis.Prism/d' node_modules/@docusaurus/theme-classic/lib/theme/prism-include-languages.jsGot this errors in console:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I don't know why you need that, but I wouldn't recommend this and I can't guarantee this will work well. If you want to keep loading 2 competing versions of Prism on the same site, you have to figure out how yourself unfortunately |
Beta Was this translation helpful? Give feedback.
-
|
Hello, you can totally achieve this via swizzling. You would eject |
Beta Was this translation helpful? Give feedback.
Hello, you can totally achieve this via swizzling. You would eject
prism-include-languagesand delete the line where it saysdelete globalThis.Prism. Alternatively, thePrismglobal object is imported fromimport {Prism} from 'prism-react-renderer';(see here: https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-theme-classic/src/prism-include-languages.ts), so in your own script, you could also import that instance and doglobalThis.Prism = Prism;and it will work :) Alternatively, if you only depend onPrismbeing global for some time but not always (for example, you are loading another component or plugin), you can put your logic directly inside the ejectedprism-includ…