EMP v2 Typescript Workflow

background

The core part of micro-frontend and micro-component development is cross-group and cross-department collaborative development. This article mainly describes the workflow of ts development implemented by the entire EMP v2.

type generation

The generated declaration file has two parts

  • MF schema type generation
    • Provide base station users to use
    • Provide security verification for shared code
    • Generate corresponding types based on exposeandname
  • Library schema type generation
    • Provides tips for using npm

Generate process

Build processes run independently through worker-theads, improving overall efficiency

  • create dtsa thread
  • Traverse the project resource directory
  • instantiate the dts class
    • read tsconfig.json
    • Specify the file cache directory
    • Instantiate ts.languageService according to configuration
  • Compile ts file with dts objectdts emit
    • transferlanguageService.getEmitOutput
    • genDCode
  • output file moduleFederation.nameas named file库模式根据lib.name进行命名
  • exit the dtsthread

Synchronization process

The type synchronization of multiple base stations currently performs download synchronization based on the access of the corresponding directory deployment by default.

  • The main project requests through the convention directory or the specified directory
  • Download and save the d.tsfile to src, so that ts can support identifying types and make type detection take effect
  • Replace remotethe custom name
  • Generate the d.ts file of the corresponding base station defined by the project

EVERYTHING

For base station synchronization, the functions of automatic synchronization and automatic synchronization of hot update will be placed in subsequent planning.

finally

If you have more opinions and ideas on the development of micro front-end, you can communicate with them in the comment area.

Guess you like

Origin juejin.im/post/7080043566742913054
v2