obsidian-dev-utils
Version:
This is the collection of useful functions that you can use for your Obsidian plugin development
22 lines (21 loc) • 952 B
text/typescript
/**
* @packageDocumentation
*
* This module defines a custom esbuild plugin that preprocesses JavaScript and TypeScript files.
*
* @remarks
* We cannot use `.` instead of `(dot)` in the above description because the file itself is preprocessed with the same rule.
*/
import type { Plugin } from 'esbuild';
/**
* Creates an esbuild plugin that preprocesses JavaScript and TypeScript files.
*
* This plugin performs the following tasks:
* - Replaces instances of `import(dot)meta(dot)url` with a Node.js-compatible `__filename` alternative.
* - Modifies the `sourceMappingURL` comment to ensure compatibility with Obsidian's plugin system.
* - Adds a basic `process` object to the global scope if `process` is referenced but not defined.
*
* @param isEsm - Whether the build is for an ESM format.
* @returns An esbuild `Plugin` object that handles the preprocessing.
*/
export declare function preprocessPlugin(isEsm?: boolean): Plugin;