UNPKG

obsidian-dev-utils

Version:

This is the collection of useful functions that you can use for your Obsidian plugin development

25 lines (24 loc) 1.24 kB
/** * @packageDocumentation * * This module defines a custom esbuild plugin that preprocesses JavaScript and TypeScript files. * The preprocessing includes replacing `import(dot)meta(dot)url` with a Node.js-compatible alternative, * ensuring compatibility with Obsidian's plugin system, and adding a basic `process` object for environments * where `process` is not available (like mobile or web environments). * * @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;