{"library":"steal-bundler","title":"StealJS Asset Bundler","type":"library","description":"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.","language":"javascript","status":"maintenance","last_verified":"Sun Apr 19","install":{"commands":["npm install steal-bundler"],"cli":null},"imports":["const bundleAssets = require('steal-bundler');","const bundleAssets = require('steal-bundler');","const bundleAssets = require('steal-bundler');"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/stealjs/steal-bundler","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/steal-bundler","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"const stealTools = require(\"steal-tools\");\nconst bundleAssets = require(\"steal-bundler\");\n\n// For a real project, stealTools.build would generate this dynamically.\n// We mock a simple buildResult object for a runnable quickstart without\n// requiring steal-tools to be installed or a full StealJS project setup.\nconst mockBuildResult = {\n  configuration: {\n    main: 'app',\n    paths: {'@empty': '@empty'}\n  },\n  graph: { /* populated graph from build */ },\n  bundles: [] // steal-bundler adds to this\n};\n\nasync function buildAndBundleAssets() {\n  try {\n    console.log('Simulating the stealTools.build process by using a mock buildResult...');\n    const buildResult = mockBuildResult; // Use the mock for demonstration.\n\n    console.log('Starting asset bundling with steal-bundler...');\n    // bundleAssets returns a Promise, which should be awaited for proper sequencing.\n    const finalBuildResult = await bundleAssets(buildResult, {\n      // This glob pattern targets all files within an 'images' directory.\n      // Adjust based on your project's static asset structure.\n      glob: \"images/**/*\",\n      infer: true // Set to false if you want to rely only on the 'glob' option\n    });\n    console.log('Asset bundling completed successfully. Final build result (truncated):', {\n      bundlesCount: finalBuildResult.bundles.length,\n      graphNodes: Object.keys(finalBuildResult.graph).length\n    });\n  } catch (error) {\n    console.error('An error occurred during the build and bundling process:', error);\n  }\n}\n\nbuildAndBundleAssets();","lang":"javascript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}