Externes JS-Bibliothek global für alle Plugins und Themes (Komponenten) hinzufügen

Situation

We want to add this external logging JS lib to our Discourse Instance to improve the debugging workflow by using this lightweight logging wrapper that allows us for example setting up a logLevel via log.setLevel('debug').

This external lib should be available throughout all our custom plugins, Theme and Theme Components we have installed on our App.

Implementation

• Would importing the JS via register_asset in various Plugins import the JS file multiple times?
• Is there an alternative JS lib with similar functionality after Ember deprecated its logging utility in favor of console.log

We currently went down following road to implement it.

  1. Install Plugin which imports external JS and make JS lib available via window object (`window.log = log’)
    • Import JS lib only once imported
    • Other plugins/Theme/Theme Components would depend on that Plugin and things like open source plugins would force users to install both plugins

Does this make sense or would you suggest a different approach?

Das wirkt für mich sehr entkoppelt… Warum nicht ein eigenständiges Plugin oder eine Komponente erstellen, die dies einführt, und dann einfach sicherstellen, dass du es immer installierst?

2 „Gefällt mir“

Ja, das war tatsächlich die Lösung, die ich erwähnt habe, die wir derzeit nutzen. Es gibt ein Plugin, das das JavaScript importiert, und andere Plugins, die es verwenden, sind davon abhängig, dass dieses Plugin installiert ist.

Danke für deine Antwort!

2 „Gefällt mir“