{"library":"scribunto-bundler","title":"Scribunto Bundler","description":"scribunto-bundler is a TypeScript-written Lua bundler specifically designed for MediaWiki's Scribunto extension. It automates the process of resolving `require` statements within Lua modules, consolidating them into a single output file suitable for deployment on MediaWiki wikis. The current stable version is 0.2.7, with the project demonstrating a rapid release cadence, frequently publishing patch and minor versions, suggesting active development and iterative improvements. Key differentiators include its explicit support for Scribunto environments, automatic `require` statement detection, and compatibility with both `.lua` and `.luau` file extensions. It offers a command-line interface for scaffolding new projects and bundling existing ones, configurable via a `bundler.config.js` file, which is type-hinted for improved developer experience.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install scribunto-bundler"],"cli":{"name":"scribunto-bundler","version":null}},"imports":["import type { Config } from 'scribunto-bundler'","import { bundle } from 'scribunto-bundler'","import { createProject } from 'scribunto-bundler'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { bundle } from 'scribunto-bundler';\nimport fs from 'node:fs/promises';\n\n// 1. Install globally for CLI, then locally for project-specific use\n// npm install -g scribunto-bundler\n// npx scribunto-bundler --create // Creates project and installs locally\n\n// 2. Configure bundler.config.js (example)\n/*\n// bundler.config.js\n/** @type {import(\"scribunto-bundler\").Config} */\n/*\nexport default {\n  prefix: '-- Bundled by scribunto-bundler\\n', // Optional prefix text\n  suffix: '\\n-- End of bundle', // Optional suffix text\n  main: 'src/main.lua', // Path to your main Lua module\n  out: 'dist/bundled.lua', // Output path for the bundled file\n};\n*/\n\n// 3. Example of a programmatic bundle (alternative to `npm run bundle`)\nasync function runBundleProgrammatically() {\n  // In a real scenario, you'd read from bundler.config.js\n  const config = {\n    prefix: '-- My Awesome Scribunto Module\\n', // Example prefix\n    suffix: '\\n-- Generated: ' + new Date().toISOString(), // Example suffix\n    main: 'src/main.lua', // Your main Lua file\n    out: 'dist/bundled-programmatic.lua', // Output file\n  };\n\n  // Ensure source files exist for demonstration\n  await fs.mkdir('src', { recursive: true });\n  await fs.writeFile('src/main.lua', 'local myutil = require(\\'myutil\\'); return myutil.add(1, 2)');\n  await fs.writeFile('src/myutil.lua', 'local M = {}; function M.add(a, b) return a + b end; return M;');\n\n  try {\n    await bundle(config);\n    console.log(`Successfully bundled to ${config.out}`);\n    const bundledCode = await fs.readFile(config.out, 'utf-8');\n    console.log('Bundled Code:\\n', bundledCode);\n  } catch (error) {\n    console.error('Bundling failed:', error);\n  }\n}\n\nrunBundleProgrammatically();\n","lang":"typescript","description":"Demonstrates how to set up, configure, and perform a programmatic bundle of a basic Scribunto Lua project. It outlines both CLI setup and direct API usage for advanced scenarios.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}