Skip to content

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 CommonJS-compatible __filename alternative. - Modifies the sourceMappingURL comment so a template literal ending a file does not swallow it. - Adds a basic process object to the global scope if process is referenced but not defined. - Fills in Symbol.dispose / Symbol.asyncDispose on engines that lack them, so using works there.

Import:

import { preprocessPlugin } from '@mnaoumov/typescript-dev-toolkit/bundlers/esbuild-impl/preprocess-plugin';

Signature:

function preprocessPlugin(options: PreprocessPluginOptions): Plugin

Parameters:

Parameter Type Description
options PreprocessPluginOptions The plugin options.

Returns: Plugin — An esbuild Plugin object that handles the preprocessing.


Links to this page: