{"id":27730,"library":"extra-build","title":"extra-build","description":"Common build tools for extra-* packages, providing a JavaScript API for building TypeScript-based libraries. Version 2.3.1 is current. It offers utility functions for generating JavaScript and type declarations, bundling scripts, managing package metadata, executing shell commands, handling git operations (commit+push, branch setup), parsing GitHub URLs, updating repo details, logging with colors, and reading/writing text/JSON files. Unlike a CLI-based approach, this redesigned version provides flexibility via a programmable API, suitable for CI systems like GitHub Actions. It includes functions like bundleScript, webifyScript, exec, gitCommitPush, and updateGithubRepoDetails.","status":"active","version":"2.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/nodef/extra-build","tags":["javascript","extra","build","BundleOptions","DocsDetails","Document","ExecOptions","GitCommitPushOptions","GitSetupBranchOptions","typescript"],"install":[{"cmd":"npm install extra-build","lang":"bash","label":"npm"},{"cmd":"yarn add extra-build","lang":"bash","label":"yarn"},{"cmd":"pnpm add extra-build","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only since v2. Use named imports.","wrong":"const bundleScript = require('extra-build').bundleScript","symbol":"bundleScript","correct":"import { bundleScript } from 'extra-build'"},{"note":"All functions are exported from the main entrypoint; no subpath imports.","wrong":"const exec = require('extra-build/exec')","symbol":"exec","correct":"import { exec } from 'extra-build'"},{"note":"Also available as default export? No, only named exports in v2+.","wrong":null,"symbol":"readMetadata","correct":"import { readMetadata } from 'extra-build'"},{"note":"Do not use default import; writeMetadata is a named export.","wrong":"import writeMetadata from 'extra-build'","symbol":"writeMetadata","correct":"import { writeMetadata } from 'extra-build'"},{"note":"No submodules; all exports are flat.","wrong":"import { gitCommitPush } from 'extra-build/git'","symbol":"gitCommitPush","correct":"import { gitCommitPush } from 'extra-build'"}],"quickstart":{"code":"import { bundleScript, exec, writeMetadata, readMetadata } from 'extra-build';\nimport { writeFileSync } from 'fs';\n\nasync function build() {\n  // Bundle source script\n  const bundledCode = await bundleScript({\n    input: 'src/index.ts',\n    format: 'esm',\n    target: 'es2020'\n  });\n  writeFileSync('dist/index.js', bundledCode);\n\n  // Execute a shell command\n  const output = await exec('echo Hello', { cwd: '.' });\n\n  // Read and update package.json\n  const meta = await readMetadata();\n  meta.version = '1.0.0';\n  await writeMetadata(meta);\n}\n\nbuild().catch(console.error);","lang":"typescript","description":"Demonstrates bundling a TypeScript source file, executing a shell command, and reading/writing package.json using extra-build API."},"warnings":[{"fix":"Ensure all calls to extra-build functions are awaited.","message":"All functions are async; forgetting await leads to unresolved promises.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Migrate from CLI usage to JavaScript API; use import instead of require.","message":"v2 removed the CLI and changed from CommonJS to ESM-only.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Set declaration: true in the options object passed to bundleScript.","message":"bundleScript does not bundle type declarations by default; must be explicitly configured.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Prefer readFileText/writeFileText or readJson/writeJson for stable file I/O.","message":"readDocument and writeDocument are experimental and may be removed in a future version.","severity":"deprecated","affected_versions":">=2.1.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Add \"type\": \"module\" to package.json, or use dynamic import(): const { bundleScript } = await import('extra-build').","cause":"Package is ESM-only; project may be using CommonJS or missing typeRoots.","error":"Cannot find module 'extra-build' or its corresponding type declarations."},{"fix":"Use import { bundleScript } from 'extra-build' instead of import bundleScript from 'extra-build'.","cause":"The named import is incorrect; usually default import used.","error":"TypeError: bundleScript is not a function"},{"fix":"All exports are at top-level: import { gitCommitPush, gitSetupBranch } from 'extra-build' directly.","cause":"Trying to import from a subpath that doesn't exist.","error":"Error: Cannot find module 'extra-build/git'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}