UNPKG

tiny-essentials

Version:

Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.

92 lines 3.09 kB
export default TinyPluginInliner; export type RootReplacement = { /** * - The directory name to replace (e.g., 'src'). */ from: string; /** * - The directory name to insert (e.g., 'dist'). */ to: string; }; export type InlinerConfig = { /** * - The absolute or relative path to the entry file. */ entryPoint: string; /** * - The absolute or relative path to the output directory. */ outDir: string; /** * - The name of the generated bundle file. */ outFileName: string; /** * - Optional customization to remap project import roots. */ rootReplacement?: RootReplacement | undefined; }; /** * @typedef {Object} RootReplacement * @property {string} from - The directory name to replace (e.g., 'src'). * @property {string} to - The directory name to insert (e.g., 'dist'). */ /** * @typedef {Object} InlinerConfig * @property {string} entryPoint - The absolute or relative path to the entry file. * @property {string} outDir - The absolute or relative path to the output directory. * @property {string} outFileName - The name of the generated bundle file. * @property {RootReplacement} [rootReplacement] - Optional customization to remap project import roots. */ declare class TinyPluginInliner { /** * Creates an instance of the TinyPluginInliner. * * @param {InlinerConfig} config - The configuration object for the build process. */ constructor(config: InlinerConfig); config: InlinerConfig; entryFile: string; outDir: string; outFile: string; entryDir: string; hoistedImports: Set<any>; hoistedTypedefs: Set<any>; /** * Rewrites all import paths (both standard and inside JSDocs) in a given code string. * Handles local path root replacements and NPM package absolute path conversion. * * @private * @param {string} code - The source code containing imports. * @param {string} sourceDir - The absolute directory of the file being processed. * @param {boolean} isNpm - Whether this code comes from an external NPM package. * @param {string|null} npmPackageName - The name of the NPM package, if applicable. * @returns {string} The code with all paths corrected. */ private _rewritePathsInString; /** * Extracts and hoists already-corrected imports and typedefs. * * @private * @param {string} code - The source code to parse. * @returns {string} The code with imports and typedefs removed. */ private _extractAndHoist; /** * Cleans up the plugin code to be safely injected into the .insert() method. * * @private * @param {string} code - The raw plugin code. * @param {string} pluginName - The name of the plugin class/variable. * @returns {string} The formatted plugin code. */ private _formatPluginCode; /** * Executes the build process. * * @returns {Promise<void>} */ build(): Promise<void>; } //# sourceMappingURL=TinyPluginInliner.d.mts.map