Registry / web-framework / component-build

component-build

JSON →
library1.2.2jsnpmunverified

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-build
INSTALL
IMPORT
SIG · COMPONENT-BUILD
C
component-build
web-frameworkjavascriptv1.2.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Build
const Build = require('component-build');
import Build from 'component-build';
The package is CommonJS-only and uses `require`.
build.scripts
build.scripts(function (err, string) { /* ... */ });
This is a method on the `Build` instance, not a direct import. It utilizes an error-first callback pattern.
Build.scriptPlugins
Build.scriptPlugins = function (build, options) { /* ... */ };
This can be overridden on both the constructor and prototype to customize script processing plugins. It's a property, not a function call.

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.

const resolve = require('component-resolver'); const Build = require('component-build'); const fs = require('fs'); const write = fs.writeFileSync; const options = { development: true, install: true, // Example for autoprefixer, if needed browsers: ['last 2 versions', '> 1% in US'], // Example for UMD wrap umd: 'myBundleName' }; resolve(process.cwd(), options, function (err, tree) { if (err) { console.error('Resolution Error:', err); throw err; } const build = Build(tree, options); build.scripts(function (err, string) { if (err) { console.error('Scripts Build Error:', err); throw err; } if (string) { console.log('Writing build.js'); write('build.js', string); } else { console.log('No scripts to build.'); } }); build.styles(function (err, string) { if (err) { console.error('Styles Build Error:', err); throw err; } if (string) { console.log('Writing build.css'); write('build.css', string); } else { console.log('No styles to build.'); } }); build.files(function (err) { if (err) { console.error('Files Build Error:', err); throw err; } console.log('Files copied successfully.'); }); });
component-build --version
Debug
Known issues
breakingThe `component` package manager ecosystem, which `component-build` is a part of, is largely abandoned and incompatible with modern `npm`, `yarn`, or `pnpm` workflows. This package is primarily for maintaining legacy projects.
fix
Consider migrating away from the `component` ecosystem to modern build tools like Webpack, Rollup, or Vite if possible.
affects: >=1.0.0
gotchaThis package is CommonJS-only and relies on `require()` for module imports. Attempting to use ES module `import` syntax will result in errors.
fix
Always use `const MyModule = require('my-module');` for importing `component-build` and its associated dependencies.
affects: >=1.0.0
gotchaAll asynchronous operations within `component-build` utilize an error-first callback pattern. There is no built-in Promise-based or `async/await` compatible API.
fix
Wrap callback-based functions with `util.promisify` or custom Promise wrappers if modern async/await syntax is desired.
affects: >=1.0.0
gotchaThe internal dependencies, such as `component-builder2` and `component-resolver`, are also likely unmaintained, potentially leading to security vulnerabilities or compatibility issues with newer Node.js versions or underlying build tools.
fix
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.
affects: >=1.0.0
gotchaWhile the README mentions "ES6 Module support," this refers to the ability to transpile ES6 modules found *within* your source code, not that the `component-build` package itself is distributed as an ES module or fully supports the modern ES module loading specification.
fix
Understand that 'ES6 Module support' means transpilation of application code, not a change in the package's own module system or API.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Build is not a function
Attempting to import `Build` using ES module syntax (e.g., `import Build from 'component-build';`).
fix
Use CommonJS `require` syntax: `const Build = require('component-build');`
Error: Cannot find module 'component-resolver'
The `component-resolver` package, a peer dependency, is not installed or cannot be resolved by the `component` tooling.
fix
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.
ReferenceError: require is not defined
Attempting to execute `component-build` or a script using `require()` in an ES module context (e.g., a file with `"type": "module"` in `package.json`) or a browser environment without a CommonJS loader.
fix
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.
[CSS] autoprefixer: No browsers config specified
The `autoprefixer` plugin (used for styles) requires a `browsers` option to specify target browser versions, which was not provided in the `options` object passed to `Build`.
fix
Add a `browsers` array or string to the `options` object, for example: `const options = { browsers: ['last 2 versions', '> 1%'] };`
Upgrade
Version history
1.2.2latest on npm
Audit
Dependencies
component-resolverrequiredUsed to resolve component dependencies and construct the dependency tree.
component-builder2requiredThe core logic for the build process; `component-build` is a thin wrapper around it.
Agent activity
12 hits · last 30 days
node
8
OpenAI (training)
1
Resources
component-build — npm install component-build · libregistry