@nestjs/cli
Version:
The Nest CLI: create NestJS applications, generate modules, controllers and CRUD resources, and build, run and watch projects and monorepos.
17 lines (16 loc) • 442 B
JavaScript
import { readFileSync } from 'fs';
import { join } from 'path';
/**
* Detect whether the target project uses ESM output.
* Checks the project's package.json for `"type": "module"`.
*/
export function isEsmProject(cwd = process.cwd()) {
try {
const raw = readFileSync(join(cwd, 'package.json'), 'utf-8');
const pkg = JSON.parse(raw);
return pkg.type === 'module';
}
catch {
return false;
}
}