andreruffert/syntax-highlight-element

Prismjs helpers are always loaded from default CDN, prismBaseUrl doesn't work

Closed this issue · 2 comments

Setting the prismBaseUrl doesn't seem to work, it always loads from the default (https://cdn.jsdelivr.net/npm/prismjs@1.30.0).

window.she = window.she || {};
window.she.config = {
  prismBaseUrl: 'https://unpkg.com/prismjs@1.30.0',
};

From what I can tell, the source code in this repo should work. But looking at the code in my node_modules folder, I see:

// syntax-highlight-element/dist/syntax-highlight-element.js
// Line ~8
const r = ((A = window[f]) == null ? void 0 : A.config) || {}, v = "https://cdn.jsdelivr.net/npm/prismjs@1.30.

// Line ~133
function P() {
  return new Promise((e, s) => {
    const t = document.createElement("script");
    t.src = `${v}/components/prism-core.min.js`, t.onload = e, t.onerror = s, document.head.appendChild(t);
  });
}

As you can see, P() sets the src to ${v}/components/prism-core.min.js.

But v is hardcoded to "https://cdn.jsdelivr.net/npm/prismjs@1.30.0";

Thanks, @rejhgadellaa. You are absolutely right!

The feature was recently introduced via #34 , but I haven't published a new release yet to avoid breaking changes because the API will probably change again. I'm currently thinking of ways to make loading the dependencies more flexible.

Thank you! ❤️