Skip to main content

The index.ts|index.js file

If you're running your react application using typescript, which you should by the way, then our file will be located in src/index.ts otherwise it will be src/index.js

The index file is our entry point, here we will import five files:

  • Shared Provider.
  • Shared Config.
  • Apps List.
  • Mongez style file.
  • Mongez startup function.

So our file should look like:

src/index.ts
import 'mongez/style.css';import 'shared/config';import 'shared/apps-list';import 'shared/shared-provider';import Mongez from 'mongez';
Mongez();
Take Care Of Importing Shared alias

Please note the shared directory is aliased, check out Path aliasing.

warning

Mongez import must be imported at the end of imports list, it can not be before importing the config or the apps list files.

tip

If you're not going to use lazy modules, then import the modules provider file after the shared provider import.

How it works#

We imported mongez style file, which should be imported in the project startup.

Then the config file as it should contain all the overriden configurations for mongez modules.

The apps list file is called to collect more information about all applications in the project, its base path and its modules list.

Importing the shared proider will initialize the basic project setup as you set in the src/shared/shared-provider.ts.

Lastly we imported mongez for booting the application.

Once Mongez() function is triggered, it will start detecting the current route then it will be check the apps list with the stored routes list.