Benifits of Module Compilation

  1. In a module, resources such as API route, controller, service, middleware, internationalization and parameter configuration can be set separately
  2. In EggJS, these resources are organized and loaded in the way of convention-over-configuration. While In EggBornJS, these resources are explicitly organized and loaded by require. Therefore, the modules in EggBornJS can be compiled separately
  3. Modules can be compiled separately, so that they can be published, deployed and upgraded separately, so as to promote the prosperity of the whole ecosystem of CabloyJS, and further accelerate the development of actural business
  4. On the other hand, module compilation can also meet the needs of business intellectual property protection

How to compile module

$ cd {project}/src/module/{moduleName}
$ npm run build:front
$ npm run build:backend

Compilation Configuration

src/module/test-party/build/config.js

module.exports = {
  productionSourceMap: true,
  uglify: false,
};
Name Description
productionSourceMap Generate SourceMap file or not
uglify uglify codes or not

How to publish module

When the module in the project is stable, you can publish and contribute the module to the Open Source Community. You can also create private npm registry in your company, and then publish the module there, so as to form company assets for easy reuse

$ cd {project}/src/module/{moduleName}
$ npm publish