CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-sveltejs--adapter-auto

SvelteKit adapter that automatically detects deployment environment and installs appropriate platform-specific adapter

Overall
score

96%

Overview
Eval results
Files

task.mdevals/scenario-5/

Package Resolver Utility

A utility function that resolves package paths in the node_modules hierarchy, supporting both scoped and non-scoped packages with export path resolution.

Capabilities

Resolves package names with scope handling

Handles both scoped packages (e.g., @scope/package-name) and non-scoped packages.

  • Given @sveltejs/kit, it locates the package at node_modules/@sveltejs/kit @test
  • Given lodash, it locates the package at node_modules/lodash @test

Traverses directory hierarchy

Searches up the directory tree from a starting point to find packages in parent node_modules folders.

  • When starting from a nested directory without node_modules, it finds the package in a parent directory's node_modules @test
  • When the package doesn't exist in any ancestor's node_modules up to the root, it throws an error @test

Resolves subpackage exports

Reads package.json exports field to resolve subpackage import paths.

  • Given @sveltejs/kit/vite, it reads package.json and resolves to the path specified in the exports field @test
  • When exports has nested conditions like {import: './path.js', default: './other.js'}, it resolves import first, then default @test

Validates and handles resolution errors

Provides clear error messages when resolution fails.

  • When a subpackage export doesn't exist in package.json, it throws an error indicating the missing export @test

Implementation

@generates

API

/**
 * Resolves a package path in the node_modules hierarchy.
 * Supports both scoped (@scope/name) and non-scoped (name) packages.
 * Can resolve subpackage paths using package.json exports.
 *
 * @param {string} packageName - The package name to resolve (e.g., 'express', '@sveltejs/kit', '@sveltejs/kit/vite')
 * @param {string} [startDir] - The directory to start searching from (defaults to process.cwd())
 * @returns {string} The absolute path to the resolved package or export
 * @throws {Error} When package cannot be found or export doesn't exist
 */
function resolvePackage(packageName, startDir = process.cwd()) {
  // Implementation here
}

module.exports = { resolvePackage };

Dependencies { .dependencies }

@sveltejs/adapter-auto { .dependency }

Provides peer dependency resolution patterns and implementation reference.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-sveltejs--adapter-auto

tile.json