preprocessPlugin
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.
Import:
import { preprocessPlugin } from 'obsidian-dev-utils/script-utils/bundlers/esbuild-impl/preprocess-plugin';Signature:
function preprocessPlugin(isEsm: boolean | undefined): PluginParameters:
| Parameter | Type | Description |
|---|---|---|
isEsm | boolean | undefined | Whether the build is for an ESM format. |
Returns: Plugin — An esbuild Plugin object that handles the preprocessing.