{"id":27219,"library":"packager","title":"Packager","description":"A browser-based trans-bundler that runs entirely in the browser, enabling code transformation and bundling without a server. Current version 0.1.9. It leverages existing bundler concepts for client-side use, focusing on ease of integration and in-browser workflows. Differentiates from server-side bundlers by operating fully in the browser environment, making it suitable for online editors or prototyping tools.","status":"active","version":"0.1.9","language":"javascript","source_language":"en","source_url":"https://github.com/baryla/packager","tags":["javascript","typescript"],"install":[{"cmd":"npm install packager","lang":"bash","label":"npm"},{"cmd":"yarn add packager","lang":"bash","label":"yarn"},{"cmd":"pnpm add packager","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only; does not support CommonJS require.","wrong":"const packager = require('packager')","symbol":"packager","correct":"import packager from 'packager'"},{"note":"BundleOptions is a TypeScript type only; use 'import type' for type imports.","wrong":"import { BundleOptions } from 'packager'","symbol":"BundleOptions","correct":"import type { BundleOptions } from 'packager'"},{"note":"bundle is a named export, not default. Ensure destructured import.","wrong":"import bundle from 'packager'","symbol":"bundle","correct":"import { bundle } from 'packager'"}],"quickstart":{"code":"import { bundle } from 'packager';\n\nconst code = `\nimport { foo } from './foo';\nconsole.log(foo);\n`;\n\nasync function run() {\n  const result = await bundle(code, {\n    resolve: (specifier) => {\n      if (specifier === './foo') {\n        return { code: 'export const foo = \"bar\";' };\n      }\n      throw new Error(`Cannot resolve ${specifier}`);\n    }\n  });\n  console.log(result.code);\n}\nrun();","lang":"typescript","description":"Shows how to bundle a simple ES module string with a custom resolver, outputting the transformed code."},"warnings":[{"fix":"Always provide a 'resolve' function that returns an object with a 'code' property for each imported module.","message":"The 'resolve' option is required; omitting it causes a runtime error.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Use 'await' or '.then()' when calling 'bundle'.","message":"The 'bundle' function returns a Promise, not a synchronous result.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Replace 'import { transform } from 'packager'' with 'import { bundle } from 'packager'' and adjust usage.","message":"Export 'transform' is deprecated; use 'bundle' instead.","severity":"deprecated","affected_versions":">=0.1.5"},{"fix":"Ensure your resolve function returns an object with 'code' (string) and optionally 'map' (object). For now, 'code' is sufficient but prepare to add 'map' eventually.","message":"In version 0.1.9, the 'resolve' callback must return an object with both 'code' and 'map' properties; returning only 'code' will be removed in future.","severity":"breaking","affected_versions":"0.1.9"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use 'import packager from 'packager'' or 'import { bundle } from 'packager'' in an ESM context.","cause":"Using CommonJS require instead of ESM import.","error":"TypeError: packager is not a function"},{"fix":"Make sure 'resolve' returns an object with a 'code' property containing the module's source code as a string.","cause":"The 'resolve' function did not return an object with 'code' property.","error":"Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'code')"},{"fix":"Run 'npm install packager' (or yarn/pnpm equivalent).","cause":"Packager is not installed or not in node_modules.","error":"Module not found: Error: Can't resolve 'packager'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}