The entry points
{
"type": "module",
"main": "./dist/index.cjs",
"exports": {
".": {
"import": "./src/index.js", // ESM gets the source
"require": "./dist/index.cjs" // CJS gets the bundle
}
},
"engines": { "node": ">=18" }
}# Python has no ESM/CommonJS split: one package, one import path.
# Your own pyproject.toml only declares the dependency:
#
# [project]
# name = "my-app"
# requires-python = ">=3.10"
# dependencies = ["iagenify>=0.1.0"]
from iagenify import IaGenifyimport reads the published source, so stack traces point at real files inside the package. require reads a single pre-bundled file.
Node builtins stay external
Neither entry point inlines node:fs, node:os, node:path, node:crypto or node:child_process. They are imported at runtime, behind a check, which is what lets the same file load where they do not exist: the import simply fails and the SDK uses the fallback for that runtime.
The practical consequence is in your bundler config, not in your code — see Install.
Mixing the two
In a CommonJS file, the named exports come off the object. In an ESM file, named imports work directly. Both give the same classes, so instanceof holds — as long as one process loads one of the two, not both.
// CommonJS
const { IaGenify, NotEnoughCredits } = require("iagenify");
// CommonJS reaching for the ESM entry point, when you need it
const { IaGenify } = await import("iagenify");# Python has one import statement for every kind of script
from iagenify import IaGenify, NotEnoughCredits
# Importing lazily, when you need it
import importlib
iagenify = importlib.import_module("iagenify")A value thrown by the ESM copy is not an instanceof the CJS copy's class. The error still carries name, status and code, so test those if you cannot avoid the mix.
TypeScript
The package ships no type declarations. Under moduleResolution: "bundler" or "node16" the import resolves; the shapes are untyped.
// iagenify.d.ts — enough to stop the compiler complaining
declare module "iagenify" {
export class IaGenify {
constructor(options: {
apiKey?: string; baseUrl?: string; storage?: unknown;
sessionPath?: string; appName?: string; timeout?: number;
});
[key: string]: any;
}
export class IaGenifyError extends Error { status: number; code: string; details?: unknown }
export class Unauthorized extends IaGenifyError {}
export class NotEnoughCredits extends IaGenifyError { required: number; available: number }
}# Type checkers read the package's Python signatures directly:
# no separate declaration file is needed.
from iagenify import IaGenify, IaGenifyError, Unauthorized, NotEnoughCredits
api: IaGenify = IaGenify(api_key=api_key, base_url=None, session_path=None, app_name=None, timeout=60)
try:
api.get_user()
except NotEnoughCredits as error: # error.required, error.available
...
except IaGenifyError as error: # error.status, error.code, error.details
...