Component Build

1.2.2 · abandoned · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

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.');
  });
});

view raw JSON →