Nundler (Not a Bundler)

0.2.0 · active · verified Sun Apr 19

Nundler (version 0.2.0) is an early-stage utility designed for JavaScript and TypeScript projects that explicitly aim to *avoid* traditional bundling paradigms, or for workflows where fine-grained control over module resolution and dependency analysis is preferred over monolithic output. Instead of merging and optimizing code into a single or few output files, Nundler focuses on assisting developers in understanding and managing module graphs in an unbundled context. Its release cadence is currently unpredictable given its alpha status. Key differentiators include its focus on unbundled environments, potentially offering tools for dynamic import analysis, dependency introspection, or optimized loading strategies without modifying source code for bundling purposes. This tool could be beneficial for scenarios like serverless functions with strict individual file size limits, or development environments emphasizing native ESM module loading directly in Node.js.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to use `analyzeDependencies` to inspect a project's module graph without bundling, logging a summary of internal and external dependencies.

import { analyzeDependencies } from 'nundler';
import * as path from 'node:path';
import * as fs from 'node:fs/promises';

async function main() {
  const projectRoot = process.cwd(); // Or a specific path, e.g., './src'
  console.log(`Analyzing dependencies in: ${projectRoot}`);

  try {
    const analysisResult = await analyzeDependencies(projectRoot, {
      entryPoints: ['index.js', 'main.ts'], // Specify your main entry points
      ignoreNodeModules: true,
      // further options to control analysis depth or file types
    });

    console.log('--- Dependency Graph Summary ---');
    if (analysisResult.graph) {
      console.log(`Total modules found: ${analysisResult.graph.nodes.length}`);
      console.log(`Total dependencies: ${analysisResult.graph.edges.length}`);
      // Example: Log unique external dependencies
      const externalDeps = new Set(analysisResult.graph.edges
        .filter(edge => edge.type === 'external')
        .map(edge => edge.target));
      console.log('External dependencies:', Array.from(externalDeps).join(', '));
    } else {
      console.log('No dependency graph generated, check entry points and options.');
    }

    if (analysisResult.errors && analysisResult.errors.length > 0) {
      console.warn('\n--- Warnings/Errors during analysis ---');
      analysisResult.errors.forEach(err => console.warn(`- ${err.message} (File: ${err.file})`));
    }

  } catch (error) {
    console.error('An error occurred during analysis:', error);
  }
}

main().catch(console.error);

view raw JSON →