diff --git a/package.json b/package.json index 7ae4b42..cb1796f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pico-api-docs", - "version": "1.6.0", + "version": "1.6.1", "description": "PICO SulTeng API Documentation - COVID-19 Sulawesi Tengah Data API", "main": "index.js", "scripts": { diff --git a/src/lib/prism-global.ts b/src/lib/prism-global.ts new file mode 100644 index 0000000..93d0aa2 --- /dev/null +++ b/src/lib/prism-global.ts @@ -0,0 +1,8 @@ +import Prism from 'prismjs' + +// The language grammars in prismjs/components call a global `Prism`. Publish it in its own +// module so it exists before any grammar loads. The bundler does not guarantee that order +// for a side-effect import, and the production build failed with "Prism is not defined". +;(globalThis as { Prism?: typeof Prism }).Prism = Prism + +export default Prism diff --git a/src/lib/prism-setup.ts b/src/lib/prism-setup.ts index a42ce7f..89819f7 100644 --- a/src/lib/prism-setup.ts +++ b/src/lib/prism-setup.ts @@ -1,7 +1,7 @@ -import Prism from 'prismjs' +import Prism from './prism-global' // Grammars register on the Prism singleton, so they must live in this one file -// (and one chunk) with the core. Only the languages the docs show are loaded. +// (and one chunk) with the core. prism-global publishes window.Prism first. Only the languages the docs show are loaded. import 'prismjs/components/prism-bash' import 'prismjs/components/prism-json' import 'prismjs/components/prism-python'