Bit-Bundler Utilities (`bit-bundler-utils`) is a Node.js helper library providing essential functionalities for projects built with `bit-bundler` and `bit-imports`. Currently at stable version 5.1.2, this package offers utilities for generating and managing unique module IDs, robustly resolving module and file paths, and asynchronously reading file contents from disk. Its path resolution capabilities are powered by `browser-resolve`, making it suitable for both Node.js and browser-compatible path handling. The library emphasizes stability and integration within the `bit-bundler` ecosystem, maintaining an `active` release cadence with regular patch updates to ensure reliability and address minor issues.
npm install bit-bundler-utilsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates resolving a module path, reading its content, and using the unique ID generation and setting functionalities.
Ensure `uniqueId.setId` is called with the same `value` for subsequent calls with the same `moduleId`, or design your application to set the ID only once per module. Repeated calls with the *same* `moduleId` and `value` are permitted.
Be aware of the caching behavior when testing or in scenarios where dynamic ID generation with different results for the same input might be expected. This is by design for performance and consistency within the `bit-bundler` ecosystem.
Prefer `const module = require('bit-bundler-utils/subpath');` syntax. If you must use ESM, ensure your build tool (e.g., Webpack, Rollup) is configured to handle CommonJS modules within an ESM project, or use dynamic `import()` for CJS modules if supported by your runtime.Review calls to `uniqueId.setId` to ensure consistency. If a module's unique ID needs to change, it indicates a design flaw or a need to reset the `uniqueId` state (which is not directly exposed by the API).
Ensure `bit-bundler-utils` is correctly installed via `npm install bit-bundler-utils` and that the `require()` path matches one of the documented subpath exports.
Change `import` statements to CommonJS `require()` syntax: `const resolvePath = require('bit-bundler-utils/resolvePath');`