Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ollm/opencomic-ai-models/llms.txt

Use this file to discover all available pages before exploring further.

The opencomic-ai-models package ships both an ESM build (dist/index.mjs) and a CommonJS build (dist/index.cjs), alongside a TypeScript declaration file (dist/index.d.ts). Node.js automatically selects the correct build based on your project’s module system, so the package works in any modern Node.js project without extra configuration.

Importing the package

import OpenComicAIModels from 'opencomic-ai-models';

const { path } = OpenComicAIModels;

console.log(path); // absolute path to the bundled models directory
To use the ESM import syntax in a Node.js project, add "type": "module" to your package.json, or rename your file to use the .mjs extension. CJS require works without any extra settings in standard Node.js projects.

TypeScript declaration

The package exports a single default object. The TypeScript declaration mirrors the runtime shape exactly:
declare const OpenComicAIModels: {
    path: string;
};

export default OpenComicAIModels;
path is always typed as string — it is a fully resolved absolute path computed at module load time.

Package exports field

The package.json exports field tells Node.js (and bundlers) which build to load for each module system:
{
  "exports": {
    "import": "./dist/index.mjs",
    "require": "./dist/index.cjs"
  },
  "types": "./dist/index.d.ts"
}
When you write import OpenComicAIModels from 'opencomic-ai-models', Node.js resolves to dist/index.mjs. When you write require('opencomic-ai-models'), it resolves to dist/index.cjs. TypeScript reads dist/index.d.ts for type information in both cases.

Resolving the path at runtime

The path value is computed once when the module is first loaded, using Node.js’s built-in path.join:
// Simplified view of the internal resolution logic (from index.mts)
import p from 'path';

const ___dirname =
  typeof __dirname !== 'undefined'
    ? __dirname                  // CJS — __dirname is available natively
    : import.meta.dirname;       // ESM — use import.meta.dirname (Node 21.2+)

const path: string = p.join(___dirname, '../', 'models');
Because the path is anchored to the compiled file’s own location inside node_modules/opencomic-ai-models/dist/, it always points to the correct models/ directory regardless of your project’s working directory or how you invoke the process. You do not need to construct or hard-code the path yourself.

Build docs developers (and LLMs) love