meteor/itgenio:live-modules
Load your code dynamically from any source.
Features
- Real-time updating modules' settings
- Enable/disable modules
- Update the version of module
- Work in Dev and Prod modes
- Import modules only with specific tags
- importTimeoutto control imports time
- Caching with IndexedDB [In progress]
- JS & CSS executing
Configuration via settings
1{ 2 "public": { 3 "liveModules": { 4 "collName": "meteor_itgenio_live-modules", 5 "subName": "itgenio.live-modules", 6 "logging": true, 7 "importTimeout": 5000 8 } 9 } 10}
Client API
1type ImportOptions = { 2 importTimeout?: number; 3}; 4 5interface LiveModules { 6 /* 7 * Is subscribtion ready? 8 */ 9 subReady(): Promise<void>; 10 11 /* 12 * Import module by name or tag 13 */ 14 importModule(tagOrName: string, opts?: ImportOptions): Promise<void>; 15 16 /* 17 * Import modules by names or tags 18 */ 19 importModules(tagsOrNames?: string[], opts?: ImportOptions): Promise<void>; 20}
Use cases
Import by tag on startup
1import { LiveModules } from 'meteor/itgenio:live-modules'; 2 3Meteor.startup(async () => { 4 //... 5 6 // 7 // Import all modules with tag `startup` 8 // 9 try { 10 await LiveModules.importModules(['startup']); 11 } catch (e) { 12 console.error(e); 13 } 14 //... 15});
Import by name in specific page
1import { LiveModules } from 'meteor/itgenio:live-modules'; 2 3const lazy = () => LiveModules.importModule('my-lazy-component'); 4 5//suspense is HOC for <Suspense/> from react 6const SubComponent = suspense(() => { 7 //Some magic... 8 //But you just waiting for resolve promise 9 useService(lazy); 10 11 // `require` wil be used from module scope 12 return require('my-lazy-component').LazyComponent; 13}); 14 15export function MyPage() { 16 return <SubComponent />; 17}
What evaluate
evaluate as JS
If the url ends with .js/.cjs or the source field contains one of strings:
- Object.getOwnPropertyDescriptor
- Object.prototype.hasOwnProperty
- Object.getPrototypeOf
It's not safe, so be careful to use source
evaluate as CSS
If the url ends with .css or the source field doesn't contain any JS markers(see above)

