Open MercatoDocsSearch docsAPI reference

CLI

mercato module enable

Register a module whose package is already installed. This command is useful when dependency installation and module registration happen in separate steps.

yarn mercato module enable registers a module package that is already present in node_modules (an official @open-mercato/* package, a module built into @open-mercato/core selected with --module <moduleId>, or a third-party package with --allow-third-party) into your app's src/modules.ts and runs the code generators. It does not install any npm dependencies. Pass --eject if you want the module copied into src/modules/<moduleId>/ and loaded as a local @app module instead of directly from the installed package.

This command is useful when you pin a module package directly in your workspace package.json (for example, in a monorepo where a package is already a workspace dependency) and only need to activate it in the app.

Usage

# Single-module package — module is selected automatically
yarn mercato module enable <packageName>

# Multi-module package — select which module to enable
yarn mercato module enable <packageName> --module <moduleId>

# Copy the installed module source into src/modules/<moduleId>/
yarn mercato module enable <packageName> --eject

# Enable an already-installed third-party (non-@open-mercato) module package
yarn mercato module enable <packageName> --allow-third-party

<packageName> is the installed dependency binding from the app's package.json, without a version suffix. It is usually the canonical npm package name (for example, @open-mercato/test-package), but it may be a Yarn npm alias. Packages whose canonical manifest name is outside the @open-mercato/* scope require --allow-third-party.

Options

OptionDescription
<packageName>Dependency binding of the already-installed module, including an npm alias when used. The canonical manifest name must be under @open-mercato/* by default; other scopes require --allow-third-party. The binding must be present in node_modules.
--module <moduleId>Select a specific module from a package that contains multiple modules. Required when the package exposes more than one module; omit for single-module packages.
--ejectCopy the selected module source into src/modules/<moduleId>/, rewrite cross-module imports to the origin package, and register it as from: '@app'. Omit this flag to keep loading the module from node_modules.
--allow-third-partyAllow enabling a package outside the @open-mercato/* scope. The package must still pass module-structure validation. Required as an explicit opt-in for supply-chain safety.

When to Use module enable vs module add

SituationCommand
Package is not yet installedmercato module add <packageSpec>
Package is already in node_modules and just needs registeringmercato module enable <packageName>
Package has multiple modulesmercato module enable <packageName> --module <moduleId>
Package is already installed and you want local source ownershipmercato module enable <packageName> --eject
Package is not installed and you want local source ownership immediatelymercato module add <packageSpec> --eject

What the Command Does

  1. Resolves <packageName> from the current workspace node_modules.
  2. Scans the package's src/modules/ directory (falling back to dist/modules/) to discover available modules.
  3. If --module is provided, selects that module; if the package has exactly one module, selects it automatically; otherwise errors with the list of available module IDs.
  4. If --eject is used, verifies that the selected module is marked ejectable in its index.ts, then copies the module directory into src/modules/<moduleId>/.
  5. Registers the module in src/modules.ts:
    • Default flow: adds an entry with from: '<packageName>'.
    • With --eject: adds an entry with from: '@app'.
  6. Runs mercato generate to regenerate the module registry, entity IDs, DI bindings, and API client.

Examples

Register a single-module package already installed in the workspace:

yarn mercato module enable @open-mercato/test-package

Enable one specific module from a multi-module package (e.g. @open-mercato/core):

yarn mercato module enable @open-mercato/core --module currencies
yarn mercato module enable @open-mercato/core --module portal

Enable an already-installed package and copy its source locally:

yarn mercato module enable @open-mercato/test-package --eject

Post-Enable Steps

# 1. Apply any new database migrations introduced by the module
yarn db:migrate

# 2. Start the dev server
yarn dev

Troubleshooting

Previous: mercato module add · Next: mercato module search