Closed whitter closed 9 months ago
Tweaked the alias method to allow the passing of a function to handle the loading of a module based on its alias.
When using a bundler such as webpack it will reduce the number of lines needed to initialise alpine. Instead of doing the following:
AsyncAlpine.init(Alpine); AsyncAlpine.data('output', () => import('/components/output.js')); AsyncAlpine.data('output1', () => import('/components/output1.js')); AsyncAlpine.data('output2', () => import('/components/output3.js')); ... AsyncAlpine.start(); Alpine.start();
We can make use of dynamic imports:
AsyncAlpine.init(Alpine); AsyncAlpine.alias((name) => import(`/components/${name}.module.js`)); AsyncAlpine.start(); Alpine.start();
Thank you, this looks great! I'm pretty busy at the moment but I'll review this when I can and providing all is good it will release in version 1.2.0.
Tweaked the alias method to allow the passing of a function to handle the loading of a module based on its alias.
When using a bundler such as webpack it will reduce the number of lines needed to initialise alpine. Instead of doing the following:
We can make use of dynamic imports: