Skip to main content
Glama
index.ts1.22 kB
/** * @intlayer/dictionaries-entry is a package that only returns the dictionary entry file. * Using an external package allow to alias it in the bundle configuration (such as webpack). * The alias allow hot reload the app (such as nextjs) on any dictionary change. */ import { existsSync } from 'node:fs'; import { join } from 'node:path'; import { clearModuleCache, configESMxCJSRequire } from '@intlayer/config'; import config from '@intlayer/config/built'; import type { DictionaryRegistry, IntlayerConfig } from '@intlayer/types'; type GetDictionaries = (configuration?: IntlayerConfig) => DictionaryRegistry; export const getDictionaries: GetDictionaries = ( configuration: IntlayerConfig = config ) => { const { content, build } = configuration; // Always use cjs for dictionaries entry as it uses require const dictionariesPath = join(content.mainDir, `dictionaries.cjs`); let dictionaries = {}; if (existsSync(dictionariesPath)) { // Clear cache for dictionaries.cjs and all its dependencies (JSON files) clearModuleCache(dictionariesPath); dictionaries = (build.require ?? configESMxCJSRequire)(dictionariesPath); } return (dictionaries ?? {}) as DictionaryRegistry; };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aymericzip/intlayer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server