modular-views.macro
TypeScript icon, indicating that this package has built-in type declarations

3.1.1 • Public • Published

modular-views.macro

When used in a modular repository, this macro will scan all the available packages, find the ones marked as 'views', and generates a map of names to the views, each wrapped in React.lazy.

usage

Suppose you have a modular repository, with a directory structure like so -

my-modular-repo
  packages
    app
    pkg-1
    pkg-2
    view-1
    view-2
    view-3
    view-4
    ...
    view-n

Then you can write code like this -

import views from 'modular-views.macro';

console.log(views);

/* 
The above call would log this object - 

{
  'view-1': React.lazy(() => import('view-1')),
  'view-2': React.lazy(() => import('view-2')),
  'view-3': React.lazy(() => import('view-3')),
  'view-4': React.lazy(() => import('view-4')),
  // ...
  'view-n': React.lazy(() => import('view-n')),
}

Like magic!
*/

Readme

Keywords

none

Package Sidebar

Install

npm i modular-views.macro

Weekly Downloads

15

Version

3.1.1

License

Apache-2.0

Unpacked Size

15.7 kB

Total Files

10

Last publish

Collaborators

  • threepointone
  • modular-publisher