Registry / web-framework / packager

packager

JSON →
library0.1.9jsnpmunverified

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.

npm install packager
INSTALL
IMPORT
SIG · PACKAGER
P
packager
web-frameworkjavascriptv0.1.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

packager
import packager from 'packager'
const packager = require('packager')
Package is ESM-only; does not support CommonJS require.
BundleOptions
import type { BundleOptions } from 'packager'
import { BundleOptions } from 'packager'
BundleOptions is a TypeScript type only; use 'import type' for type imports.
bundle
import { bundle } from 'packager'
import bundle from 'packager'
bundle is a named export, not default. Ensure destructured import.

Shows how to bundle a simple ES module string with a custom resolver, outputting the transformed code.

import { bundle } from 'packager'; const code = ` import { foo } from './foo'; console.log(foo); `; async function run() { const result = await bundle(code, { resolve: (specifier) => { if (specifier === './foo') { return { code: 'export const foo = "bar";' }; } throw new Error(`Cannot resolve ${specifier}`); } }); console.log(result.code); } run();
Debug
Known issues
breakingThe 'resolve' option is required; omitting it causes a runtime error.
fix
Always provide a 'resolve' function that returns an object with a 'code' property for each imported module.
affects: >=0.1.0
gotchaThe 'bundle' function returns a Promise, not a synchronous result.
fix
Use 'await' or '.then()' when calling 'bundle'.
affects: >=0.1.0
deprecatedExport 'transform' is deprecated; use 'bundle' instead.
fix
Replace 'import { transform } from 'packager'' with 'import { bundle } from 'packager'' and adjust usage.
affects: >=0.1.5
breakingIn 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.
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.
affects: 0.1.9
Errors
Common errors & fixes
TypeError: packager is not a function
Using CommonJS require instead of ESM import.
fix
Use 'import packager from 'packager'' or 'import { bundle } from 'packager'' in an ESM context.
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'code')
The 'resolve' function did not return an object with 'code' property.
fix
Make sure 'resolve' returns an object with a 'code' property containing the module's source code as a string.
Module not found: Error: Can't resolve 'packager'
Packager is not installed or not in node_modules.
fix
Run 'npm install packager' (or yarn/pnpm equivalent).
Upgrade
Version history
0.1.9latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
packager — npm install packager · libregistry