{"id":15570,"library":"cheminfo-build","title":"ChemInfo Build Tool","description":"cheminfo-build is a specialized Command Line Interface (CLI) tool designed to streamline the build process for packages within the ChemInfo ecosystem. It automates common tasks such as bundling JavaScript for various environments (ESM, UMD), generating source maps, and creating minified versions. The package is currently at version 1.3.2 and receives regular updates, primarily for dependency management and minor fixes, with major breaking changes occurring less frequently. For example, v1.3.0 introduced significant changes to module resolution and bundle extensions. Its key differentiators include its focus on ChemInfo package conventions and its ability to handle modern JavaScript module formats (ESM, CJS) with configurable output paths and naming conventions.","status":"active","version":"1.3.2","language":"javascript","source_language":"en","source_url":"https://github.com/cheminfo/cheminfo-build","tags":["javascript"],"install":[{"cmd":"npm install cheminfo-build","lang":"bash","label":"npm"},{"cmd":"yarn add cheminfo-build","lang":"bash","label":"yarn"},{"cmd":"pnpm add cheminfo-build","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"While primarily a CLI, `cheminfo-build` also exposes a programmatic API. Assuming a named export `build` for its core functionality based on package name and common patterns for build tools. Verify actual exports from the package's entry files for definitive symbols.","wrong":"import cheminfoBuild from 'cheminfo-build'; // Incorrect if 'build' is a named export.","symbol":"build","correct":"import { build } from 'cheminfo-build';"},{"note":"For CommonJS environments, requiring the package will expose its named exports, such as 'build'. Version 1.3.0 introduced the `.umd.cjs` bundle extension for CommonJS.","wrong":"const build = require('cheminfo-build'); // Incorrect if 'build' is a named export, common error.","symbol":"build","correct":"const { build } = require('cheminfo-build');"},{"note":"The primary and most common interaction with `cheminfo-build` is via its command-line interface. Using `npx` ensures you execute the project-local version without global installation.","symbol":"CLI Usage","correct":"npx cheminfo-build <options>"}],"quickstart":{"code":"npm install -D cheminfo-build\n\n// Example package.json with a custom build script\n// This demonstrates how to integrate cheminfo-build into a typical project workflow.\n// {\n//   \"name\": \"my-cheminfo-package\",\n//   \"version\": \"1.0.0\",\n//   \"main\": \"dist/my-cheminfo-package.umd.cjs\",\n//   \"module\": \"dist/my-cheminfo-package.esm.mjs\",\n//   \"exports\": {\n//     \".\": {\n//       \"import\": \"./dist/my-cheminfo-package.esm.mjs\",\n//       \"require\": \"./dist/my-cheminfo-package.umd.cjs\"\n//     }\n//   },\n//   \"scripts\": {\n//     \"build\": \"cheminfo-build -e src/index.js -o dist -n my-cheminfo-package --no-source-map\"\n//   }\n// }\n\n// To execute the build command defined in package.json:\n// In your terminal:\n// npm run build\n\n// Or, for direct CLI execution without a package.json script:\n// npx cheminfo-build -e src/index.js -o dist -n my-cheminfo-package --no-minify","lang":"javascript","description":"Demonstrates installation and basic CLI usage of cheminfo-build within a project's `package.json` scripts, including options for entry, output, name, and disabling features like source maps or minification."},"warnings":[{"fix":"Review and update your `package.json`'s `exports` field to correctly define module entry points for both CommonJS (`require`) and ESM (`import`) environments. Any build scripts, bundler configurations, or direct import paths that relied on the old `.js` extensions for UMD bundles must be updated to use the new `.umd.cjs` or `.esm.mjs` extensions. Prioritize `package.json` `exports` for robust module resolution over direct file paths.","message":"Starting with version 1.3.0, `cheminfo-build` introduced significant breaking changes to its module resolution and bundle output conventions. It now prioritizes the `exports` field in `package.json` for determining module entry points, aligning with modern Node.js practices. Furthermore, UMD bundles are renamed to `.umd.cjs`, and new ESM bundles are generated with the `.esm.mjs` extension.","severity":"breaking","affected_versions":">=1.3.0"},{"fix":"Regularly update `cheminfo-build` to its latest patch version (e.g., `npm update cheminfo-build`). Always test your build process after updating, especially within CI/CD pipelines, to catch any unexpected behavior. Consider pinning to a major version (`^1.x.x`) to prevent automatic major version upgrades that could introduce unannounced breaking changes.","message":"`cheminfo-build` frequently updates its internal dependencies, as indicated by recent releases. While typically non-breaking, these updates can sometimes introduce subtle changes, compatibility issues with older Node.js versions, or conflicts with other project dependencies if not regularly managed.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure `cheminfo-build` is installed as a dependency (`npm install cheminfo-build` or `npm install -D cheminfo-build`). For programmatic use, rely on standard module imports like `import { build } from 'cheminfo-build'` or `const { build } = require('cheminfo-build')`, which correctly utilize `package.json`'s `exports` field for resolution, rather than hardcoding paths to `dist` files.","cause":"This error often occurs when attempting programmatic import of the package when it's not correctly installed, or when using an incorrect/deprecated path for a specific bundle file. This is especially relevant after v1.3.0's changes to bundle extensions (.umd.cjs, .esm.mjs) and export precedence.","error":"Error: Cannot find module 'cheminfo-build' or 'cheminfo-build/dist/my-package.js'"},{"fix":"Execute the command using `npx cheminfo-build <options>` to leverage the locally installed version from your project's `node_modules`. Alternatively, ensure `node_modules/.bin` is included in your system's PATH, or call the executable directly from `node_modules/.bin/cheminfo-build`.","cause":"The `cheminfo-build` executable is not accessible in the system's PATH. This typically happens when the package is installed as a local `devDependency` and the command is not invoked from within the local `node_modules/.bin` directory or via `npx`.","error":"cheminfo-build: command not found"}],"ecosystem":"npm"}