loader.mjs — drizzle-orm Source File
Architecture documentation for loader.mjs, a javascript file in the drizzle-orm codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR e576d3e3_66a6_6510_87d7_76e665e848ff["loader.mjs"] 5abc9a84_b390_cd74_47c2_eb5116e8fe7e["esbuild"] e576d3e3_66a6_6510_87d7_76e665e848ff --> 5abc9a84_b390_cd74_47c2_eb5116e8fe7e 9a46d98d_eb2d_c1e4_a37b_506dd514a6a7["fs"] e576d3e3_66a6_6510_87d7_76e665e848ff --> 9a46d98d_eb2d_c1e4_a37b_506dd514a6a7 412eac48_6e13_8b0f_b7b2_5c943c225130["path"] e576d3e3_66a6_6510_87d7_76e665e848ff --> 412eac48_6e13_8b0f_b7b2_5c943c225130 style e576d3e3_66a6_6510_87d7_76e665e848ff fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import esbuild from 'esbuild';
import { readFileSync } from 'fs';
import * as path from 'path';
const parse = (it) => {
if (!it) return { drizzle: false };
if (it.endsWith('__drizzle__')) {
const offset = it.startsWith('file://') ? 'file://'.length : 0;
const clean = it.slice(offset, -'__drizzle__'.length);
return { drizzle: true, clean, original: it };
}
return { drizzle: false, clean: it };
};
export function resolve(specifier, context, nextResolve) {
const { drizzle, clean } = parse(specifier);
if (drizzle && !clean.endsWith('.ts') && !clean.endsWith('.mts')) {
return nextResolve(clean);
}
if (drizzle) {
return {
shortCircuit: true,
url: `file://${specifier}`,
};
}
const parsedParent = parse(context.parentURL);
const parentURL = parsedParent.drizzle
? new URL(`file://${path.resolve(parsedParent.clean)}`)
: context.parentURL;
// Let Node.js handle all other specifiers.
return nextResolve(specifier, { ...context, parentURL });
}
export async function load(url, context, defaultLoad) {
const { drizzle, clean } = parse(url);
if (drizzle) {
const file = readFileSync(clean, 'utf-8');
if (clean.endsWith('.ts') || clean.endsWith('.mts')) {
const source = esbuild.transformSync(file, {
loader: 'ts',
format: 'esm',
});
return {
format: 'module',
shortCircuit: true,
source: source.code,
};
}
}
// let Node.js handle all other URLs
return defaultLoad(url, context, defaultLoad);
}
Domain
Subdomains
Dependencies
- esbuild
- fs
- path
Source
Frequently Asked Questions
What does loader.mjs do?
loader.mjs is a source file in the drizzle-orm codebase, written in javascript. It belongs to the DrizzleKit domain, Introspection subdomain.
What functions are defined in loader.mjs?
loader.mjs defines 3 function(s): load, parse, resolve.
What does loader.mjs depend on?
loader.mjs imports 3 module(s): esbuild, fs, path.
Where is loader.mjs in the architecture?
loader.mjs is located at drizzle-kit/src/loader.mjs (domain: DrizzleKit, subdomain: Introspection, directory: drizzle-kit/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free