How To: Enable the Extension at the Entry Point¶
PWAjet can include extensions that:
- subscribe to events;
- register additional blocks/screens/language variables, etc.;
- embed themselves in component render;
- and other.
Upgrade Without Rebuilding¶
The application can change some parts of the code using any convenient and accessible tool. The key point is requirements. To connect an extension to the application, you need:
(1) In index.html, add objects that describe the connection point of the add-on to the following array:
window.pwajet.extensions = [
/*extensions*/
{ src: '/public/path/assets/extensions/vendor/module/js/module-enry.js'}
];
If the add-on consists of several files, the array must contain all the files required to initialize it.
Important
Do not specify dynamically loaded files here.
- In
service-worker.js
inprecacheManifest
, add objects in the form:
{'revision':'063fb803d113f1dcdbb3540a4bf6f15d','url':'/public/path/assets/extensions/vendor/module/js/module-enry.js'}
Note
All scripts and styles related to the extension must be specified here.
It is highly recommended to load the rest of the code only when needed using dynamic imports and lazy load.
Registration of ESM¶
To use up-to-date ESM instead of window.pwajet.extensions
, use esmExtensions
:
window.pwajet.esmExtensions = [
'/public/path/assets/extensions/vendor/module/js/module.js'
];
Note
The esmExtensions structure differs from extensions
. Firstly, you need to register not entry points, but specific subprograms (refer to the examples). And secondly, the array elements are strings with the extension address.
It is highly recommended to load the rest of the code only when needed using dynamic imports and lazy load.