cap-js-community / feature-toggle-library

SAP BTP feature toggle library enables Node.js applications using the SAP Cloud Application Programming Model to maintain live-updatable feature toggles via Redis.
https://cap-js-community.github.io/feature-toggle-library/
Apache License 2.0
5 stars 2 forks source link

simplify cds-plugin export #31

Closed johannes-vogel closed 1 year ago

johannes-vogel commented 1 year ago

The plugin mechanism is able to deal with asynchronous functions. Daniel would like to get rid of the activate function in general. This PR would already prepare for it.

rlindner81 commented 1 year ago

Is this compatible with older cds versions? Otherwise this will need some version-check compatibility code.

The load_plugin of 7.2.0 does not seem to cover it: node_modules/@sap/cds/lib/plugins.js:39

    function _load_plugin (name, impl, conf) {
      plugins[name] = async() => {
        // TODO support ESM plugins.  But see cap/cds/pull/1838#issuecomment-1177200 !
        const plugin = plugins[name] = require(impl)
        if (DEBUG) log('[cds] - loaded plugin:', { impl: local(impl) })
        if (plugin.activate) await plugin.activate(conf)
      }
    }
johannes-vogel commented 1 year ago

Is this compatible with older cds versions? Otherwise this will need some version-check compatibility code.

The load_plugin of 7.2.0 does not seem to cover it: node_modules/@sap/cds/lib/plugins.js:39

    function _load_plugin (name, impl, conf) {
      plugins[name] = async() => {
        // TODO support ESM plugins.  But see cap/cds/pull/1838#issuecomment-1177200 !
        const plugin = plugins[name] = require(impl)
        if (DEBUG) log('[cds] - loaded plugin:', { impl: local(impl) })
        if (plugin.activate) await plugin.activate(conf)
      }
    }

I also double checked and came to the same conclusion.

rlindner81 commented 1 year ago

superseded by #32