component-build is a JavaScript package from the "component" ecosystem designed to bundle client-side web assets (scripts, styles, files) for browser deployment. Released around 2014, its stable version is 1.2.2. It acts as a wrapper around `component-builder2` and integrates with `component-resolver` to manage dependencies. Key features include transpilation of ES6 modules in source code, JSON parsing, template handling (as strings), automatic CSS autoprefixing, and URL rewriting for styles. For JavaScript, it supports optional UMD wrapping and autorequires the bundle entry point. The package primarily uses a callback-based API for its build processes. While it provided a structured way to build client-side applications within the 'component' framework, the 'component' package manager and its associated tools are largely obsolete, making `component-build` suitable mainly for maintaining legacy projects built within that specific ecosystem rather than new development. Its release cadence is effectively abandoned.
npm install component-buildVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use `component-build` to resolve dependencies and then build JavaScript, CSS, and copy files for a project, writing the output to disk. It showcases the core API for asset bundling.
Consider migrating away from the `component` ecosystem to modern build tools like Webpack, Rollup, or Vite if possible.
Always use `const MyModule = require('my-module');` for importing `component-build` and its associated dependencies.Wrap callback-based functions with `util.promisify` or custom Promise wrappers if modern async/await syntax is desired.
Exercise caution when using this package in environments with strict security requirements or newer Node.js versions. Regular security audits are recommended for legacy projects.
Understand that 'ES6 Module support' means transpilation of application code, not a change in the package's own module system or API.
Use CommonJS `require` syntax: `const Build = require('component-build');`Ensure `component-resolver` is correctly installed as a dependency within your project's `component.json` or equivalent setup, as per the `component` ecosystem's requirements.
Ensure your build script that invokes `component-build` is run in a Node.js CommonJS environment. This package is designed to be run server-side to build browser assets.
Add a `browsers` array or string to the `options` object, for example: `const options = { browsers: ['last 2 versions', '> 1%'] };`