A small native ESM compatibility package that provides one stable import surface for Eliware's shared Node.js utilities.
- Node.js 26 or newer
- Node.js
>=26 - Published Eliware dependency packages matching the versions in
package.json
npm install @eliware/common@eliware/common re-exports the current public APIs from:
@eliware/log:log,createLogger,safeSerialize@eliware/path:path,pathUrl,getCurrentDirname,getCurrentFilename,resolvePath,relativePath,fileUrlToPath@eliware/errors:registerHandlers@eliware/signals:registerSignals- Node.js
fs
The implementation is split into focused modules under src/ while the package root remains the public entry point.
import {
fs,
log,
path,
pathUrl,
resolvePath,
registerHandlers,
registerSignals,
} from '@eliware/common';
const configPath = path(import.meta, '.env');
const configUrl = pathUrl(import.meta, '.env');
const absolutePath = resolvePath(import.meta, 'config');
log.info('Application starting', { configPath, configUrl, absolutePath });
log.info(`Files: ${fs.readdirSync(path(import.meta)).join(', ')}`);
const errors = registerHandlers({ events: ['uncaughtException', 'unhandledRejection'] });
const signals = registerSignals({ shutdownHook: async () => errors.removeHandlers() });
process.once('SIGTERM', () => void signals.shutdown('SIGTERM'));Type declarations are included and expose the dependency option and return types:
import {
createLogger,
getCurrentDirname,
registerSignals,
type RegisterSignalsOptions,
} from '@eliware/common';
const logger = createLogger({ format: 'json' });
const directory = getCurrentDirname(import.meta);
const options: RegisterSignalsOptions = { exit: false };
const registration = registerSignals(options);The package has no global configuration and performs no work at import time. Configure the delegated logger, error handlers, and signal handlers through their options. Applications should validate their own configuration before opening files or external connections and should make shutdown cleanup idempotent.
This package is a compatibility layer and delegates behavior to its underlying packages. For logging, path, error-handler, or signal-handler failures, consult the corresponding dependency documentation. Keep dependency versions synchronized with the public exports and declarations.
npm install
npm test
npm run lint
npm run typecheck
npm run pack
npm audit --omit=dev --audit-level=moderateThis package is a re-export/compatibility layer. Its tests verify the public export contract and representative delegation to the underlying packages; implementation behavior is tested in those dependency packages.
Do not log secrets or include credentials or machine-specific paths in examples. Review delegated package behavior and keep dependencies updated before publishing.