Create ScandiPWA App
ScandiPWA DocsCreate Magento AppGitHub
  • Create ScandiPWA App
  • Getting Started
    • Getting Started
    • Folder structure
    • Supported Browsers & Features
    • Updating to New Releases
  • Themes
    • Themes
    • File overrides
  • Extensions
    • Extensions
    • Installation
    • Application plugins
      • Plugin Templates
    • Build configuration plugins
    • Plugins for HTML and PHP
    • File provision
    • Module preference
  • Building your app
    • Proxying requests to server
    • Internationalization
    • Creating production build
  • Deploying your app
    • Storefront
    • Magento theme
Powered by GitBook
On this page

Was this helpful?

  1. Extensions

Module preference

PreviousFile provisionNextProxying requests to server

Last updated 4 years ago

Was this helpful?

ScandiPWA introduces concept of module preference. This is a feature of .

To preference a module - to take-over another NPM or virtual module. To take-over means to completely replace an implementation, the original module will not be available.

To preference a module, set the scandipwa.preference field of package.json equal to the desired module name.

Watch out!

This is very dangerous to preference a real NPM module, like in example react or redux. While you can do this, this feature is meant for .

Virtual module preference

Watch out!

This is a subject to change. We plan on providing a more robust way to depend on virtual modules. They should be coupled with typescript interfaces. Currently, virtual-modules only work on the level of module resolution, they do not provide any interface for the implementation.

Create ScandiPWA App introduces the concept of "virtual module".

Virtual module - a non-existing module, referenced in the code. It provides an abstraction layer, which allows to swap the implementation.

Virtual modules are useful for UI elements, where different libraries could be used as an implementation, or for an API endpoints, where the application is relying on data format, not the source of the data.

To create a virtual module, define the reference to a non existing module, and in your extension to it. To ensure that it does not exist, use @virtual-module/<name> name for it.

ScandiPWA extensions
virtual module preference
implement a preference