···2323npm exec lex-cli generate -c ./lex.config.js
2424```
25252626-highly recommend packaging the generated schemas as a publishable library for others to use.
2626+## publishing your schemas
2727+2828+if you're packaging your generated schemas as a publishable library, add the `atcute:lexicons`
2929+field to your package.json. this allows other projects to automatically discover and import your
3030+schemas without manual configuration.
3131+3232+```json
3333+{
3434+ "name": "@example/my-schemas",
3535+ "atcute:lexicons": {
3636+ "mapping": {
3737+ "com.example.*": {
3838+ "type": "namespace",
3939+ "path": "./types/{{nsid_remainder}}"
4040+ }
4141+ }
4242+ }
4343+}
4444+```
4545+4646+the `path` field supports several template expansions:
4747+4848+- `./` at the start is replaced with the package name (e.g., `./types/foo` becomes
4949+ `@example/my-schemas/types/foo`)
5050+- `{{nsid}}` - the full NSID with dots replaced by slashes (e.g., `com/example/foo/bar`)
5151+- `{{nsid_prefix}}` - the part before the wildcard (e.g., `com/example`)
5252+- `{{nsid_remainder}}` - the part after the prefix (e.g., `foo/bar`)
27532854## external references
29553056when your lexicons reference types from namespaces outside your configured files, you'll need to
3131-configure mappings to resolve these references.
5757+configure how these references are resolved.
32583359for example, if your lexicon references a type from another namespace:
3460···5480}
5581```
56825757-define mappings in your configuration to specify how external namespaces should be imported:
8383+the simplest way to resolve external references is using the `imports` array with packages that
8484+provide the `atcute:lexicons` metadata:
8585+8686+```ts
8787+// file: lex.config.js
8888+import { defineLexiconConfig } from '@atcute/lex-cli';
8989+9090+export default defineLexiconConfig({
9191+ files: ['lexicons/**/*.json'],
9292+ outdir: 'src/lexicons/',
9393+ imports: ['@atcute/atproto', '@atcute/bluesky'],
9494+});
9595+```
9696+9797+the CLI will automatically discover the namespace mappings from each package's `atcute:lexicons`
9898+field in their package.json.
9999+100100+for packages without metadata, or when you need more fine-grained control over import resolution,
101101+use the `mappings` configuration instead:
5810259103```ts
60104// file: lex.config.js
···81125 ],
82126});
83127```
8484-8585-with this configuration, any reference to a lexicon in the `com.atproto.*` or `app.bsky.*` namespace
8686-will be imported from `@atcute/atproto` or `@atcute/bluesky`, respectively.