CLI
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.
# 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.
| Option | Description |
|---|---|
<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. |
--eject | Copy 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-party | Allow 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. |
module enable vs module add| Situation | Command |
|---|---|
| Package is not yet installed | mercato module add <packageSpec> |
Package is already in node_modules and just needs registering | mercato module enable <packageName> |
| Package has multiple modules | mercato module enable <packageName> --module <moduleId> |
| Package is already installed and you want local source ownership | mercato module enable <packageName> --eject |
| Package is not installed and you want local source ownership immediately | mercato module add <packageSpec> --eject |
<packageName> from the current workspace node_modules.src/modules/ directory (falling back to dist/modules/) to discover available modules.--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.--eject is used, verifies that the selected module is marked ejectable in its index.ts, then copies the module directory into src/modules/<moduleId>/.src/modules.ts:
from: '<packageName>'.--eject: adds an entry with from: '@app'.mercato generate to regenerate the module registry, entity IDs, DI bindings, and API client.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
# 1. Apply any new database migrations introduced by the module
yarn db:migrate
# 2. Start the dev server
yarn dev
yarn mercato module add <packageSpec> to install and register in one step.src/modules/ or dist/modules/ directory. Only packages that expose at least one module directory are supported.--allow-third-party to opt in to enabling third-party module packages.--module <moduleId>. The error message lists the available IDs.src/modules.ts from the same source. Nothing to do – it is already active.src/modules.ts but with a different from value. Remove the existing entry first, or use mercato module eject if the package-backed module is already enabled and you want to switch it to local ownership.--eject) – only modules whose index.ts exports ejectable: true can be copied into src/modules/.--eject) – remove src/modules/<moduleId>/ before running the command again with --eject.yarn mercato generate to regenerate all artifacts, then verify with yarn build.