CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-ember-resolver

The default modules based resolver for Ember CLI that handles module lookup and dependency resolution.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

module-registry.mddocs/

Module Registry

Module registry system for managing available modules and providing lookup capabilities. Supports both dynamic RequireJS-based registries and static module collections.

Capabilities

ModuleRegistry Class

Registry interface for managing and accessing available modules in Ember applications.

/**
 * Registry for managing module entries and lookups
 */
class ModuleRegistry {
  /** Internal module entries storage */
  _entries: object;
}

Constructor

Creates a module registry with optional entries object.

/**
 * Creates registry with optional entries object
 * @param entries - Optional entries object, defaults to globalThis.requirejs.entries
 */
constructor(entries?: object): ModuleRegistry;

Usage Examples:

import { ModuleRegistry } from "ember-resolver";

// Create registry with RequireJS entries
const registry = new ModuleRegistry();

// Create registry with custom entries
const customRegistry = new ModuleRegistry({
  "my-app/components/hello": HelloComponent,
  "my-app/routes/application": ApplicationRoute
});

Registry Methods

Core methods for interacting with the module registry.

/**
 * Returns array of all module names in the registry
 * @returns Array of module names
 */
moduleNames(): string[];

/**
 * Checks if module exists in registry
 * @param moduleName - Name of module to check
 * @returns Boolean indicating if module exists
 */
has(moduleName: string): boolean;

/**
 * Gets module using require function
 * @param ...args - Arguments passed to require function
 * @returns Required module
 */
get(...args: any[]): any;

Usage Examples:

import { ModuleRegistry } from "ember-resolver";

const registry = new ModuleRegistry({
  "my-app/components/user-card": UserCardComponent,
  "my-app/components/nav-bar": NavBarComponent,
  "my-app/routes/posts": PostsRoute
});

// Get all module names
const moduleNames = registry.moduleNames();
console.log(moduleNames);
// Output: ["my-app/components/user-card", "my-app/components/nav-bar", "my-app/routes/posts"]

// Check if module exists
const hasUserCard = registry.has("my-app/components/user-card");
console.log(hasUserCard); // Output: true

const hasUnknown = registry.has("my-app/components/unknown");
console.log(hasUnknown); // Output: false

// Get a module
const UserCard = registry.get("my-app/components/user-card");

Dynamic Registry Integration

When used without explicit entries, ModuleRegistry integrates with RequireJS/AMD module systems.

// Automatic RequireJS integration
const resolver = Resolver.create({
  namespace: { modulePrefix: "my-app" }
});

// The resolver automatically creates a ModuleRegistry that uses:
// - globalThis.requirejs.entries for module discovery
// - globalThis.require for module loading

Static Module Registry

For resolvers created with Resolver.withModules(), a custom registry interface is used.

const StaticResolver = Resolver.withModules({
  "my-app/components/hello": HelloComponent,
  "my-app/routes/application": ApplicationRoute
});

const resolver = StaticResolver.create();

// Internal registry interface provides:
// - moduleNames(): returns Object.keys() of explicit modules
// - has(name): checks Boolean(explicitModules[name])
// - get(name): returns explicitModules[name]
// - addModules(modules): merges additional modules

Registry Interface

The internal registry interface used by the resolver system.

interface RegistryInterface {
  /** Returns all available module names */
  moduleNames(): string[];
  /** Checks if a module exists */
  has(name: string): boolean;
  /** Gets a module by name */
  get(name: string): any;
  /** Adds additional modules (static registries only) */
  addModules?(modules: Record<string, unknown>): void;
}

Install with Tessl CLI

npx tessl i tessl/npm-ember-resolver

docs

core-resolution.md

index.md

module-registry.md

string-utilities.md

tile.json