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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
bundleAssets function
✓ const bundleAssets = require('steal-bundler');
✗ import bundleAssets from 'steal-bundler';
The package is a CommonJS module and exports the `bundleAssets` function directly as its `module.exports`. Use `require()` to import it. Direct ESM `import` syntax is not officially supported and can lead to issues.
Accessing named exports (incorrect)
✓ const bundleAssets = require('steal-bundler');
✗ const { bundleAssets } = require('steal-bundler');
// or
const bundleAssets = require('steal-bundler').bundleAssets;
Since `steal-bundler` exports a single function as its `module.exports` (a default export in CJS terms), attempting to destructure named exports or access properties like `.bundleAssets` from the required object will result in `undefined`.
ESM namespace import (incorrect)
✓ const bundleAssets = require('steal-bundler');
✗ import * as bundle from 'steal-bundler';
// then attempting to call bundle.default or bundle.bundleAssets
As a pure CommonJS package, `steal-bundler` does not provide an explicit `default` export for ESM interop. Using namespace imports (`import * as bundle`) will typically yield an object wrapping the CJS export, but accessing the function might require `bundle.default` or similar, which might not always work consistently depending on the Node.js version and `type` configuration in `package.json`.
Demonstrates how to integrate `steal-bundler` into a StealJS build workflow to automatically bundle static assets. It provides a runnable example by mocking the `stealTools.build` output to simplify execution.
const stealTools = require("steal-tools");
const bundleAssets = require("steal-bundler");
// For a real project, stealTools.build would generate this dynamically.
// We mock a simple buildResult object for a runnable quickstart without
// requiring steal-tools to be installed or a full StealJS project setup.
const mockBuildResult = {
configuration: {
main: 'app',
paths: {'@empty': '@empty'}
},
graph: { /* populated graph from build */ },
bundles: [] // steal-bundler adds to this
};
async function buildAndBundleAssets() {
try {
console.log('Simulating the stealTools.build process by using a mock buildResult...');
const buildResult = mockBuildResult; // Use the mock for demonstration.
console.log('Starting asset bundling with steal-bundler...');
// bundleAssets returns a Promise, which should be awaited for proper sequencing.
const finalBuildResult = await bundleAssets(buildResult, {
// This glob pattern targets all files within an 'images' directory.
// Adjust based on your project's static asset structure.
glob: "images/**/*",
infer: true // Set to false if you want to rely only on the 'glob' option
});
console.log('Asset bundling completed successfully. Final build result (truncated):', {
bundlesCount: finalBuildResult.bundles.length,
graphNodes: Object.keys(finalBuildResult.graph).length
});
} catch (error) {
console.error('An error occurred during the build and bundling process:', error);
}
}
buildAndBundleAssets();
Errors
Common errors & fixes
SyntaxError: Use of const in strict mode.
This error occurs when running `steal-bundler` versions older than v0.3.5 on Node.js 4 without strict mode enabled. These older versions used `const` and `let` keywords which were not fully supported in Node.js 4 in non-strict contexts.
fixUpgrade `steal-bundler` to version 0.3.5 or newer. Alternatively, ensure your Node.js environment is configured for strict mode or use a Node.js version greater than 4.
Unhandled Rejection (TypeError): Cannot read property 'then' of undefined
This typically happens if `bundleAssets` was called in a `steal-bundler` version prior to v0.3.3, which might not have consistently returned a `Promise`, or if the `buildResult` object passed to it was invalid or incomplete (e.g., from an unawaited `stealTools.build` call).
fixEnsure `steal-bundler` is at version 0.3.3 or higher. Verify that the `buildResult` object passed to `bundleAssets` is a valid output from `stealTools.build` and is awaited properly if `stealTools.build` is asynchronous.
Audit
Dependencies
steal-toolsrequiredRequired to generate the 'buildResult' object that steal-bundler operates on. This is a runtime dependency for the build process.