{"library":"rucksack-lite","title":"Rucksack Lite Resource Management Core","description":"rucksack-lite is a JavaScript library providing the foundational `RucksackLite` class for managing and preparing JavaScript and CSS resources. It serves as the core resource abstraction layer, differentiating it from actual bundlers, and is utilized by the more comprehensive `rucksack` bundler package. Currently at version 6.0.0, the library underwent a complete rewrite in this major release, focusing on robust handling of both local and remote resources. It defines a `RucksackResource` class internally for managing resource paths, types (JS/CSS), and generating the necessary HTML markup for inclusion. While its release cadence appears somewhat irregular, major versions signify active development with significant architectural shifts, such as licensing updates and full rewrites. Its primary differentiation lies in offering a clean, object-oriented API for resource management, abstracting away complexities of path resolution and markup generation prior to the actual bundling process.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install rucksack-lite"],"cli":null},"imports":["import RucksackLite from 'rucksack-lite'","import { RucksackResource } from 'rucksack-lite'","const { default: RucksackLite } = await import('rucksack-lite');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import RucksackLite, { RucksackResource } from 'rucksack-lite';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nasync function setupRucksack() {\n  const r = new RucksackLite({\n    name: \"my-app\",\n    bundle_dir: path.resolve(__dirname, \"output\"), // Ensure an absolute path for bundle_dir\n    bundle_url: \"/static\",\n    input: \"main.js\" // This input file isn't created in this example, but defines the primary bundle.\n  });\n\n  // Add a remote JavaScript resource by URL string\n  r.add(\"https://example.com/index.js\");\n\n  // Add a remote CSS resource using the RucksackResource class for explicit typing\n  r.add(new RucksackResource({\n    path: \"https://example.com/styles.css\",\n    type: \"css\"\n  }));\n\n  // Generate the HTML markup (note: this does not perform actual bundling)\n  const htmlMarkup = r.html();\n  console.log('Generated HTML Markup:\\n', htmlMarkup);\n\n  // The `bundle()` method primarily processes local resources for path resolution\n  // It does NOT create actual bundled files without the full `rucksack` package and actual files.\n  try {\n    console.log('\\nAttempting to call bundle() (no actual files created in this quickstart):');\n    await r.bundle();\n    console.log('Bundle operation completed (paths resolved, if any local resources were added).');\n  } catch (error) {\n    console.warn('Bundle operation warning (expected without actual files/bundler):', error.message);\n  }\n\n  console.log('\\nRefreshed Markup after potential bundle operation:');\n  console.log(r.html());\n}\n\nsetupRucksack().catch(console.error);\n","lang":"javascript","description":"This quickstart demonstrates how to instantiate `RucksackLite`, add various types of resources (remote JS by string, remote CSS explicitly via `RucksackResource`), and generate the corresponding HTML markup. It highlights the resource management capabilities without performing actual file bundling, which is the domain of the `rucksack` package.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}