Find what blocks a CommonJS to ES module migration

Proprietary

Reports, for each Node.js package and each of its files, what stands between it and ES modules, and changes nothing. Each blocker is marked where it is and is a row of the EsmMigrationBlockers data table, with its kind and a suggested manual action: __dirname, require.cache and the loader's other internals, dynamic, nested and conditional require(), createRequire, mixed or unusual export shapes, top-level this and return, duplicate top-level declarations, sloppy-mode-only code, JSON and extensionless requires, files that mix import or export with CommonJS, files that "type": "module" would reinterpret, #imports, deep requires between packages, ES module-only dependencies, statements whose order before a later require() matters, and require() patching tools. The EsmPackageSummary data table has one row per package.json: its CommonJS and ES module file counts, type, engines.node, whether that range has require() of ES modules, and the blockers by kind. It reports what it found, not whether a package is ready. ES module-only dependencies, and extensionless requires into a dependency, are found by reading the installed node_modules next to the sources, so they are reported only where the dependencies are installed.

org.openrewrite.javascript.migrate.esm.FindEsmMigrationBlockers
mod run . --recipe=org.openrewrite.javascript.migrate.esm.FindEsmMigrationBlockers

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.