Phase 0
Inventory current moment usage and identify timezone, locale, and parsing hotspots.
Migration
This page is for teams that need a realistic adoption path: evaluate first, replace in a small surface, compare behavior, then expand with confidence.
CLI Migration Tool
The mmntjs CLI automates the mechanical part of migration: scanning source
files, rewriting import paths, and generating a report to make rollout decisions visible.
# Scan first, then apply
mmntjs migrate --check
mmntjs migrate --applyMigration Overview
The safest way to adopt mmntjs is to treat it as a compatibility bridge first and an optimization or modernization step second. Teams usually get better results by reducing the migration surface one ownership boundary at a time instead of attempting a global swap.
A good migration plan also makes room for the possibility that a few modules should stay on moment.js longer than others. That is not failure. It is a controlled rollout doing its job.
Staged Rollout
Inventory current moment usage and identify timezone, locale, and parsing hotspots.
Run compatibility checks and review known differences for the APIs your codebase uses.
Replace imports in a low-risk module or service and run the existing test suite.
Compare production-like behavior, especially invalid dates, offsets, and custom parsing.
Expand rollout module by module with ownership and rollback clarity.
Use the bridge period to guide new code toward modern date/time APIs, including Temporal where it fits.
Migration Approaches by Build Tool
mmntjs supports three migration patterns. Which one works best depends on your package manager and test runner.
| Approach | npm / yarn | pnpm | Jest / webpack | vitest | bun |
|---|---|---|---|---|---|
A: npm alias"moment": "npm:mmntjs" | Works with one dependency alias. | Use root overrides when workspace resolution needs to be forced."moment": "link:../mmntjs/dist" | ✅ | Works; pool: threads is recommended. | ✅ |
B: Migration tool rewritemmntjs migrate --apply | ✅ | ✅ | ✅ | ✅ | ✅ |
C: Preload aliasModule._resolveFilename hook | Works with one setup file. | Use root overrides plus link:. | Works. | Use pool: threads; forks can fail to inherit resolution. | Use --preload. |
"moment": "link:../mmntjs/dist"
in the root package.json pnpm.overrides. The
file: and npm: protocols can interact poorly with pnpm's virtual
store in this setup.
pool: forks, forked workers may not inherit
the pnpm override resolution and can fail with Failed to resolve import "moment".
Switching to pool: threads resolves that failure mode.
vitest.resolve.alias with a 'moment' key does not reliably catch
the bare module specifier. Directly replacing node_modules/moment with a symlink
is overwritten by pnpm install.
moment-timezone,
evaluate that path separately rather than assuming a plain moment alias covers it.
The mmntjs timezone package installs behavior onto the mmntjs factory and should be tested
with the timezone entry point your app actually uses.
Migration to Temporal
mmntjs report analyzes each file and estimates how many moment usages can be
expressed directly with Temporal APIs. That number is not a migration promise; it is a signal
for which modules are worth evaluating for a Temporal path first.
mmntjs itself is the bridge: keep legacy moment-shaped code stable on mmntjs, write new code against Temporal where the report shows a clean mapping, and retire the old surface on your schedule rather than on a migration deadline.
Concrete Rollout Examples
Good Fit
Use Caution
Testing Strategy
What Not To Rush
Risk Checklist
If your team can complete this checklist for one low-risk module first, the next expansion step becomes much more credible to reviewers and maintainers.
Minimal Comparison Set
Before expanding beyond the first module or service, keep a tiny comparison set that reflects the way your application actually uses dates. It does not need to be large. It needs to be representative.