Skip to main content

toImportSpecifier

@webda/utils


Function: toImportSpecifier()

toImportSpecifier(file): string

Defined in: packages/utils/src/esm.ts:46

Convert a module path to a specifier accepted by dynamic import().

Absolute paths are converted to file:// URLs: on Windows import("C:\\...") fails with ERR_UNSUPPORTED_ESM_URL_SCHEME. Other specifiers are returned unchanged.

Parameters​

file​

string

The module path or specifier

Returns​

string

a specifier usable with import()