MCPcopy Index your code
hub / github.com/formatjs/formatjs / resolveCustomFormatter

Function resolveCustomFormatter

packages/cli-lib/compile.ts:176–191  ·  view source on GitHub ↗
(
  format: string | Formatter<unknown> | undefined
)

Source from the content-addressed store, hash-verified

174}
175
176async function resolveCustomFormatter(
177 format: string | Formatter<unknown> | undefined
178): Promise<Formatter<unknown>> {
179 if (!format) {
180 throw new Error('A custom formatter is required')
181 }
182 if (typeof format !== 'string') {
183 return format
184 }
185 try {
186 return dynamicImport(pathToFileURL(resolve(process.cwd(), format)).href)
187 } catch (e) {
188 console.error(`Cannot resolve formatter ${format}`)
189 throw e
190 }
191}
192
193/**
194 * Compile extracted translation files with the native formatjs CLI binding and

Callers 1

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected