@visulima/packem
Version:
A fast and modern bundler for Node.js and TypeScript.
116 lines (115 loc) • 3.71 kB
TypeScript
import type { Loader } from "esbuild";
/**
* Default file extensions that Packem will process.
* Includes JavaScript (ES modules and CommonJS), TypeScript, and their respective JSX/TSX variants.
*
* @remarks
* These extensions are used to determine which files should be processed by the bundler.
* The order of extensions matters for resolution priority.
*
* @example
* ```ts
* // Will match files like:
* // - index.mjs
* // - component.tsx
* // - utils.cts
* ```
*/
export declare const DEFAULT_EXTENSIONS: string[];
/**
* Default esbuild loaders configuration for different file extensions.
* Maps file extensions to their corresponding esbuild loader type.
*
* @remarks
* - 'file' loader is used for static assets that should be emitted as-is
* - 'js', 'jsx', 'ts', 'tsx' loaders are used for their respective file types
*
* @example
* ```ts
* // Usage:
* const loader = DEFAULT_LOADERS[".tsx"]; // Returns "tsx"
* ```
*/
export declare const DEFAULT_LOADERS: Record<string, Loader>;
/**
* Constant representing the production environment.
* Used for environment-specific optimizations and configurations.
*
* @constant
*/
export declare const PRODUCTION_ENV = "production";
/**
* Constant representing the development environment.
* Used for environment-specific features like source maps and debug information.
*
* @constant
*/
export declare const DEVELOPMENT_ENV = "development";
/**
* Set of runtime export conventions for special handling.
* These conventions determine how exports are processed for different runtime targets.
*
* @remarks
* Currently supports:
* - react-server: For React Server Components
* - react-native: For React Native platform
* - edge-light: For Edge runtime environments
*/
export declare const RUNTIME_EXPORT_CONVENTIONS: Set<string>;
/**
* Combined set of all special export conventions including runtime and environment-specific ones.
*
* @remarks
* Includes both runtime conventions and environment types (production/development).
* Used for determining special processing rules during bundling.
*/
export declare const SPECIAL_EXPORT_CONVENTIONS: Set<string>;
/**
* Regular expression to exclude node_modules from certain processing steps.
*
* @remarks
* Used to skip processing of node_modules files when not necessary,
* improving build performance.
*/
export declare const EXCLUDE_REGEXP: RegExp;
/**
* Regular expression to match file extensions, including TypeScript declaration files.
*
* @remarks
* Used for file extension detection and manipulation.
* Matches:
* - TypeScript declaration files (.d.ts, .d.mts, .d.cts)
* - Any file extension starting with a dot
*/
export declare const ENDING_RE: RegExp;
/**
* Directory name for storing chunk files generated by Packem.
*
* @remarks
* This directory contains dynamically generated chunk files for code splitting.
*/
export declare const CHUNKS_PACKEM_FOLDER = "packem_chunks";
/**
* Directory name for storing shared resources.
*
* @remarks
* This directory contains shared resources that are used across multiple chunks
* or entry points.
*/
export declare const SHARED_PACKEM_FOLDER = "packem_shared";
/**
* Regular expression to match file extensions that can be transformed.
*
* @remarks
* Matches JavaScript and TypeScript files, including their module variants:
* - .js, .mjs, .cjs
* - .ts, .mts, .cts
* - .jsx, .tsx (and their module variants)
*
* @example
* ```ts
* const canTransform = ALLOWED_TRANSFORM_EXTENSIONS_REGEX.test("file.ts"); // true
* const canTransform = ALLOWED_TRANSFORM_EXTENSIONS_REGEX.test("file.css"); // false
* ```
*/
export declare const ALLOWED_TRANSFORM_EXTENSIONS_REGEX: RegExp;