@diosmosis opened this Pull Request on March 22nd 2022 Member

Description:

This PR provides on demand loading of a plugin's Vue module, so it does not have to be loaded on each page load.

To set a plugin's Vue module to be loaded on demand you'd have to:

  • override Plugin::shouldLoadUmdOnDemand() and return true
  • if the plugin defines angularjs adapters, move them all to a separate file manually included via the AssetManager event and set the component property to a reference like { plugin: 'MyPluginName', component: 'MyComponentName' }.

If you need to use a plugin that's loaded like this in another plugin, you won't be able to import as you would normally. Instead you'll need to use the importPluginUmd method:

import { importPluginUmd } from 'CoreHome';

importPluginUmd('TagManager').then((module: typeof import('TagManager')) => {
  // ...
});

Note: that adapters for stores or anything that gets added via angular(...).adapter will not be available, so making a plugin load on demand is a potential BC break. For TagManager this is acceptable since the old models weren't meant to be reused.

To see a plugin that uses this, see: https://github.com/matomo-org/tag-manager/pull/461

Review

@diosmosis commented on March 22nd 2022 Member

Adding this to the current milestone, but I'm not sure when it is desired to include it.

@github-actions[bot] commented on April 14th 2022 Contributor

This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers

Powered by GitHub Issue Mirror