UNPKG

@visulima/packem

Version:

A fast and modern bundler for Node.js and TypeScript.

65 lines (64 loc) 2.49 kB
import type { PackageJson } from "@visulima/package"; import type { Pail } from "@visulima/pail"; import type { TsConfigResult } from "@visulima/tsconfig"; import type { Plugin } from "rollup"; import type { InternalBuildOptions } from '../../types.d.ts'; type MaybeFalsy<T> = T | undefined | null | false; export type ResolveExternalsPluginOptions = { /** * Mark node built-in modules like `path`, `fs`... as external. * * Set the builtins option to false if you'd like to use some shims/polyfills for those. * * How to handle the node: scheme used in recent versions of Node (i.e., import path from 'node:path'). * If add (the default, recommended), the node: scheme is always added. In effect, this dedupes your imports of Node builtins by homogenizing their names to their schemed version. * If strip, the scheme is always removed. In effect, this dedupes your imports of Node builtins by homogenizing their names to their unschemed version. Schemed-only builtins like node:test are not stripped. * ignore will simply leave all builtins imports as written in your code. * * Note that scheme handling is always applied, regardless of the builtins options being enabled or not. * * @default true */ builtins?: boolean; /** * node: prefix handing for importing Node builtins: * - `'add'` turns `'path'` to `'node:path'` * - `'strip'` turns `'node:path'` to `'path'` * - `'ignore'` leaves Node builtin names as-is * * @default "add" */ builtinsPrefix?: "add" | "strip" | "ignore"; /** * Mark dependencies as external. * * Defaults to `true`. */ deps?: boolean; /** * Mark devDependencies as external. * * Defaults to `false`. */ devDeps?: boolean; /** * Force exclude these deps from the list of externals, regardless of other settings. * * Defaults to `[]` (force exclude nothing). */ exclude?: MaybeFalsy<string | RegExp>[]; /** * Mark optionalDependencies as external. * * Defaults to `true`. */ optDeps?: boolean; /** * Mark peerDependencies as external. * * Defaults to `true`. */ peerDeps?: boolean; }; export declare const resolveExternalsPlugin: (packageJson: PackageJson, tsconfig: TsConfigResult | undefined, buildOptions: InternalBuildOptions, logger: Pail, options: ResolveExternalsPluginOptions) => Plugin; export {};