Registry / devops / steal-bundler

steal-bundler

JSON →
library0.3.6jsnpmunverified

steal-bundler is a utility package designed to integrate with steal-tools for projects utilizing the StealJS module loader. Its primary function is to automatically identify and bundle static assets (like images) alongside JavaScript and CSS files during the build process, facilitating deployment to CDNs. The current stable version is 0.3.6, with recent releases (v0.3.x) focusing on bug fixes and compatibility rather than new features, suggesting a maintenance release cadence. A key differentiator is its automatic inference of static assets from the project's codebase, though manual glob patterns can also be specified. It's an integral part of the StealJS build pipeline, streamlining asset management for applications built with StealJS and steal-tools. It operates primarily in a CommonJS environment, typical for StealJS projects.

npm install steal-bundler
INSTALL
IMPORT
SIG · STEAL-BUNDLER
S
steal-bundler
devopsjavascriptv0.3.6
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.

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();
Debug
Known issues
gotchaPrior to v0.3.6, `steal-bundler` had a bug where it might incorrectly move bundled assets to a location outside the designated `dest` folder defined in `steal-tools` build options. This could lead to broken references to assets in the deployed application.
fix
Upgrade to `steal-bundler` version 0.3.6 or newer to ensure assets are correctly placed within the specified destination directory, maintaining correct paths relative to your build output.
affects: <0.3.6
gotchaVersions of `steal-bundler` older than v0.3.3 did not consistently return a `Promise` from the `bundleAssets` function, which is expected by the `steal-tools` API for asynchronous operations. This could cause issues with promise chaining or subsequent build steps that rely on its completion.
fix
Upgrade `steal-bundler` to v0.3.3 or newer. This ensures that `bundleAssets` reliably returns a `Promise`, allowing for proper async/await or `.then()` chaining in your build scripts.
affects: <0.3.3
gotchaThe `infer` option, which automatically detects static assets from your JavaScript and CSS, is `true` by default. While convenient, this might include unintended files or miss assets in non-standard locations. It's important to review inferred assets or explicitly manage them.
fix
To gain explicit control over which assets are bundled, set `infer: false` in the `bundleAssets` options and use the `glob` option to specify exact files or patterns. Example: `bundleAssets(buildResult, { infer: false, glob: ['static/**/*', 'favicons/**/*'] });`
affects: >=0.1.0
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.
fix
Upgrade `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).
fix
Ensure `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.
Upgrade
Version history
0.3.6latest on npm
Audit
Dependencies
steal-toolsrequiredRequired to generate the 'buildResult' object that steal-bundler operates on. This is a runtime dependency for the build process.
Agent activity
5 hits · last 30 days
node
4
Resources
steal-bundler — npm install steal-bundler · libregistry