ModuleConfig

ModuleConfig is used to configure module import and export rules:

1interface ModuleConfig {
2    /**
3     * Links configuration between services
4     * Key: Name of the remote service
5     * Value: Path to the build output directory of the remote service
6     */
7    links?: Record<string, string>;
8
9    /**
10     * Import configuration: Maps module identifiers in the current service to modules provided by remote services
11     * Key: Module identifier used in the current service
12     * Value: Module path exported by the remote service
13     */
14    imports?: Record<string, string>;
15
16    /**
17     * Export configuration: Exposes modules from the current service for use by other services
18     */
19    exports?: ModuleConfigExportExports;
20}

Specify build directory locations of remote services:

1{
2  links: {
3    'vue-remote-service': '../vue-remote-service/dist',  // Relative path
4    'other-service': '/var/www/other-service/dist'  // Absolute path
5  }
6}

imports Configuration

Configure modules to use and their sources:

1{
2  imports: {
3    'remote-button': 'vue-remote-service/components/button'
4  }
5}

exports Configuration

The system exports these entry files by default:

1{
2  'src/entry.client': {
3    inputTarget: {
4      client: './src/entry.client',
5      server: false
6    }
7  },
8  'src/entry.server': {
9    inputTarget: {
10      client: false,
11      server: './src/entry.server'
12    }
13  }
14}

Array Format

1exports: [
2    // Export npm package
3    'npm:vue',                           // Will set rewrite: false automatically
4    
5    // Export source file (must include file extension)
6    'root:src/components/button.ts',     // Will be resolved to './src/components/button'
7    
8    // Object configuration
9    {
10      'store': {
11        input: './src/store.ts',         // Isomorphic module
12        inputTarget: {                   // Or specify different client/server implementations
13          client: './src/store.client.ts',
14          server: './src/store.server.ts'
15        },
16        rewrite: true                    // Defaults to true
17      }
18    }
19]

Object Format

1exports: {
2    // Directly specify source file path
3    'utils': './src/utils.ts',
4
5    // Complete configuration
6    'api': {
7        input: './src/api/index.ts'      // Entry file for isomorphic module
8    },
9    
10    // Client/Server separation
11    'entry': {
12        inputTarget: {
13            client: './src/entry.client.ts',  // false means no implementation for this environment
14            server: './src/entry.server.ts'
15        }
16    }
17}

Configuration Properties

ModuleConfigExportObject

1interface ModuleConfigExportObject {
2    /**
3     * Source file path of the module
4     */
5    input?: string;
6
7    /**
8     * Different entry file configurations for client and server
9     * false means no implementation for that environment
10     */
11    inputTarget?: Record<'client' | 'server', string | false>;
12
13    /**
14     * Whether to rewrite module paths
15     * @default true
16     * @remarks Only needs to be false when exporting npm packages
17     */
18    rewrite?: boolean;
19}

Usage Restrictions

  1. Path Requirements

    • All paths except npm: prefix exports must point to specific files
    • File paths with root: prefix must include file extensions (.ts, .js, etc.)
  2. Path Resolution Rules

    • npm: prefix: For exporting npm packages, automatically sets rewrite: false
    • root: prefix: For exporting source files, resolved to relative paths