isPureExport

tcmts.cli.npm.isPureExport · #leajd4yb · term · runs on the server

uses tcmts.cli.npm.npmFacts, which uses node:path

An npm package's export whose code, through everything it uses, renders the same for the same arguments on the server: it reaches nothing outside (#arkyikhq), holds no state, uses no browser globals, and nothing of it couldn't be followed. (Node's modules it uses for that are fine: node:path.)

import { npmFacts } from "#codebase/tcmts/cli/npm";
import type { ExtRef } from "#codebase/tcmts/core/types";

export function isPureExport(cacheDir: string, ext: ExtRef): boolean {
  const f = npmFacts(cacheDir, ext, "server");
  return !!f && !f.effects.length && !f.state && !f.dom.length && !f.opaque.length;
}

uses

used by