Monorepo & Package Architecture
Relevant source files
The following files were used as context for generating this wiki page:
nuxt-i18n-micro utilizes a monorepo architecture managed by pnpm to provide a modular, performance-focused i18n solution for Nuxt 3. The project separates core domain logic, framework-agnostic runtimes, and specific framework bindings into distinct packages under the @i18n-micro/ scope to minimize bundle sizes and runtime overhead.
The architecture prioritizes small bundles, fast builds, and low runtime costs by reusing shared logic in packages/core and packages/utils rather than duplicating implementation across framework-specific packages.
Sources: AGENTS.md:7-13, README.md:9-12
Core Package Hierarchy
The monorepo structure organizes code based on its role in the build and runtime lifecycle. Shared logic sits at the base of the dependency tree, while framework adapters and tooling sit at the top.
The diagram shows the dependency flow where framework-specific implementations depend on core layers, which ultimately depend on shared types.
Package Definitions and Roles
| Package Name | Directory | Primary Responsibility |
|---|---|---|
nuxt-i18n-micro | src/ | The published root Nuxt module and build hooks. |
@i18n-micro/core | packages/core/ | Translation, pluralization, and formatting domain logic. |
@i18n-micro/types | packages/types/ | Shared TypeScript interfaces and object shapes. |
@i18n-micro/utils | packages/utils/ | Framework-agnostic helper functions. |
@i18n-micro/runtime | packages/runtime/ | Framework-agnostic runtime (createI18n) without filesystem dependencies. |
@i18n-micro/route-strategy | packages/route-strategy/ | Build-time localized route generation for Nuxt. |
@i18n-micro/path-strategy | packages/path-strategy/ | Runtime path resolving and strategy-aware URL building. |
Sources: AGENTS.md:14-25, packages/route-strategy/README.md:10-25
Build and Development Workflow
Building the monorepo requires a specific order because the main Nuxt module and playgrounds import @i18n-micro/* packages from their respective dist/ directories.
- Package Build: Build all internal workspace packages (excluding playgrounds).
- Dev Prepare: Execute
pnpm run dev:prepareto load the Nuxt module and generate.nuxt/tsconfig.json. - Playground Build: Build package-specific playgrounds to generate virtual configuration declarations (e.g.,
virtual:i18n-micro/config).
Sources: AGENTS.md:32-52
Order of operations for setting up a fresh development environment to ensure all local dependencies are resolved.
Package Standards and Verification
The project enforces strict packaging standards to ensure compatibility across different environments (ESM and CommonJS).
Dual-Package Exports
Workspace packages use dual-package exports to support both modern and legacy consumers. The package.json manifest defines specific targets for production, import, and require.
"exports": {
".": {
"production": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
},
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
}
}
Sources: packages/core/package.json:35-51, scripts/src/commands/verify-packages.ts:25-30
Verification Logic
The verify-packages script audits the following criteria:
- Missing Files: Ensures paths referenced in
exportsormainactually exist on disk. - Unpublished Files: Checks if the
filesarray inpackage.jsonincludes all necessary artifacts for the registry. - Dual-Package Types: Validates that
requireconditions use.d.ctsextensions to prevent type resolution failures for CommonJS consumers. - Engines: Confirms
engines.nodeis defined to specify environment requirements.
Sources: scripts/src/commands/verify-packages.ts:160-200, scripts/src/commands/verify-packages.ts:40-75
Routing and Strategy Separation
The architecture splits routing into build-time and runtime packages to optimize Nuxt performance.
Route Generation (route-strategy)
This package operates purely on NuxtPage objects during the extendPages hook. It transforms raw page definitions into localized trees based on four strategies: no_prefix, prefix, prefix_except_default, and prefix_and_default. It remains framework-agnostic by avoiding dependencies on Nuxt runtime or Vue Router.
Sources: packages/route-strategy/README.md:1-25, packages/route-strategy/README.md:95-120
Path Strategies (path-strategy)
While route-strategy handles the physical structure of routes at build time, path-strategy handles runtime URL building and detection. This separation allows the application to resolve $localePath and $localeRoute efficiently without re-calculating the entire route tree.
Sources: AGENTS.md:21-22, packages/route-strategy/README.md:162-170
Tooling and Maintenance
The monorepo includes dedicated tooling for documentation, auditing, and performance reporting.
docs-generate: Usesvue-docgen-apiandTypeDocto extract documentation directly from source files, ensuring the reference guides stay in sync with the code.docs-audit: Scans for "drift" such as undocumented options or dead links that standard build steps might miss.performance-report: Measures build time, bundle size (code vs. translations), peak memory usage (RSS), and requests per second (RPS) using Artillery.
Sources: scripts/src/commands/docs-generate.ts:320-350, scripts/src/perf/report.ts:75-100, README.md:38-55
nuxt-i18n-micro maintains a clean separation between its engine and its bindings, ensuring that the core logic remains lean and reusable while providing deep integration for Nuxt developers.