Skip to content

rewriteImportPathExtensions

Rewrites the extension of every import-like path in an emitted module’s text from .ts to the target output extension (.mjs / .cjs), so the multi-file dist/lib build references its real siblings.

Covers require('…'), static from "…", and dynamic import("…") occurrences.

Import:

import { rewriteImportPathExtensions } from 'obsidian-dev-utils/script-utils/bundlers/esbuild-impl/change-extension-plugin';

Signature:

function rewriteImportPathExtensions(text: string, extension: string): string

Parameters:

ParameterTypeDescription
textstringThe emitted module text to rewrite.
extensionstringThe output extension to rewrite .ts paths to (e.g. .mjs or .cjs).

Returns: string — The rewritten module text.