StealJS Build Tools

2.3.0 · active · verified Tue Apr 21

Steal-tools is a robust collection of command-line and programmatic utilities designed for building, packaging, and optimizing JavaScript applications, particularly those utilizing the StealJS module loader. It supports a wide array of module formats including ES6 Modules, CommonJS, and AMD, facilitating the creation of applications and plugins that load efficiently. As of version 2.3.0, it leverages modern JavaScript features like dynamic `import()` via `esprima-next` and uses `terser` as its default minifier. This package is an integral part of the larger StealJS ecosystem, working in tandem with the `steal` module loader for client-side dependency management, and is actively maintained with regular patch and minor releases focusing on compatibility and feature enhancements. It differentiates itself through features like intelligent bundling, progressive loading, and comprehensive project exporting capabilities, all aimed at improving application load times and caching strategies.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically build a StealJS application using `steal-tools.build`. It configures a basic build, specifies entry points, enables minification and asset bundling, and sets an output directory.

const stealTools = require('steal-tools');
const path = require('path');

const projectRoot = path.resolve(__dirname, 'my-steal-app');
const outputPath = path.resolve(projectRoot, 'dist');

console.log('Starting StealJS application build...');

stealTools.build({
  // Configuration for your StealJS app
  config: path.join(projectRoot, 'package.json!npm'), // Path to your package.json with StealJS config
  main: 'my-app/main' // Your main application module
}, {
  // Build options
  minify: true, // Minify the output code (default: true)
  bundleAssets: true, // Bundle assets like CSS/images
  dest: outputPath, // Destination folder for the build
  removeDevelopmentCode: true, // Remove development-specific code
  verbose: true // Log more details about the build process
}).then(function(buildResult) {
  console.log('StealJS application build complete!');
  console.log(`Output written to: ${outputPath}`);
  // You can inspect buildResult for more details like bundles, graph, etc.
  // For example: console.log(buildResult.bundles);
}).catch(function(err) {
  console.error('StealJS build failed:', err);
  process.exit(1);
});

view raw JSON →