question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[ RFC ] Improved modules API

See original GitHub issue

What is the motivation for adding / enhancing this feature?

Current modules API is a huge milestone in VS history but still pretty limited. The goal of this transformation is to cut off those limits.

The biggest limitations are

  • inability to load modules lazily in easy way
  • modules merging during runtime process (old and new module are landing in final bundle) - still need to figure it out and it’s probably a case for another issue

The goal of the solution is to solve those two problems while not changing any currently existing module from the inside. In other words this change should be handled purely on Vue Storefront level so there are no changes needed in any of currently existing modules.

Solution

To allow lazy loading of modules and better error handling we should put an abstraction layer on top of Vuex (similar to router manager). I was trying to do it seamlessly as a proxy (see reference) but it turned out to be impossible. To use any of the modules the module object needs to be called directly which should enable seamless lazy loading, autocompletion and better error handling

//somewhere in code
const CatalogModule = () => import('@vue-storefront/catalog')
CatalogModule.dispatch('actionName', payload)

We will also depreciate old root registration in index.ts and extendModule method in favor of VueStorefrontModule.extend() so everything is encapsulated.

This is something I would like to do during Christmas break.

Ofc everything will be backward comaptible and for next 3 major versions you could still use old way of registering and using modules.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
pkarwcommented, Apr 19, 2019

This is awesome. How about adding the module hooks by this chance? I mean hooks like: afterApplicationLoaded, afterStoreviewChanged (there were few cases we encountered with @patzick thay there’s is no entry point for applying some business logic once the proper store view is loaded)? I think it would be great to use similar approach like Nuxt has and set the fixed set of endpoints; current set is too limited I belive

1reaction
lukeromanowiczcommented, Apr 19, 2019

While we are here, would be nice to add dependency checking between vsf modules. I.e. if there is a checkout module, build process should check if the cart module is being loaded as well. We would probably want also to have control over which modules load first based on something else than alphabetic order.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[ RFC ] Improved modules API · Issue #2760 - GitHub
The goal of the solution is to solve those two problems while not changing any currently existing module from the inside. In other...
Read more >
RFC 2614: An API for Service Location
The APIs are modular and are designed to allow implementations to offer just the feature set needed. In addition, standardized file formats for ......
Read more >
[RFC] Lifetime of API Tools - Laminas Project Community
In combination with Doctrine, the API tools are simply unusable for inexperienced users who only want to use the tool via the admin...
Read more >
RFC 86: Column-oriented read API for vector layers - GDAL
(details on the various data types can be skipped) is strongly encouraged for a better understanding of the rest of this RFC.
Read more >
T95654 RFC: Business Layer Architecture on budget
Similar to T89889, this RFC proposes a simple path to split presentation vs data ... T93897 Better separate logic/data classes from API modules...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found