andreruffert/syntax-highlight-element

Language config requires defaults, no duplicates (incl aliases)

Closed this issue · 2 comments

I ran into some issues when I tried to configure the languages config:

The following configs cause errors, which breaks the element:

// set languages to 'jsx' and 'javascript'
window.she = window.she || {};
window.she.config = {
  languages: ['jsx', 'javascript'],
};
// add 'html' (which is the same as 'markup')
window.she = window.she || {};
window.she.config = {
  languages: ['markup', 'css', 'javascript', 'html'],
};

It works if I...

  • always supply the defaults first, then append additional languages
  • map language aliases and remove duplicates (html => markup)
window.she = window.she || {};
window.she.config = {
  languages: ['markup', 'css', 'javascript', 'jsx'],
};

@rejhgadellaa thanks for your time and investigation!

There was indeed a bug in the language dependency resolution not including transitive dependencies.
I published a new prerelease version 1.2.0-beta.0 which includes a bugfix. Additionally the new version introduces support to resolve language aliases and deduplication.

Please let me know if the new version fixes your described issues.
You can install the prerelease via npm install syntax-highlight-element@next.

Thanks!

✌️