@intlayer/config 7.0.3-canary.1 → 7.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client.cjs +4 -0
- package/dist/cjs/configFile/buildConfigurationFields.cjs +1 -2
- package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
- package/dist/cjs/configFile/getConfiguration.cjs +5 -6
- package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
- package/dist/cjs/index.cjs +9 -9
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs +2 -2
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/parseFileContent.cjs +4 -4
- package/dist/cjs/loadExternalFile/parseFileContent.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/transpileTSToMJS.cjs +2 -1
- package/dist/cjs/loadExternalFile/transpileTSToMJS.cjs.map +1 -1
- package/dist/cjs/package.cjs +1 -1
- package/dist/cjs/package.cjs.map +1 -1
- package/dist/cjs/utils/ESMxCJSHelpers.cjs +5 -2
- package/dist/cjs/utils/ESMxCJSHelpers.cjs.map +1 -1
- package/dist/cjs/utils/clearModuleCache.cjs +3 -3
- package/dist/cjs/utils/clearModuleCache.cjs.map +1 -1
- package/dist/cjs/utils/getPackageJsonPath.cjs +3 -1
- package/dist/cjs/utils/getPackageJsonPath.cjs.map +1 -1
- package/dist/esm/client.mjs +3 -2
- package/dist/esm/configFile/buildConfigurationFields.mjs +1 -2
- package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
- package/dist/esm/configFile/getConfiguration.mjs +5 -6
- package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
- package/dist/esm/index.mjs +9 -9
- package/dist/esm/loadExternalFile/loadExternalFile.mjs +3 -3
- package/dist/esm/loadExternalFile/loadExternalFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/parseFileContent.mjs +3 -3
- package/dist/esm/loadExternalFile/parseFileContent.mjs.map +1 -1
- package/dist/esm/loadExternalFile/transpileTSToMJS.mjs +2 -1
- package/dist/esm/loadExternalFile/transpileTSToMJS.mjs.map +1 -1
- package/dist/esm/package.mjs +1 -1
- package/dist/esm/package.mjs.map +1 -1
- package/dist/esm/utils/ESMxCJSHelpers.mjs +5 -2
- package/dist/esm/utils/ESMxCJSHelpers.mjs.map +1 -1
- package/dist/esm/utils/clearModuleCache.mjs +4 -4
- package/dist/esm/utils/clearModuleCache.mjs.map +1 -1
- package/dist/esm/utils/getPackageJsonPath.mjs +3 -1
- package/dist/esm/utils/getPackageJsonPath.mjs.map +1 -1
- package/dist/types/client.d.ts +3 -2
- package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
- package/dist/types/configFile/getConfiguration.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/loadExternalFile/transpileTSToMJS.d.ts.map +1 -1
- package/dist/types/utils/ESMxCJSHelpers.d.ts +2 -2
- package/dist/types/utils/ESMxCJSHelpers.d.ts.map +1 -1
- package/dist/types/utils/cache.d.ts +1 -1
- package/dist/types/utils/cache.d.ts.map +1 -1
- package/dist/types/utils/getPackageJsonPath.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/types/client.d.ts.map +0 -1
- package/dist/types/configFile/index.d.ts.map +0 -1
- package/dist/types/defaultValues/middleware.d.ts +0 -8
- package/dist/types/defaultValues/middleware.d.ts.map +0 -1
- package/dist/types/getSandboxContext.d.ts +0 -4
- package/dist/types/getSandboxContext.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/loadExternalFile.d.ts +0 -8
- package/dist/types/loadExternalFile.d.ts.map +0 -1
- package/dist/types/types/config.d.ts +0 -649
- package/dist/types/types/config.d.ts.map +0 -1
- package/dist/types/types/locales.d.ts +0 -564
- package/dist/types/types/locales.d.ts.map +0 -1
- package/dist/types/types/plugin.d.ts +0 -68
- package/dist/types/types/plugin.d.ts.map +0 -1
|
@@ -6,7 +6,6 @@ import { APPLICATION_URL, BACKEND_URL, CMS_URL, DICTIONARY_PRIORITY_STRATEGY, ED
|
|
|
6
6
|
import { DEFAULT_LOCALE, LOCALES, REQUIRED_LOCALES, STRICT_MODE } from "../defaultValues/internationalization.mjs";
|
|
7
7
|
import { MODE, PREFIX } from "../defaultValues/log.mjs";
|
|
8
8
|
import { BASE_PATH, ROUTING_MODE, STORAGE } from "../defaultValues/routing.mjs";
|
|
9
|
-
import { ESMxCJSRequire } from "../utils/ESMxCJSHelpers.mjs";
|
|
10
9
|
import { isAbsolute, join } from "node:path";
|
|
11
10
|
|
|
12
11
|
//#region src/configFile/buildConfigurationFields.ts
|
|
@@ -93,7 +92,7 @@ const buildBuildFields = (customConfiguration) => ({
|
|
|
93
92
|
traversePattern: customConfiguration?.traversePattern ?? TRAVERSE_PATTERN,
|
|
94
93
|
outputFormat: customConfiguration?.outputFormat ?? OUTPUT_FORMAT,
|
|
95
94
|
cache: customConfiguration?.cache ?? CACHE,
|
|
96
|
-
require: customConfiguration?.require
|
|
95
|
+
require: customConfiguration?.require
|
|
97
96
|
});
|
|
98
97
|
const buildDictionaryFields = (customConfiguration) => ({ fill: customConfiguration?.fill ?? FILL });
|
|
99
98
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildConfigurationFields.mjs","names":["storedConfiguration: IntlayerConfig","notDerivedContentConfig: BaseContentConfig","baseDirDerivedConfiguration: BaseDerivedConfig","patternsConfiguration: PatternsContentConfig"],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { isAbsolute, join } from 'node:path';\nimport type {\n AiConfig,\n BaseContentConfig,\n BaseDerivedConfig,\n BuildConfig,\n ContentConfig,\n CustomIntlayerConfig,\n DictionaryConfig,\n EditorConfig,\n InternationalizationConfig,\n IntlayerConfig,\n LogConfig,\n LogFunctions,\n PatternsContentConfig,\n RoutingConfig,\n} from '@intlayer/types';\nimport {\n CACHE,\n IMPORT_MODE,\n OPTIMIZE,\n OUTPUT_FORMAT,\n TRAVERSE_PATTERN,\n} from '../defaultValues/build';\nimport {\n CACHE_DIR,\n CONFIG_DIR,\n CONTENT_DIR,\n DICTIONARIES_DIR,\n DYNAMIC_DICTIONARIES_DIR,\n EXCLUDED_PATHS,\n FETCH_DICTIONARIES_DIR,\n FILE_EXTENSIONS,\n MAIN_DIR,\n MODULE_AUGMENTATION_DIR,\n REMOTE_DICTIONARIES_DIR,\n TYPES_DIR,\n UNMERGED_DICTIONARIES_DIR,\n WATCH,\n} from '../defaultValues/content';\nimport { FILL } from '../defaultValues/dictionary';\nimport {\n APPLICATION_URL,\n BACKEND_URL,\n CMS_URL,\n DICTIONARY_PRIORITY_STRATEGY,\n EDITOR_URL,\n IS_ENABLED,\n LIVE_SYNC,\n LIVE_SYNC_PORT,\n PORT,\n} from '../defaultValues/editor';\nimport {\n DEFAULT_LOCALE,\n LOCALES,\n REQUIRED_LOCALES,\n STRICT_MODE,\n} from '../defaultValues/internationalization';\nimport { MODE, PREFIX } from '../defaultValues/log';\nimport { BASE_PATH, ROUTING_MODE, STORAGE } from '../defaultValues/routing';\nimport { ESMxCJSRequire } from '../utils/ESMxCJSHelpers';\nimport { normalizePath } from '../utils/normalizePath';\n\nlet storedConfiguration: IntlayerConfig;\n\nconst buildInternationalizationFields = (\n customConfiguration?: Partial<InternationalizationConfig>\n): InternationalizationConfig => ({\n /**\n * Locales available in the application\n *\n * Default: ['en']\n *\n */\n locales: customConfiguration?.locales ?? LOCALES,\n\n /**\n * Locales required by TypeScript to ensure strong implementations of internationalized content using typescript.\n *\n * Default: []\n *\n * If empty, all locales are required in `strict` mode.\n *\n * Ensure required locales are also defined in the `locales` field.\n */\n requiredLocales:\n customConfiguration?.requiredLocales ??\n customConfiguration?.locales ??\n REQUIRED_LOCALES,\n\n /**\n * Ensure strong implementations of internationalized content using typescript.\n * - If set to \"strict\", the translation `t` function will require each declared locales to be defined. If one locale is missing, or if a locale is not declared in your config, it will throw an error.\n * - If set to \"inclusive\", the translation `t` function will require each declared locales to be defined. If one locale is missing, it will throw a warning. But will accept if a locale is not declared in your config, but exist.\n * - If set to \"loose\", the translation `t` function will accept any existing locale.\n *\n * Default: \"inclusive\"\n */\n strictMode: customConfiguration?.strictMode ?? STRICT_MODE,\n\n /**\n * Default locale of the application for fallback\n *\n * Default: 'en'\n */\n defaultLocale: customConfiguration?.defaultLocale ?? DEFAULT_LOCALE,\n});\n\nconst buildRoutingFields = (\n customConfiguration?: Partial<RoutingConfig>\n): RoutingConfig => ({\n /**\n * URL routing mode for locale handling\n *\n * Controls how locales are represented in application URLs:\n * - 'prefix-no-default': Prefix all locales except the default locale (default)\n * - en → /dashboard\n * - fr → /fr/dashboard\n *\n * - 'prefix-all': Prefix all locales including the default locale\n * - en → /en/dashboard\n * - fr → /fr/dashboard\n *\n * - 'search-params': Use search parameters for locale handling\n * - en → /dashboard?locale=en\n * - fr → /fr/dashboard?locale=fr\n *\n * - 'no-prefix': No locale prefixing in URLs\n * - en → /dashboard\n * - fr → /dashboard\n *\n * Default: 'prefix-no-default'\n */\n mode: customConfiguration?.mode ?? ROUTING_MODE,\n\n /**\n * Configuration for storing the locale in the client (localStorage or sessionStorage)\n *\n * If false, the locale will not be stored by the middleware.\n * If true, the locale storage will consider all default values. (cookie and header)\n *\n * Default: ['cookie', 'header']\n *\n */\n storage: customConfiguration?.storage ?? STORAGE,\n\n /**\n * Base path of the application URL\n *\n * Default: ''\n *\n * Example:\n * - If the application is hosted at https://example.com/my-app\n * - The base path is '/my-app'\n * - The URL will be https://example.com/my-app/en\n * - If the base path is not set, the URL will be https://example.com/en\n */\n basePath: customConfiguration?.basePath ?? BASE_PATH,\n});\n\nconst buildContentFields = (\n customConfiguration?: Partial<ContentConfig>,\n baseDir?: string\n): ContentConfig => {\n const notDerivedContentConfig: BaseContentConfig = {\n /**\n * File extensions of content to look for to build the dictionaries\n *\n * - Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']\n *\n * - Example: ['.data.ts', '.data.js', '.data.json']\n *\n * Note:\n * - Can exclude unused file extensions to improve performance\n * - Avoid using common file extensions like '.ts', '.js', '.json' to avoid conflicts\n */\n fileExtensions: customConfiguration?.fileExtensions ?? FILE_EXTENSIONS,\n\n /**\n * Absolute path of the directory of the project\n * - Default: process.cwd()\n * - Example: '\n *\n * Will be used to resolve all intlayer directories\n *\n * Note:\n * - The base directory should be the root of the project\n * - Can be changed to a custom directory to externalize either the content used in the project, or the intlayer application from the project\n */\n baseDir: customConfiguration?.baseDir ?? baseDir ?? process.cwd(),\n\n /**\n * Should exclude some directories from the content search\n *\n * Default: ['**\\/node_modules/**', '**\\/dist/**', '**\\/build/**', '**\\/.intlayer/**', '**\\/.next/**', '**\\/.nuxt/**', '**\\/.expo/**', '**\\/.vercel/**', '**\\/.turbo/**', '**\\/.tanstack/**']\n */\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n\n /**\n * Indicates if Intlayer should watch for changes in the content declaration files in the app to rebuild the related dictionaries.\n *\n * Default: process.env.NODE_ENV === 'development'\n */\n watch: customConfiguration?.watch ?? WATCH,\n\n /**\n * Command to format the content. When intlayer write your .content files locally, this command will be used to format the content.\n * Intlayer will replace the {{file}} with the path of the file to format.\n *\n * If not set, Intlayer will try to detect the format command automatically. By trying to resolve the following commands: prettier, biome, eslint.\n *\n * Example:\n *\n * ```bash\n * npx prettier --write {{file}}\n * ```\n *\n * ```bash\n * bunx biome format {{file}}\n * ```\n *\n * ```bash\n * bun format {{file}}\n * ```\n *\n * ```bash\n * npx eslint --fix {{file}}\n * ```\n *\n * Default: undefined\n */\n formatCommand: customConfiguration?.formatCommand,\n };\n\n const optionalJoinBaseDir = (path: string) => {\n if (isAbsolute(path)) return path;\n\n return join(notDerivedContentConfig.baseDir, path);\n };\n\n const baseDirDerivedConfiguration: BaseDerivedConfig = {\n /**\n * Directory where the content is stored\n *\n * Relative to the base directory of the project\n *\n * Default: ./src\n *\n * Example: 'src'\n *\n * Note:\n * - Can be changed to a custom directory to externalize the content used in the project\n * - If the content is not at the base directory level, update the contentDirName field instead\n */\n contentDir: (customConfiguration?.contentDir ?? CONTENT_DIR).map(\n optionalJoinBaseDir\n ),\n\n /**\n * Directory where the module augmentation will be stored\n *\n * Module augmentation allow better IDE suggestions and type checking\n *\n * Relative to the base directory of the project\n *\n * Default: .intlayer/types\n *\n * Example: 'types'\n *\n * Note:\n * - If this path changed, be sure to include it from the tsconfig.json file\n * - If the module augmentation is not at the base directory level, update the moduleAugmentationDirName field instead\n *\n */\n moduleAugmentationDir: optionalJoinBaseDir(\n customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR\n ),\n\n /**\n * Directory where the unmerged dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: '.intlayer/unmerged_dictionary'\n *\n */\n unmergedDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.unmergedDictionariesDir ?? UNMERGED_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the remote dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: '.intlayer/remote_dictionary'\n */\n remoteDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.remoteDictionariesDir ?? REMOTE_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the final dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/dictionary\n *\n * Example: '.intlayer/dictionary'\n *\n * Note:\n * - If the types are not at the result directory level, update the dictionariesDirName field instead\n * - The dictionaries are stored in JSON format\n * - The dictionaries are used to translate the content\n * - The dictionaries are built from the content files\n */\n dictionariesDir: optionalJoinBaseDir(\n customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the dynamic dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/dynamic_dictionary\n */\n dynamicDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.dynamicDictionariesDir ?? DYNAMIC_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the fetch dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/fetch_dictionary\n */\n fetchDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.fetchDictionariesDir ?? FETCH_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the dictionaries types will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/types\n *\n * Example: 'types'\n *\n * Note:\n * - If the types are not at the result directory level, update the typesDirName field instead\n */\n typesDir: optionalJoinBaseDir(customConfiguration?.typesDir ?? TYPES_DIR),\n\n /**\n * Directory where the main files will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/main\n *\n * Example: '.intlayer/main'\n *\n * Note:\n *\n * - If the main files are not at the result directory level, update the mainDirName field instead\n */\n mainDir: optionalJoinBaseDir(customConfiguration?.mainDir ?? MAIN_DIR),\n\n /**\n * Directory where the configuration files are stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/config\n *\n * Example: '.intlayer/config'\n *\n * Note:\n *\n * - If the configuration files are not at the result directory level, update the configDirName field instead\n */\n configDir: optionalJoinBaseDir(\n customConfiguration?.configDir ?? CONFIG_DIR\n ),\n\n /**\n * Directory where the cache files are stored, relative to the result directory\n *\n * Default: .intlayer/cache\n */\n cacheDir: optionalJoinBaseDir(customConfiguration?.cacheDir ?? CACHE_DIR),\n };\n\n const patternsConfiguration: PatternsContentConfig = {\n /**\n * Pattern of files to watch\n *\n * Default: ['/**\\/*.content.ts', '/**\\/*.content.js', '/**\\/*.content.json', '/**\\/*.content.cjs', '/**\\/*.content.mjs', '/**\\/*.content.tsx', '/**\\/*.content.jsx']\n */\n watchedFilesPattern: notDerivedContentConfig.fileExtensions.map(\n (ext) => `/**/*${ext}`\n ),\n\n /**\n * Pattern of files to watch including the relative path\n *\n * Default: ['src/**\\/*.content.ts', 'src/**\\/*.content.js', 'src/**\\/*.content.json', 'src/**\\/*.content.cjs', 'src/**\\/*.content.mjs', 'src/**\\/*.content.tsx', 'src/**\\/*.content.jsx']\n */\n watchedFilesPatternWithPath: notDerivedContentConfig.fileExtensions.flatMap(\n (ext) =>\n baseDirDerivedConfiguration.contentDir.map(\n (contentDir) => `${normalizePath(contentDir)}/**/*${ext}`\n )\n ),\n\n /**\n * Pattern of dictionary to interpret\n *\n * Default: '.intlayer/dictionary/**\\/*.json'\n */\n outputFilesPatternWithPath: `${normalizePath(\n baseDirDerivedConfiguration.dictionariesDir\n )}/**/*.json`,\n };\n\n return {\n ...notDerivedContentConfig,\n ...baseDirDerivedConfiguration,\n ...patternsConfiguration,\n };\n};\n\nconst buildEditorFields = (\n customConfiguration?: Partial<EditorConfig>\n): EditorConfig => ({\n /**\n * URL of the application. Used to restrict the origin of the editor for security reasons.\n *\n * > '*' means that the editor is accessible from any origin\n *\n * Default: '*'\n */\n applicationURL: customConfiguration?.applicationURL ?? APPLICATION_URL,\n\n /**\n * URL of the editor server. Used to restrict the origin of the editor for security reasons.\n *\n * > '*' means that the editor is accessible from any origin\n *\n * Default: '*'\n */\n editorURL: customConfiguration?.editorURL ?? EDITOR_URL,\n\n /**\n * URL of the CMS server. Used to restrict the origin of the editor for security reasons.\n */\n cmsURL: customConfiguration?.cmsURL ?? CMS_URL,\n\n /**\n * URL of the editor server\n *\n * Default: 'https://back.intlayer.org'\n */\n backendURL: customConfiguration?.backendURL ?? BACKEND_URL,\n\n /** Port of the editor server\n *\n * Default: 8000\n */\n port: customConfiguration?.port ?? PORT,\n\n /**\n * Indicates if the application interact with the visual editor\n *\n * Default: true;\n *\n * If true, the editor will be able to interact with the application.\n * If false, the editor will not be able to interact with the application.\n * In any case, the editor can only be enabled by the visual editor.\n * Disabling the editor for specific environments is a way to enforce the security.\n *\n * Usage:\n * ```js\n * {\n * // Other configurations\n * editor: {\n * enabled: process.env.NODE_ENV !== 'production',\n * }\n * };\n * ```\n */\n enabled: customConfiguration?.enabled ?? IS_ENABLED,\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://intlayer.org/dashboard/project and create an account.\n *\n * Default: undefined\n *\n * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.\n */\n clientId: customConfiguration?.clientId ?? undefined,\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://intlayer.org/dashboard/project and create an account.\n *\n * Default: undefined\n *\n * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.\n */\n clientSecret: customConfiguration?.clientSecret ?? undefined,\n\n /**\n * Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.\n * However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.\n *\n * Default: 'local_first'\n *\n * The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.\n * - 'local_first': The first dictionary found in the locale is used.\n * - 'distant_first': The first dictionary found in the distant locales is used.\n */\n dictionaryPriorityStrategy:\n customConfiguration?.dictionaryPriorityStrategy ??\n DICTIONARY_PRIORITY_STRATEGY,\n\n /**\n * Indicates if the application should hot reload the locale configurations when a change is detected.\n * For example, when a new dictionary is added or updated, the application will update the content tu display in the page.\n *\n * The hot reload is only available for clients of the `enterprise` plan.\n *\n * Default: false\n */\n liveSync: customConfiguration?.liveSync ?? LIVE_SYNC,\n\n /**\n * Port of the live sync server\n *\n * Default: 4000\n */\n liveSyncPort: customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT,\n\n /**\n * URL of the live sync server in case of remote live sync server\n *\n * Default: `http://localhost:${LIVE_SYNC_PORT}`\n */\n liveSyncURL:\n customConfiguration?.liveSyncURL ??\n `http://localhost:${customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT}`,\n});\n\nconst buildLogFields = (\n customConfiguration?: Partial<LogConfig>,\n logFunctions?: LogFunctions\n): LogConfig => ({\n /**\n * Indicates if the logger is enabled\n *\n * Default: 'prefix-no-default'\n *\n * If 'default', the logger is enabled and can be used.\n * If 'verbose', the logger will be enabled and can be used, but will log more information.\n * If 'disabled', the logger is disabled and cannot be used.\n */\n mode: customConfiguration?.mode ?? MODE,\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: customConfiguration?.prefix ?? PREFIX,\n\n /**\n * Functions to log\n */\n error: logFunctions?.error,\n log: logFunctions?.log,\n info: logFunctions?.info,\n warn: logFunctions?.warn,\n});\n\nconst buildAiFields = (customConfiguration?: Partial<AiConfig>): AiConfig => ({\n /**\n * AI configuration\n */\n provider: customConfiguration?.provider,\n\n /**\n * API key\n */\n apiKey: customConfiguration?.apiKey,\n\n /**\n * API model\n */\n model: customConfiguration?.model,\n\n /**\n * Temperature\n */\n temperature: customConfiguration?.temperature,\n\n /**\n * Application context\n */\n applicationContext: customConfiguration?.applicationContext,\n});\n\nconst buildBuildFields = (\n customConfiguration?: Partial<BuildConfig>\n): BuildConfig => ({\n /**\n * Indicates if the build should be optimized\n *\n * Default: process.env.NODE_ENV === 'production'\n *\n * If true, the build will be optimized.\n * If false, the build will not be optimized.\n *\n * Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used.\n * All imports will stay as static import to avoid async processing when loading the dictionaries.\n *\n * Note:\n * - Intlayer will replace all call of `useIntlayer` with the defined mode by the `importMode` option.\n * - Intlayer will replace all call of `getIntlayer` with `getDictionary`.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - In most cases, \"dynamic\" will be used for React applications, \"async\" for Vue.js applications.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n */\n optimize: customConfiguration?.optimize ?? OPTIMIZE,\n\n /**\n * Indicates the mode of import to use for the dictionaries.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * - \"live\": The dictionaries are imported dynamically using the live sync API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * Live mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as \"dynamic\" mode.\n *\n * Default: \"static\"\n *\n * By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.\n *\n * Note:\n * - Dynamic imports rely on Suspense and may slightly impact rendering performance.\n * - If disabled all locales will be loaded at once, even if they are not used.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n * - This option will be ignored if `optimize` is disabled.\n * - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.\n * - The \"live\" allows to sync the dictionaries to the live sync server.\n */\n importMode: customConfiguration?.importMode ?? IMPORT_MODE,\n\n /**\n * Pattern to traverse the code to optimize.\n *\n * Allows to avoid to traverse the code that is not relevant to the optimization.\n * Improve build performance.\n *\n * Default: ['**\\/*.{js,ts,mjs,cjs,jsx,tsx,mjx,cjx}', '!**\\/node_modules/**']\n *\n * Example: `['src/**\\/*.{ts,tsx}', '../ui-library/**\\/*.{ts,tsx}']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n */\n traversePattern: customConfiguration?.traversePattern ?? TRAVERSE_PATTERN,\n\n /**\n * Output format of the dictionaries\n *\n * Can be set on large projects to improve build performance.\n *\n * Default: ['cjs', 'esm']\n *\n * The output format of the dictionaries. It can be either 'cjs' or 'esm'.\n * - 'cjs': The dictionaries are outputted as CommonJS modules.\n * - 'esm': The dictionaries are outputted as ES modules.\n */\n outputFormat: customConfiguration?.outputFormat ?? OUTPUT_FORMAT,\n\n /**\n * Cache\n */\n cache: customConfiguration?.cache ?? CACHE,\n\n /**\n * Require function\n */\n require: customConfiguration?.require ?? ESMxCJSRequire,\n});\n\nconst buildDictionaryFields = (\n customConfiguration?: Partial<DictionaryConfig>\n): DictionaryConfig => ({\n /**\n * Indicate how the dictionary should be filled using AI.\n *\n * Default: true\n */\n fill: customConfiguration?.fill ?? FILL,\n});\n\n/**\n * Build the configuration fields by merging the default values with the custom configuration\n */\nexport const buildConfigurationFields = (\n customConfiguration?: CustomIntlayerConfig,\n baseDir?: string,\n logFunctions?: LogFunctions\n): IntlayerConfig => {\n const internationalizationConfig = buildInternationalizationFields(\n customConfiguration?.internationalization\n );\n\n const routingConfig = buildRoutingFields(customConfiguration?.routing);\n\n const contentConfig = buildContentFields(\n customConfiguration?.content,\n baseDir\n );\n\n const editorConfig = buildEditorFields(customConfiguration?.editor);\n\n const logConfig = buildLogFields(customConfiguration?.log, logFunctions);\n\n const aiConfig = buildAiFields(customConfiguration?.ai);\n\n const buildConfig = buildBuildFields(customConfiguration?.build);\n\n const dictionaryConfig = buildDictionaryFields(\n customConfiguration?.dictionary\n );\n\n storedConfiguration = {\n internationalization: internationalizationConfig,\n routing: routingConfig,\n content: contentConfig,\n editor: editorConfig,\n log: logConfig,\n ai: aiConfig,\n build: buildConfig,\n dictionary: dictionaryConfig,\n plugins: customConfiguration?.plugins,\n };\n\n return storedConfiguration;\n};\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"buildConfigurationFields.mjs","names":["storedConfiguration: IntlayerConfig","notDerivedContentConfig: BaseContentConfig","baseDirDerivedConfiguration: BaseDerivedConfig","patternsConfiguration: PatternsContentConfig"],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { isAbsolute, join } from 'node:path';\nimport type {\n AiConfig,\n BaseContentConfig,\n BaseDerivedConfig,\n BuildConfig,\n ContentConfig,\n CustomIntlayerConfig,\n DictionaryConfig,\n EditorConfig,\n InternationalizationConfig,\n IntlayerConfig,\n LogConfig,\n LogFunctions,\n PatternsContentConfig,\n RoutingConfig,\n} from '@intlayer/types';\nimport {\n CACHE,\n IMPORT_MODE,\n OPTIMIZE,\n OUTPUT_FORMAT,\n TRAVERSE_PATTERN,\n} from '../defaultValues/build';\nimport {\n CACHE_DIR,\n CONFIG_DIR,\n CONTENT_DIR,\n DICTIONARIES_DIR,\n DYNAMIC_DICTIONARIES_DIR,\n EXCLUDED_PATHS,\n FETCH_DICTIONARIES_DIR,\n FILE_EXTENSIONS,\n MAIN_DIR,\n MODULE_AUGMENTATION_DIR,\n REMOTE_DICTIONARIES_DIR,\n TYPES_DIR,\n UNMERGED_DICTIONARIES_DIR,\n WATCH,\n} from '../defaultValues/content';\nimport { FILL } from '../defaultValues/dictionary';\nimport {\n APPLICATION_URL,\n BACKEND_URL,\n CMS_URL,\n DICTIONARY_PRIORITY_STRATEGY,\n EDITOR_URL,\n IS_ENABLED,\n LIVE_SYNC,\n LIVE_SYNC_PORT,\n PORT,\n} from '../defaultValues/editor';\nimport {\n DEFAULT_LOCALE,\n LOCALES,\n REQUIRED_LOCALES,\n STRICT_MODE,\n} from '../defaultValues/internationalization';\nimport { MODE, PREFIX } from '../defaultValues/log';\nimport { BASE_PATH, ROUTING_MODE, STORAGE } from '../defaultValues/routing';\nimport { normalizePath } from '../utils/normalizePath';\n\nlet storedConfiguration: IntlayerConfig;\n\nconst buildInternationalizationFields = (\n customConfiguration?: Partial<InternationalizationConfig>\n): InternationalizationConfig => ({\n /**\n * Locales available in the application\n *\n * Default: ['en']\n *\n */\n locales: customConfiguration?.locales ?? LOCALES,\n\n /**\n * Locales required by TypeScript to ensure strong implementations of internationalized content using typescript.\n *\n * Default: []\n *\n * If empty, all locales are required in `strict` mode.\n *\n * Ensure required locales are also defined in the `locales` field.\n */\n requiredLocales:\n customConfiguration?.requiredLocales ??\n customConfiguration?.locales ??\n REQUIRED_LOCALES,\n\n /**\n * Ensure strong implementations of internationalized content using typescript.\n * - If set to \"strict\", the translation `t` function will require each declared locales to be defined. If one locale is missing, or if a locale is not declared in your config, it will throw an error.\n * - If set to \"inclusive\", the translation `t` function will require each declared locales to be defined. If one locale is missing, it will throw a warning. But will accept if a locale is not declared in your config, but exist.\n * - If set to \"loose\", the translation `t` function will accept any existing locale.\n *\n * Default: \"inclusive\"\n */\n strictMode: customConfiguration?.strictMode ?? STRICT_MODE,\n\n /**\n * Default locale of the application for fallback\n *\n * Default: 'en'\n */\n defaultLocale: customConfiguration?.defaultLocale ?? DEFAULT_LOCALE,\n});\n\nconst buildRoutingFields = (\n customConfiguration?: Partial<RoutingConfig>\n): RoutingConfig => ({\n /**\n * URL routing mode for locale handling\n *\n * Controls how locales are represented in application URLs:\n * - 'prefix-no-default': Prefix all locales except the default locale (default)\n * - en → /dashboard\n * - fr → /fr/dashboard\n *\n * - 'prefix-all': Prefix all locales including the default locale\n * - en → /en/dashboard\n * - fr → /fr/dashboard\n *\n * - 'search-params': Use search parameters for locale handling\n * - en → /dashboard?locale=en\n * - fr → /fr/dashboard?locale=fr\n *\n * - 'no-prefix': No locale prefixing in URLs\n * - en → /dashboard\n * - fr → /dashboard\n *\n * Default: 'prefix-no-default'\n */\n mode: customConfiguration?.mode ?? ROUTING_MODE,\n\n /**\n * Configuration for storing the locale in the client (localStorage or sessionStorage)\n *\n * If false, the locale will not be stored by the middleware.\n * If true, the locale storage will consider all default values. (cookie and header)\n *\n * Default: ['cookie', 'header']\n *\n */\n storage: customConfiguration?.storage ?? STORAGE,\n\n /**\n * Base path of the application URL\n *\n * Default: ''\n *\n * Example:\n * - If the application is hosted at https://example.com/my-app\n * - The base path is '/my-app'\n * - The URL will be https://example.com/my-app/en\n * - If the base path is not set, the URL will be https://example.com/en\n */\n basePath: customConfiguration?.basePath ?? BASE_PATH,\n});\n\nconst buildContentFields = (\n customConfiguration?: Partial<ContentConfig>,\n baseDir?: string\n): ContentConfig => {\n const notDerivedContentConfig: BaseContentConfig = {\n /**\n * File extensions of content to look for to build the dictionaries\n *\n * - Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']\n *\n * - Example: ['.data.ts', '.data.js', '.data.json']\n *\n * Note:\n * - Can exclude unused file extensions to improve performance\n * - Avoid using common file extensions like '.ts', '.js', '.json' to avoid conflicts\n */\n fileExtensions: customConfiguration?.fileExtensions ?? FILE_EXTENSIONS,\n\n /**\n * Absolute path of the directory of the project\n * - Default: process.cwd()\n * - Example: '\n *\n * Will be used to resolve all intlayer directories\n *\n * Note:\n * - The base directory should be the root of the project\n * - Can be changed to a custom directory to externalize either the content used in the project, or the intlayer application from the project\n */\n baseDir: customConfiguration?.baseDir ?? baseDir ?? process.cwd(),\n\n /**\n * Should exclude some directories from the content search\n *\n * Default: ['**\\/node_modules/**', '**\\/dist/**', '**\\/build/**', '**\\/.intlayer/**', '**\\/.next/**', '**\\/.nuxt/**', '**\\/.expo/**', '**\\/.vercel/**', '**\\/.turbo/**', '**\\/.tanstack/**']\n */\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n\n /**\n * Indicates if Intlayer should watch for changes in the content declaration files in the app to rebuild the related dictionaries.\n *\n * Default: process.env.NODE_ENV === 'development'\n */\n watch: customConfiguration?.watch ?? WATCH,\n\n /**\n * Command to format the content. When intlayer write your .content files locally, this command will be used to format the content.\n * Intlayer will replace the {{file}} with the path of the file to format.\n *\n * If not set, Intlayer will try to detect the format command automatically. By trying to resolve the following commands: prettier, biome, eslint.\n *\n * Example:\n *\n * ```bash\n * npx prettier --write {{file}}\n * ```\n *\n * ```bash\n * bunx biome format {{file}}\n * ```\n *\n * ```bash\n * bun format {{file}}\n * ```\n *\n * ```bash\n * npx eslint --fix {{file}}\n * ```\n *\n * Default: undefined\n */\n formatCommand: customConfiguration?.formatCommand,\n };\n\n const optionalJoinBaseDir = (path: string) => {\n if (isAbsolute(path)) return path;\n\n return join(notDerivedContentConfig.baseDir, path);\n };\n\n const baseDirDerivedConfiguration: BaseDerivedConfig = {\n /**\n * Directory where the content is stored\n *\n * Relative to the base directory of the project\n *\n * Default: ./src\n *\n * Example: 'src'\n *\n * Note:\n * - Can be changed to a custom directory to externalize the content used in the project\n * - If the content is not at the base directory level, update the contentDirName field instead\n */\n contentDir: (customConfiguration?.contentDir ?? CONTENT_DIR).map(\n optionalJoinBaseDir\n ),\n\n /**\n * Directory where the module augmentation will be stored\n *\n * Module augmentation allow better IDE suggestions and type checking\n *\n * Relative to the base directory of the project\n *\n * Default: .intlayer/types\n *\n * Example: 'types'\n *\n * Note:\n * - If this path changed, be sure to include it from the tsconfig.json file\n * - If the module augmentation is not at the base directory level, update the moduleAugmentationDirName field instead\n *\n */\n moduleAugmentationDir: optionalJoinBaseDir(\n customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR\n ),\n\n /**\n * Directory where the unmerged dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: '.intlayer/unmerged_dictionary'\n *\n */\n unmergedDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.unmergedDictionariesDir ?? UNMERGED_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the remote dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: '.intlayer/remote_dictionary'\n */\n remoteDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.remoteDictionariesDir ?? REMOTE_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the final dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/dictionary\n *\n * Example: '.intlayer/dictionary'\n *\n * Note:\n * - If the types are not at the result directory level, update the dictionariesDirName field instead\n * - The dictionaries are stored in JSON format\n * - The dictionaries are used to translate the content\n * - The dictionaries are built from the content files\n */\n dictionariesDir: optionalJoinBaseDir(\n customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the dynamic dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/dynamic_dictionary\n */\n dynamicDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.dynamicDictionariesDir ?? DYNAMIC_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the fetch dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/fetch_dictionary\n */\n fetchDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.fetchDictionariesDir ?? FETCH_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the dictionaries types will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/types\n *\n * Example: 'types'\n *\n * Note:\n * - If the types are not at the result directory level, update the typesDirName field instead\n */\n typesDir: optionalJoinBaseDir(customConfiguration?.typesDir ?? TYPES_DIR),\n\n /**\n * Directory where the main files will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/main\n *\n * Example: '.intlayer/main'\n *\n * Note:\n *\n * - If the main files are not at the result directory level, update the mainDirName field instead\n */\n mainDir: optionalJoinBaseDir(customConfiguration?.mainDir ?? MAIN_DIR),\n\n /**\n * Directory where the configuration files are stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/config\n *\n * Example: '.intlayer/config'\n *\n * Note:\n *\n * - If the configuration files are not at the result directory level, update the configDirName field instead\n */\n configDir: optionalJoinBaseDir(\n customConfiguration?.configDir ?? CONFIG_DIR\n ),\n\n /**\n * Directory where the cache files are stored, relative to the result directory\n *\n * Default: .intlayer/cache\n */\n cacheDir: optionalJoinBaseDir(customConfiguration?.cacheDir ?? CACHE_DIR),\n };\n\n const patternsConfiguration: PatternsContentConfig = {\n /**\n * Pattern of files to watch\n *\n * Default: ['/**\\/*.content.ts', '/**\\/*.content.js', '/**\\/*.content.json', '/**\\/*.content.cjs', '/**\\/*.content.mjs', '/**\\/*.content.tsx', '/**\\/*.content.jsx']\n */\n watchedFilesPattern: notDerivedContentConfig.fileExtensions.map(\n (ext) => `/**/*${ext}`\n ),\n\n /**\n * Pattern of files to watch including the relative path\n *\n * Default: ['src/**\\/*.content.ts', 'src/**\\/*.content.js', 'src/**\\/*.content.json', 'src/**\\/*.content.cjs', 'src/**\\/*.content.mjs', 'src/**\\/*.content.tsx', 'src/**\\/*.content.jsx']\n */\n watchedFilesPatternWithPath: notDerivedContentConfig.fileExtensions.flatMap(\n (ext) =>\n baseDirDerivedConfiguration.contentDir.map(\n (contentDir) => `${normalizePath(contentDir)}/**/*${ext}`\n )\n ),\n\n /**\n * Pattern of dictionary to interpret\n *\n * Default: '.intlayer/dictionary/**\\/*.json'\n */\n outputFilesPatternWithPath: `${normalizePath(\n baseDirDerivedConfiguration.dictionariesDir\n )}/**/*.json`,\n };\n\n return {\n ...notDerivedContentConfig,\n ...baseDirDerivedConfiguration,\n ...patternsConfiguration,\n };\n};\n\nconst buildEditorFields = (\n customConfiguration?: Partial<EditorConfig>\n): EditorConfig => ({\n /**\n * URL of the application. Used to restrict the origin of the editor for security reasons.\n *\n * > '*' means that the editor is accessible from any origin\n *\n * Default: '*'\n */\n applicationURL: customConfiguration?.applicationURL ?? APPLICATION_URL,\n\n /**\n * URL of the editor server. Used to restrict the origin of the editor for security reasons.\n *\n * > '*' means that the editor is accessible from any origin\n *\n * Default: '*'\n */\n editorURL: customConfiguration?.editorURL ?? EDITOR_URL,\n\n /**\n * URL of the CMS server. Used to restrict the origin of the editor for security reasons.\n */\n cmsURL: customConfiguration?.cmsURL ?? CMS_URL,\n\n /**\n * URL of the editor server\n *\n * Default: 'https://back.intlayer.org'\n */\n backendURL: customConfiguration?.backendURL ?? BACKEND_URL,\n\n /** Port of the editor server\n *\n * Default: 8000\n */\n port: customConfiguration?.port ?? PORT,\n\n /**\n * Indicates if the application interact with the visual editor\n *\n * Default: true;\n *\n * If true, the editor will be able to interact with the application.\n * If false, the editor will not be able to interact with the application.\n * In any case, the editor can only be enabled by the visual editor.\n * Disabling the editor for specific environments is a way to enforce the security.\n *\n * Usage:\n * ```js\n * {\n * // Other configurations\n * editor: {\n * enabled: process.env.NODE_ENV !== 'production',\n * }\n * };\n * ```\n */\n enabled: customConfiguration?.enabled ?? IS_ENABLED,\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://intlayer.org/dashboard/project and create an account.\n *\n * Default: undefined\n *\n * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.\n */\n clientId: customConfiguration?.clientId ?? undefined,\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://intlayer.org/dashboard/project and create an account.\n *\n * Default: undefined\n *\n * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.\n */\n clientSecret: customConfiguration?.clientSecret ?? undefined,\n\n /**\n * Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.\n * However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.\n *\n * Default: 'local_first'\n *\n * The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.\n * - 'local_first': The first dictionary found in the locale is used.\n * - 'distant_first': The first dictionary found in the distant locales is used.\n */\n dictionaryPriorityStrategy:\n customConfiguration?.dictionaryPriorityStrategy ??\n DICTIONARY_PRIORITY_STRATEGY,\n\n /**\n * Indicates if the application should hot reload the locale configurations when a change is detected.\n * For example, when a new dictionary is added or updated, the application will update the content tu display in the page.\n *\n * The hot reload is only available for clients of the `enterprise` plan.\n *\n * Default: false\n */\n liveSync: customConfiguration?.liveSync ?? LIVE_SYNC,\n\n /**\n * Port of the live sync server\n *\n * Default: 4000\n */\n liveSyncPort: customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT,\n\n /**\n * URL of the live sync server in case of remote live sync server\n *\n * Default: `http://localhost:${LIVE_SYNC_PORT}`\n */\n liveSyncURL:\n customConfiguration?.liveSyncURL ??\n `http://localhost:${customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT}`,\n});\n\nconst buildLogFields = (\n customConfiguration?: Partial<LogConfig>,\n logFunctions?: LogFunctions\n): LogConfig => ({\n /**\n * Indicates if the logger is enabled\n *\n * Default: 'prefix-no-default'\n *\n * If 'default', the logger is enabled and can be used.\n * If 'verbose', the logger will be enabled and can be used, but will log more information.\n * If 'disabled', the logger is disabled and cannot be used.\n */\n mode: customConfiguration?.mode ?? MODE,\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: customConfiguration?.prefix ?? PREFIX,\n\n /**\n * Functions to log\n */\n error: logFunctions?.error,\n log: logFunctions?.log,\n info: logFunctions?.info,\n warn: logFunctions?.warn,\n});\n\nconst buildAiFields = (customConfiguration?: Partial<AiConfig>): AiConfig => ({\n /**\n * AI configuration\n */\n provider: customConfiguration?.provider,\n\n /**\n * API key\n */\n apiKey: customConfiguration?.apiKey,\n\n /**\n * API model\n */\n model: customConfiguration?.model,\n\n /**\n * Temperature\n */\n temperature: customConfiguration?.temperature,\n\n /**\n * Application context\n */\n applicationContext: customConfiguration?.applicationContext,\n});\n\nconst buildBuildFields = (\n customConfiguration?: Partial<BuildConfig>\n): BuildConfig => ({\n /**\n * Indicates if the build should be optimized\n *\n * Default: process.env.NODE_ENV === 'production'\n *\n * If true, the build will be optimized.\n * If false, the build will not be optimized.\n *\n * Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used.\n * All imports will stay as static import to avoid async processing when loading the dictionaries.\n *\n * Note:\n * - Intlayer will replace all call of `useIntlayer` with the defined mode by the `importMode` option.\n * - Intlayer will replace all call of `getIntlayer` with `getDictionary`.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - In most cases, \"dynamic\" will be used for React applications, \"async\" for Vue.js applications.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n */\n optimize: customConfiguration?.optimize ?? OPTIMIZE,\n\n /**\n * Indicates the mode of import to use for the dictionaries.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * - \"live\": The dictionaries are imported dynamically using the live sync API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * Live mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as \"dynamic\" mode.\n *\n * Default: \"static\"\n *\n * By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.\n *\n * Note:\n * - Dynamic imports rely on Suspense and may slightly impact rendering performance.\n * - If disabled all locales will be loaded at once, even if they are not used.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n * - This option will be ignored if `optimize` is disabled.\n * - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.\n * - The \"live\" allows to sync the dictionaries to the live sync server.\n */\n importMode: customConfiguration?.importMode ?? IMPORT_MODE,\n\n /**\n * Pattern to traverse the code to optimize.\n *\n * Allows to avoid to traverse the code that is not relevant to the optimization.\n * Improve build performance.\n *\n * Default: ['**\\/*.{js,ts,mjs,cjs,jsx,tsx,mjx,cjx}', '!**\\/node_modules/**']\n *\n * Example: `['src/**\\/*.{ts,tsx}', '../ui-library/**\\/*.{ts,tsx}']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n */\n traversePattern: customConfiguration?.traversePattern ?? TRAVERSE_PATTERN,\n\n /**\n * Output format of the dictionaries\n *\n * Can be set on large projects to improve build performance.\n *\n * Default: ['cjs', 'esm']\n *\n * The output format of the dictionaries. It can be either 'cjs' or 'esm'.\n * - 'cjs': The dictionaries are outputted as CommonJS modules.\n * - 'esm': The dictionaries are outputted as ES modules.\n */\n outputFormat: customConfiguration?.outputFormat ?? OUTPUT_FORMAT,\n\n /**\n * Cache\n */\n cache: customConfiguration?.cache ?? CACHE,\n\n /**\n * Require function\n */\n require: customConfiguration?.require,\n});\n\nconst buildDictionaryFields = (\n customConfiguration?: Partial<DictionaryConfig>\n): DictionaryConfig => ({\n /**\n * Indicate how the dictionary should be filled using AI.\n *\n * Default: true\n */\n fill: customConfiguration?.fill ?? FILL,\n});\n\n/**\n * Build the configuration fields by merging the default values with the custom configuration\n */\nexport const buildConfigurationFields = (\n customConfiguration?: CustomIntlayerConfig,\n baseDir?: string,\n logFunctions?: LogFunctions\n): IntlayerConfig => {\n const internationalizationConfig = buildInternationalizationFields(\n customConfiguration?.internationalization\n );\n\n const routingConfig = buildRoutingFields(customConfiguration?.routing);\n\n const contentConfig = buildContentFields(\n customConfiguration?.content,\n baseDir\n );\n\n const editorConfig = buildEditorFields(customConfiguration?.editor);\n\n const logConfig = buildLogFields(customConfiguration?.log, logFunctions);\n\n const aiConfig = buildAiFields(customConfiguration?.ai);\n\n const buildConfig = buildBuildFields(customConfiguration?.build);\n\n const dictionaryConfig = buildDictionaryFields(\n customConfiguration?.dictionary\n );\n\n storedConfiguration = {\n internationalization: internationalizationConfig,\n routing: routingConfig,\n content: contentConfig,\n editor: editorConfig,\n log: logConfig,\n ai: aiConfig,\n build: buildConfig,\n dictionary: dictionaryConfig,\n plugins: customConfiguration?.plugins,\n };\n\n return storedConfiguration;\n};\n"],"mappings":"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"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { logger } from "../logger.mjs";
|
|
2
2
|
import { cache } from "../utils/cache.mjs";
|
|
3
|
-
import { getPackageJsonPath } from "../utils/getPackageJsonPath.mjs";
|
|
4
3
|
import { buildConfigurationFields } from "./buildConfigurationFields.mjs";
|
|
5
|
-
import { loadConfigurationFile } from "./loadConfigurationFile.mjs";
|
|
6
4
|
import { searchConfigurationFile } from "./searchConfigurationFile.mjs";
|
|
5
|
+
import { getPackageJsonPath } from "../utils/getPackageJsonPath.mjs";
|
|
6
|
+
import { loadConfigurationFile } from "./loadConfigurationFile.mjs";
|
|
7
7
|
import { relative } from "node:path";
|
|
8
8
|
import merge from "deepmerge";
|
|
9
9
|
|
|
@@ -12,16 +12,15 @@ import merge from "deepmerge";
|
|
|
12
12
|
* Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)
|
|
13
13
|
*/
|
|
14
14
|
const getConfigurationAndFilePath = (options) => {
|
|
15
|
-
const { baseDir } = getPackageJsonPath();
|
|
16
15
|
const mergedOptions = {
|
|
17
|
-
baseDir,
|
|
18
16
|
require: options?.require,
|
|
19
17
|
...options
|
|
20
18
|
};
|
|
19
|
+
const baseDir = mergedOptions.baseDir ?? getPackageJsonPath().baseDir;
|
|
21
20
|
const cachedConfiguration = cache.get(mergedOptions);
|
|
22
21
|
if (cachedConfiguration) return cachedConfiguration;
|
|
23
|
-
const { configurationFilePath, numCustomConfiguration } = searchConfigurationFile(
|
|
24
|
-
if (options?.override?.log?.mode === "verbose") logConfigFileResult(
|
|
22
|
+
const { configurationFilePath, numCustomConfiguration } = searchConfigurationFile(baseDir);
|
|
23
|
+
if (options?.override?.log?.mode === "verbose") logConfigFileResult(baseDir, numCustomConfiguration, configurationFilePath);
|
|
25
24
|
let storedConfiguration;
|
|
26
25
|
if (configurationFilePath) storedConfiguration = buildConfigurationFields(loadConfigurationFile(configurationFilePath, {
|
|
27
26
|
projectRequire: mergedOptions.require,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConfiguration.mjs","names":["storedConfiguration: IntlayerConfig | undefined","projectRequireConfig: CustomIntlayerConfig"],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n LogFunctions,\n} from '@intlayer/types';\nimport merge from 'deepmerge';\nimport type { SandBoxContextOptions } from '../loadExternalFile/parseFileContent';\nimport { logger } from '../logger';\nimport { cache } from '../utils/cache';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nexport type GetConfigurationOptions = {\n baseDir?: string;\n override?: CustomIntlayerConfig;\n // Dotenv options\n env?: string;\n envFile?: string;\n // Log functions\n logFunctions?: LogFunctions;\n // Require function\n require?: NodeJS.Require;\n} & Omit<SandBoxContextOptions, 'projectRequire'>;\n\nexport type GetConfigurationAndFilePathResult = {\n configuration: IntlayerConfig;\n configurationFilePath: string | undefined;\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfigurationAndFilePath = (\n options?: GetConfigurationOptions\n): GetConfigurationAndFilePathResult => {\n const
|
|
1
|
+
{"version":3,"file":"getConfiguration.mjs","names":["storedConfiguration: IntlayerConfig | undefined","projectRequireConfig: CustomIntlayerConfig"],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n LogFunctions,\n} from '@intlayer/types';\nimport merge from 'deepmerge';\nimport type { SandBoxContextOptions } from '../loadExternalFile/parseFileContent';\nimport { logger } from '../logger';\nimport { cache } from '../utils/cache';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nexport type GetConfigurationOptions = {\n baseDir?: string;\n override?: CustomIntlayerConfig;\n // Dotenv options\n env?: string;\n envFile?: string;\n // Log functions\n logFunctions?: LogFunctions;\n // Require function\n require?: NodeJS.Require;\n} & Omit<SandBoxContextOptions, 'projectRequire'>;\n\nexport type GetConfigurationAndFilePathResult = {\n configuration: IntlayerConfig;\n configurationFilePath: string | undefined;\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfigurationAndFilePath = (\n options?: GetConfigurationOptions\n): GetConfigurationAndFilePathResult => {\n const mergedOptions = {\n require: options?.require,\n ...options,\n };\n\n const baseDir = mergedOptions.baseDir ?? getPackageJsonPath().baseDir;\n\n const cachedConfiguration =\n cache.get<GetConfigurationAndFilePathResult>(mergedOptions);\n\n if (cachedConfiguration) return cachedConfiguration;\n\n // Search for configuration files\n const { configurationFilePath, numCustomConfiguration } =\n searchConfigurationFile(baseDir);\n\n if (options?.override?.log?.mode === 'verbose') {\n logConfigFileResult(baseDir, numCustomConfiguration, configurationFilePath);\n }\n\n let storedConfiguration: IntlayerConfig | undefined;\n\n if (configurationFilePath) {\n // Load the custom configuration\n const customConfiguration: CustomIntlayerConfig | undefined =\n loadConfigurationFile(configurationFilePath, {\n projectRequire: mergedOptions.require,\n // Dotenv options\n envVarOptions: {\n env: mergedOptions.env,\n envFile: mergedOptions.envFile,\n },\n // Sandbox context additional variables\n additionalEnvVars: mergedOptions.additionalEnvVars,\n aliases: mergedOptions.aliases,\n });\n\n // Save the configuration to avoid reading the file again\n storedConfiguration = buildConfigurationFields(\n customConfiguration,\n mergedOptions.baseDir,\n mergedOptions.logFunctions\n );\n }\n\n // Log warning if multiple configuration files are found\n\n const projectRequireConfig: CustomIntlayerConfig = mergedOptions.require\n ? {\n build: {\n require: mergedOptions.require,\n },\n }\n : {};\n\n const configWithProjectRequire = merge(\n storedConfiguration ?? {},\n projectRequireConfig\n ) as CustomIntlayerConfig;\n\n const configuration = merge(\n configWithProjectRequire,\n mergedOptions.override ?? {}\n ) as IntlayerConfig;\n\n cache.set(mergedOptions, {\n configuration,\n configurationFilePath,\n });\n\n return {\n configuration,\n configurationFilePath,\n };\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfiguration = (\n options?: GetConfigurationOptions\n): IntlayerConfig => getConfigurationAndFilePath(options).configuration;\n\nconst logConfigFileResult = (\n baseDir: string,\n numCustomConfiguration?: number,\n configurationFilePath?: string\n) => {\n if (numCustomConfiguration === 0) {\n logger('Configuration file not found, using default configuration.', {\n isVerbose: true,\n });\n } else {\n const relativeOutputPath = relative(baseDir, configurationFilePath!);\n\n if (numCustomConfiguration === 1) {\n logger(`Configuration file found: ${relativeOutputPath}.`, {\n isVerbose: true,\n });\n } else {\n logger(\n `Multiple configuration files found, using ${relativeOutputPath}.`,\n {\n isVerbose: true,\n }\n );\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;AAmCA,MAAa,+BACX,YACsC;CACtC,MAAM,gBAAgB;EACpB,SAAS,SAAS;EAClB,GAAG;EACJ;CAED,MAAM,UAAU,cAAc,WAAW,oBAAoB,CAAC;CAE9D,MAAM,sBACJ,MAAM,IAAuC,cAAc;AAE7D,KAAI,oBAAqB,QAAO;CAGhC,MAAM,EAAE,uBAAuB,2BAC7B,wBAAwB,QAAQ;AAElC,KAAI,SAAS,UAAU,KAAK,SAAS,UACnC,qBAAoB,SAAS,wBAAwB,sBAAsB;CAG7E,IAAIA;AAEJ,KAAI,sBAgBF,uBAAsB,yBAbpB,sBAAsB,uBAAuB;EAC3C,gBAAgB,cAAc;EAE9B,eAAe;GACb,KAAK,cAAc;GACnB,SAAS,cAAc;GACxB;EAED,mBAAmB,cAAc;EACjC,SAAS,cAAc;EACxB,CAAC,EAKF,cAAc,SACd,cAAc,aACf;CAKH,MAAMC,uBAA6C,cAAc,UAC7D,EACE,OAAO,EACL,SAAS,cAAc,SACxB,EACF,GACD,EAAE;CAON,MAAM,gBAAgB,MALW,MAC/B,uBAAuB,EAAE,EACzB,qBACD,EAIC,cAAc,YAAY,EAAE,CAC7B;AAED,OAAM,IAAI,eAAe;EACvB;EACA;EACD,CAAC;AAEF,QAAO;EACL;EACA;EACD;;;;;AAMH,MAAa,oBACX,YACmB,4BAA4B,QAAQ,CAAC;AAE1D,MAAM,uBACJ,SACA,wBACA,0BACG;AACH,KAAI,2BAA2B,EAC7B,QAAO,8DAA8D,EACnE,WAAW,MACZ,CAAC;MACG;EACL,MAAM,qBAAqB,SAAS,SAAS,sBAAuB;AAEpE,MAAI,2BAA2B,EAC7B,QAAO,6BAA6B,mBAAmB,IAAI,EACzD,WAAW,MACZ,CAAC;MAEF,QACE,6CAA6C,mBAAmB,IAChE,EACE,WAAW,MACZ,CACF"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -3,20 +3,20 @@ import { normalizePath } from "./utils/normalizePath.mjs";
|
|
|
3
3
|
import { getAlias } from "./alias.mjs";
|
|
4
4
|
import { ANSIColors, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, getAppLogger, logger, removeColor, spinnerFrames, v, x } from "./logger.mjs";
|
|
5
5
|
import { cache, clearCache, getCache, localCache, setCache } from "./utils/cache.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import { ESMxCJSRequire, configESMxCJSRequire, isESModule } from "./utils/ESMxCJSHelpers.mjs";
|
|
6
|
+
import { bundleJSFile } from "./bundleJSFile.mjs";
|
|
8
7
|
import { buildConfigurationFields } from "./configFile/buildConfigurationFields.mjs";
|
|
8
|
+
import { searchConfigurationFile } from "./configFile/searchConfigurationFile.mjs";
|
|
9
|
+
import { defaultValues_exports } from "./defaultValues/index.mjs";
|
|
9
10
|
import { getEnvFilePath, loadEnvFile } from "./loadEnvFile.mjs";
|
|
10
|
-
import { parseFileContent } from "./loadExternalFile/parseFileContent.mjs";
|
|
11
11
|
import { bundleFile, bundleFileSync } from "./loadExternalFile/bundleFile.mjs";
|
|
12
|
+
import { configESMxCJSRequire, getProjectRequire, isESModule } from "./utils/ESMxCJSHelpers.mjs";
|
|
13
|
+
import { parseFileContent } from "./loadExternalFile/parseFileContent.mjs";
|
|
12
14
|
import { loadExternalFile, loadExternalFileSync } from "./loadExternalFile/loadExternalFile.mjs";
|
|
13
|
-
import { searchConfigurationFile } from "./configFile/searchConfigurationFile.mjs";
|
|
14
|
-
import { getConfiguration, getConfigurationAndFilePath } from "./configFile/getConfiguration.mjs";
|
|
15
|
-
import { bundleJSFile } from "./bundleJSFile.mjs";
|
|
16
|
-
import { defaultValues_exports } from "./defaultValues/index.mjs";
|
|
17
|
-
import { logStack } from "./utils/logStack.mjs";
|
|
18
15
|
import { extractErrorMessage } from "./utils/extractErrorMessage.mjs";
|
|
19
16
|
import { retryManager } from "./retryManager.mjs";
|
|
20
17
|
import { clearModuleCache } from "./utils/clearModuleCache.mjs";
|
|
18
|
+
import { logStack } from "./utils/logStack.mjs";
|
|
19
|
+
import { getPackageJsonPath } from "./utils/getPackageJsonPath.mjs";
|
|
20
|
+
import { getConfiguration, getConfigurationAndFilePath } from "./configFile/getConfiguration.mjs";
|
|
21
21
|
|
|
22
|
-
export { ANSIColors, defaultValues_exports as DefaultValues,
|
|
22
|
+
export { ANSIColors, defaultValues_exports as DefaultValues, buildConfigurationFields, bundleFile, bundleFileSync, bundleJSFile, cache, clearCache, clearModuleCache, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, configESMxCJSRequire, extractErrorMessage, getAlias, getAppLogger, getCache, getConfiguration, getConfigurationAndFilePath, getEnvFilePath, getExtension, getPackageJsonPath, getProjectRequire, isESModule, loadEnvFile, loadExternalFile, loadExternalFileSync, localCache, logStack, logger, normalizePath, parseFileContent, removeColor, retryManager, searchConfigurationFile, setCache, spinnerFrames, v, x };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { colorizePath, logger } from "../logger.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { getProjectRequire } from "../utils/ESMxCJSHelpers.mjs";
|
|
3
3
|
import { parseFileContent } from "./parseFileContent.mjs";
|
|
4
4
|
import { transpileTSToMJS, transpileTSToMJSSync } from "./transpileTSToMJS.mjs";
|
|
5
5
|
import { extname } from "node:path";
|
|
@@ -14,7 +14,7 @@ import { readFileSync } from "node:fs";
|
|
|
14
14
|
*/
|
|
15
15
|
const loadExternalFileSync = (filePath, options) => {
|
|
16
16
|
const fileExtension = extname(filePath);
|
|
17
|
-
const safeProjectRequire = options?.projectRequire ??
|
|
17
|
+
const safeProjectRequire = options?.projectRequire ?? getProjectRequire();
|
|
18
18
|
try {
|
|
19
19
|
if (fileExtension === "json") {
|
|
20
20
|
delete safeProjectRequire.cache[safeProjectRequire.resolve(filePath)];
|
|
@@ -48,7 +48,7 @@ const loadExternalFileSync = (filePath, options) => {
|
|
|
48
48
|
*/
|
|
49
49
|
const loadExternalFile = async (filePath, options) => {
|
|
50
50
|
const fileExtension = extname(filePath);
|
|
51
|
-
const safeProjectRequire = options?.projectRequire ??
|
|
51
|
+
const safeProjectRequire = options?.projectRequire ?? getProjectRequire();
|
|
52
52
|
try {
|
|
53
53
|
if (fileExtension === "json") {
|
|
54
54
|
delete safeProjectRequire.cache[safeProjectRequire.resolve(filePath)];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadExternalFile.mjs","names":["moduleResultString: string | undefined"],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport type { BuildOptions, Plugin } from 'esbuild';\nimport { colorizePath, logger } from '../logger';\nimport {
|
|
1
|
+
{"version":3,"file":"loadExternalFile.mjs","names":["moduleResultString: string | undefined"],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport type { BuildOptions, Plugin } from 'esbuild';\nimport { colorizePath, logger } from '../logger';\nimport { getProjectRequire } from '../utils/ESMxCJSHelpers';\nimport {\n parseFileContent,\n type SandBoxContextOptions,\n} from './parseFileContent';\nimport { transpileTSToMJS, transpileTSToMJSSync } from './transpileTSToMJS';\n\nexport type ESBuildPlugin = Plugin;\n\nexport type LoadExternalFileOptions = {\n configuration?: IntlayerConfig;\n buildOptions?: BuildOptions;\n} & SandBoxContextOptions;\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFileSync = (\n filePath: string,\n options?: LoadExternalFileOptions\n): any | undefined => {\n const fileExtension = extname(filePath);\n const safeProjectRequire = options?.projectRequire ?? getProjectRequire();\n\n try {\n if (fileExtension === 'json') {\n // Remove cache to force getting fresh content\n delete safeProjectRequire.cache[safeProjectRequire.resolve(filePath)];\n // Assume JSON\n return safeProjectRequire(filePath);\n }\n\n // Rest is JS, MJS or TS\n const code = readFileSync(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = transpileTSToMJSSync(\n code,\n filePath\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File file could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = async (\n filePath: string,\n options?: LoadExternalFileOptions\n): Promise<any | undefined> => {\n const fileExtension = extname(filePath);\n const safeProjectRequire = options?.projectRequire ?? getProjectRequire();\n\n try {\n if (fileExtension === 'json') {\n // Remove cache to force getting fresh content\n delete safeProjectRequire.cache[safeProjectRequire.resolve(filePath)];\n // Assume JSON\n return safeProjectRequire(filePath);\n }\n\n // Rest is JS, MJS or TS\n const code = await readFile(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = await transpileTSToMJS(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File file could not be loaded. Path : ${colorizePath(filePath)}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;;AAyBA,MAAa,wBACX,UACA,YACoB;CACpB,MAAM,gBAAgB,QAAQ,SAAS;CACvC,MAAM,qBAAqB,SAAS,kBAAkB,mBAAmB;AAEzE,KAAI;AACF,MAAI,kBAAkB,QAAQ;AAE5B,UAAO,mBAAmB,MAAM,mBAAmB,QAAQ,SAAS;AAEpE,UAAO,mBAAmB,SAAS;;EAMrC,MAAMA,qBAAyC,qBAFlC,aAAa,UAAU,QAAQ,EAI1C,SACD;AAED,MAAI,CAAC,oBAAoB;AACvB,UAAO,6BAA6B,EAAE,OAAO,SAAS,CAAC;AACvD;;EAGF,MAAM,cAAc,iBAAiB,oBAAoB;GACvD,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,mBAAmB,SAAS;GAC5B,OAAO,SAAS;GAChB,SAAS,SAAS;GACnB,CAAC;AAEF,MAAI,OAAO,gBAAgB,aAAa;AACtC,UAAO,yCAAyC,WAAW;AAC3D;;AAGF,SAAO;UACA,OAAO;AACd,SACE,CACE,UAAW,MAAgB,QAAQ,MACnC,KAAK,UAAW,MAAgB,OAAO,MAAM,EAAE,CAChD,EACD,EACE,OAAO,SACR,CACF;;;;;;;;AASL,MAAa,mBAAmB,OAC9B,UACA,YAC6B;CAC7B,MAAM,gBAAgB,QAAQ,SAAS;CACvC,MAAM,qBAAqB,SAAS,kBAAkB,mBAAmB;AAEzE,KAAI;AACF,MAAI,kBAAkB,QAAQ;AAE5B,UAAO,mBAAmB,MAAM,mBAAmB,QAAQ,SAAS;AAEpE,UAAO,mBAAmB,SAAS;;EAMrC,MAAMA,qBAAyC,MAAM,iBAFxC,MAAM,SAAS,UAAU,QAAQ,EAI5C,UACA,SAAS,aACV;AAED,MAAI,CAAC,oBAAoB;AACvB,UAAO,6BAA6B,EAAE,OAAO,SAAS,CAAC;AACvD;;EAGF,MAAM,cAAc,iBAAiB,oBAAoB;GACvD,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,mBAAmB,SAAS;GAC5B,OAAO,SAAS;GAChB,SAAS,SAAS;GACnB,CAAC;AAEF,MAAI,OAAO,gBAAgB,aAAa;AACtC,UAAO,yCAAyC,aAAa,SAAS,GAAG;AACzE;;AAGF,SAAO;UACA,OAAO;AACd,SACE,CACE,UAAW,MAAgB,QAAQ,MACnC,KAAK,UAAW,MAAgB,OAAO,MAAM,EAAE,CAChD,EACD,EACE,OAAO,SACR,CACF"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ESMxCJSRequire } from "../utils/ESMxCJSHelpers.mjs";
|
|
2
1
|
import { loadEnvFile } from "../loadEnvFile.mjs";
|
|
3
|
-
import {
|
|
2
|
+
import { getProjectRequire } from "../utils/ESMxCJSHelpers.mjs";
|
|
4
3
|
import * as esbuild from "esbuild";
|
|
4
|
+
import { runInNewContext } from "node:vm";
|
|
5
5
|
|
|
6
6
|
//#region src/loadExternalFile/parseFileContent.ts
|
|
7
7
|
const getSandBoxContext = (options) => {
|
|
8
8
|
const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } = options ?? {};
|
|
9
9
|
let additionalGlobalVar = {};
|
|
10
|
-
const baseRequire = typeof projectRequire === "function" ? projectRequire :
|
|
10
|
+
const baseRequire = typeof projectRequire === "function" ? projectRequire : getProjectRequire();
|
|
11
11
|
const mockedRequire = (() => {
|
|
12
12
|
const mockTable = Object.assign({ esbuild }, mocks);
|
|
13
13
|
const aliasTable = Object.assign({}, aliases);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseFileContent.mjs","names":["baseRequire: NodeJS.Require","mockedRequire: NodeJS.Require","sandboxContext: Context","candidates: unknown[]"],"sources":["../../../src/loadExternalFile/parseFileContent.ts"],"sourcesContent":["import { type Context, runInNewContext } from 'node:vm';\nimport * as esbuild from 'esbuild';\nimport { type LoadEnvFileOptions, loadEnvFile } from '../loadEnvFile';\nimport {
|
|
1
|
+
{"version":3,"file":"parseFileContent.mjs","names":["baseRequire: NodeJS.Require","mockedRequire: NodeJS.Require","sandboxContext: Context","candidates: unknown[]"],"sources":["../../../src/loadExternalFile/parseFileContent.ts"],"sourcesContent":["import { type Context, runInNewContext } from 'node:vm';\nimport * as esbuild from 'esbuild';\nimport { type LoadEnvFileOptions, loadEnvFile } from '../loadEnvFile';\nimport { getProjectRequire } from '../utils/ESMxCJSHelpers';\n\nexport type SandBoxContextOptions = {\n envVarOptions?: LoadEnvFileOptions;\n projectRequire?: NodeJS.Require;\n additionalEnvVars?: Record<string, string>;\n /**\n * Map of specifier -> mocked export to be returned when code in the VM calls require(specifier).\n * Example:\n * mocks: {\n * '@intlayer/config/built': { getConfig: () => ({}), Locales: {} }\n * }\n */\n mocks?: Record<string, any>;\n /**\n * Optional alias map if you want to redirect specifiers.\n * Useful when user code imports a subpath you want to collapse.\n * Example:\n * aliases: { '@intlayer/config/built': '@intlayer/config' }\n */\n aliases?: Record<string, string>;\n};\n\nexport const getSandBoxContext = (options?: SandBoxContextOptions): Context => {\n const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } =\n options ?? {};\n\n let additionalGlobalVar = {};\n\n const baseRequire: NodeJS.Require =\n typeof projectRequire === 'function' ? projectRequire : getProjectRequire();\n\n // Wrap require to honor mocks and aliases inside the VM\n const mockedRequire: NodeJS.Require = (() => {\n const mockTable = Object.assign(\n {\n esbuild,\n },\n mocks\n );\n const aliasTable = Object.assign({}, aliases);\n\n const wrappedRequire = function mockableRequire(id: string) {\n const target = aliasTable?.[id] ? aliasTable[id] : id;\n\n if (mockTable && Object.hasOwn(mockTable, target)) {\n return mockTable[target];\n }\n\n // If the original id was aliased, allow mocks to be defined on either key.\n if (target !== id && mockTable && Object.hasOwn(mockTable, id)) {\n return mockTable[id];\n }\n\n return baseRequire(target);\n } as NodeJS.Require;\n\n // Mirror NodeJS.Require properties\n wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);\n wrappedRequire.main = baseRequire.main;\n wrappedRequire.extensions = baseRequire.extensions;\n wrappedRequire.cache = baseRequire.cache;\n\n return wrappedRequire;\n })();\n\n try {\n // Dynamically try to require React if it's installed in the project\n additionalGlobalVar = {\n React: baseRequire('react'),\n };\n } catch (_err) {\n // React is not installed, so we don't inject it\n }\n\n const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n process: {\n ...process,\n env: {\n ...process.env,\n ...loadEnvFile(envVarOptions),\n ...additionalEnvVars,\n },\n },\n console,\n require: mockedRequire,\n ...additionalGlobalVar,\n };\n\n // Dynamically inject all global variables\n Object.getOwnPropertyNames(globalThis).forEach((key) => {\n if (!(key in sandboxContext)) {\n sandboxContext[key] = globalThis[key as keyof typeof globalThis];\n }\n });\n\n return sandboxContext;\n};\n\nexport const parseFileContent = <T>(\n fileContentString: string,\n options?: SandBoxContextOptions\n): T | undefined => {\n const sandboxContext = getSandBoxContext(options);\n\n // Force strict mode so illegal writes throw instead of silently failing.\n runInNewContext(`\"use strict\";\\n${fileContentString}`, sandboxContext);\n\n const candidates: unknown[] = [\n sandboxContext.exports?.default,\n sandboxContext.module?.exports?.defaults,\n sandboxContext.module?.exports?.default,\n sandboxContext.module?.exports,\n ];\n\n for (const candidate of candidates) {\n if (\n candidate &&\n typeof candidate === 'object' &&\n Object.keys(candidate as object).length > 0\n ) {\n return candidate as T;\n }\n }\n};\n"],"mappings":";;;;;;AA0BA,MAAa,qBAAqB,YAA6C;CAC7E,MAAM,EAAE,eAAe,gBAAgB,mBAAmB,OAAO,YAC/D,WAAW,EAAE;CAEf,IAAI,sBAAsB,EAAE;CAE5B,MAAMA,cACJ,OAAO,mBAAmB,aAAa,iBAAiB,mBAAmB;CAG7E,MAAMC,uBAAuC;EAC3C,MAAM,YAAY,OAAO,OACvB,EACE,SACD,EACD,MACD;EACD,MAAM,aAAa,OAAO,OAAO,EAAE,EAAE,QAAQ;EAE7C,MAAM,iBAAiB,SAAS,gBAAgB,IAAY;GAC1D,MAAM,SAAS,aAAa,MAAM,WAAW,MAAM;AAEnD,OAAI,aAAa,OAAO,OAAO,WAAW,OAAO,CAC/C,QAAO,UAAU;AAInB,OAAI,WAAW,MAAM,aAAa,OAAO,OAAO,WAAW,GAAG,CAC5D,QAAO,UAAU;AAGnB,UAAO,YAAY,OAAO;;AAI5B,iBAAe,UAAU,YAAY,QAAQ,KAAK,YAAY;AAC9D,iBAAe,OAAO,YAAY;AAClC,iBAAe,aAAa,YAAY;AACxC,iBAAe,QAAQ,YAAY;AAEnC,SAAO;KACL;AAEJ,KAAI;AAEF,wBAAsB,EACpB,OAAO,YAAY,QAAQ,EAC5B;UACM,MAAM;CAIf,MAAMC,iBAA0B;EAC9B,SAAS,EACP,SAAS,EAAE,EACZ;EACD,QAAQ,EACN,SAAS,EAAE,EACZ;EACD,SAAS;GACP,GAAG;GACH,KAAK;IACH,GAAG,QAAQ;IACX,GAAG,YAAY,cAAc;IAC7B,GAAG;IACJ;GACF;EACD;EACA,SAAS;EACT,GAAG;EACJ;AAGD,QAAO,oBAAoB,WAAW,CAAC,SAAS,QAAQ;AACtD,MAAI,EAAE,OAAO,gBACX,gBAAe,OAAO,WAAW;GAEnC;AAEF,QAAO;;AAGT,MAAa,oBACX,mBACA,YACkB;CAClB,MAAM,iBAAiB,kBAAkB,QAAQ;AAGjD,iBAAgB,kBAAkB,qBAAqB,eAAe;CAEtE,MAAMC,aAAwB;EAC5B,eAAe,SAAS;EACxB,eAAe,QAAQ,SAAS;EAChC,eAAe,QAAQ,SAAS;EAChC,eAAe,QAAQ;EACxB;AAED,MAAK,MAAM,aAAa,WACtB,KACE,aACA,OAAO,cAAc,YACrB,OAAO,KAAK,UAAoB,CAAC,SAAS,EAE1C,QAAO"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getLoader } from "./bundleFile.mjs";
|
|
2
|
+
import { getPackageJsonPath } from "../utils/getPackageJsonPath.mjs";
|
|
2
3
|
import { dirname, extname, join } from "node:path";
|
|
3
4
|
import { build, buildSync } from "esbuild";
|
|
4
5
|
import { pathToFileURL } from "node:url";
|
|
@@ -22,7 +23,7 @@ const getTransformationOptions = (filePath) => ({
|
|
|
22
23
|
write: false,
|
|
23
24
|
packages: "external",
|
|
24
25
|
bundle: true,
|
|
25
|
-
tsconfig: join(
|
|
26
|
+
tsconfig: join(getPackageJsonPath(dirname(filePath)).baseDir, "tsconfig.json"),
|
|
26
27
|
define: { "import.meta.url": JSON.stringify(pathToFileURL(filePath).href) }
|
|
27
28
|
});
|
|
28
29
|
const transpileTSToMJSSync = (code, filePath, options) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpileTSToMJS.mjs","names":[],"sources":["../../../src/loadExternalFile/transpileTSToMJS.ts"],"sourcesContent":["import { dirname, extname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n type BuildOptions,\n type BuildResult,\n build,\n buildSync,\n type Plugin,\n} from 'esbuild';\nimport { getLoader } from './bundleFile';\n\nexport type ESBuildPlugin = Plugin;\n\nconst getTransformationOptions = (filePath: string): BuildOptions => ({\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n '.md': 'text',\n '.mdx': 'text',\n },\n format: 'cjs',\n target: 'node20',\n platform: 'node',\n write: false,\n packages: 'external',\n bundle: true,\n tsconfig: join(
|
|
1
|
+
{"version":3,"file":"transpileTSToMJS.mjs","names":[],"sources":["../../../src/loadExternalFile/transpileTSToMJS.ts"],"sourcesContent":["import { dirname, extname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n type BuildOptions,\n type BuildResult,\n build,\n buildSync,\n type Plugin,\n} from 'esbuild';\nimport { getPackageJsonPath } from '..';\nimport { getLoader } from './bundleFile';\n\nexport type ESBuildPlugin = Plugin;\n\nconst getTransformationOptions = (filePath: string): BuildOptions => ({\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n '.md': 'text',\n '.mdx': 'text',\n },\n format: 'cjs',\n target: 'node20',\n platform: 'node',\n write: false,\n packages: 'external',\n bundle: true,\n tsconfig: join(\n getPackageJsonPath(dirname(filePath)).baseDir,\n 'tsconfig.json'\n ),\n define: {\n 'import.meta.url': JSON.stringify(pathToFileURL(filePath).href),\n },\n});\n\nexport const transpileTSToMJSSync = (\n code: string,\n filePath: string,\n options?: BuildOptions\n): string | undefined => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = buildSync({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n\nexport const transpileTSToMJS = async (\n code: string,\n filePath: string,\n options?: BuildOptions\n): Promise<string | undefined> => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = await build({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n"],"mappings":";;;;;;;AAcA,MAAM,4BAA4B,cAAoC;CACpE,QAAQ;EACN,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,OAAO;EACP,QAAQ;EACT;CACD,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,OAAO;CACP,UAAU;CACV,QAAQ;CACR,UAAU,KACR,mBAAmB,QAAQ,SAAS,CAAC,CAAC,SACtC,gBACD;CACD,QAAQ,EACN,mBAAmB,KAAK,UAAU,cAAc,SAAS,CAAC,KAAK,EAChE;CACF;AAED,MAAa,wBACX,MACA,UACA,YACuB;AAiBvB,QAbkC,UAAU;EAC1C,OAAO;GACL,UAAU;GACV,QALW,UADG,QAAQ,SAAS,CACA;GAM/B,YAAY,QAAQ,SAAS;GAC7B,YAAY;GACb;EACD,GAAG,yBAAyB,SAAS;EACrC,GAAG;EACJ,CAAC,CAEsC,cAAc,GAAG;;AAK3D,MAAa,mBAAmB,OAC9B,MACA,UACA,YACgC;AAiBhC,SAbkC,MAAM,MAAM;EAC5C,OAAO;GACL,UAAU;GACV,QALW,UADG,QAAQ,SAAS,CACA;GAM/B,YAAY,QAAQ,SAAS;GAC7B,YAAY;GACb;EACD,GAAG,yBAAyB,SAAS;EACrC,GAAG;EACJ,CAAC,EAEsC,cAAc,GAAG"}
|
package/dist/esm/package.mjs
CHANGED
package/dist/esm/package.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.mjs","names":[],"sources":["../../package.json"],"sourcesContent":["{\n \"name\": \"@intlayer/config\",\n \"version\": \"7.0.
|
|
1
|
+
{"version":3,"file":"package.mjs","names":[],"sources":["../../package.json"],"sourcesContent":["{\n \"name\": \"@intlayer/config\",\n \"version\": \"7.0.2\",\n \"private\": false,\n \"description\": \"Retrieve Intlayer configurations and manage environment variables for both server-side and client-side environments.\",\n \"keywords\": [\n \"intlayer\",\n \"layer\",\n \"abstraction\",\n \"data\",\n \"internationalization\",\n \"i18n\",\n \"typescript\",\n \"javascript\",\n \"json\",\n \"file\"\n ],\n \"homepage\": \"https://intlayer.org\",\n \"bugs\": {\n \"url\": \"https://github.com/aymericzip/intlayer/issues\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/aymericzip/intlayer.git\"\n },\n \"license\": \"Apache-2.0\",\n \"author\": {\n \"name\": \"Aymeric PINEAU\",\n \"url\": \"https://github.com/aymericzip\"\n },\n \"contributors\": [\n {\n \"name\": \"Aymeric Pineau\",\n \"email\": \"ay.pineau@gmail.com\",\n \"url\": \"https://github.com/aymericzip\"\n }\n ],\n \"sideEffects\": false,\n \"exports\": {\n \".\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"browser\": \"./dist/esm/client.mjs\",\n \"require\": \"./dist/cjs/index.cjs\",\n \"import\": \"./dist/esm/index.mjs\"\n },\n \"./client\": {\n \"types\": \"./dist/types/client.d.ts\",\n \"require\": \"./dist/cjs/client.cjs\",\n \"import\": \"./dist/esm/client.mjs\"\n },\n \"./built\": {\n \"types\": \"./dist/types/built.d.ts\",\n \"require\": \"./dist/cjs/built.cjs\",\n \"import\": \"./dist/esm/built.mjs\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"main\": \"dist/cjs/index.cjs\",\n \"module\": \"dist/esm/index.mjs\",\n \"types\": \"dist/types/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \".\": [\n \"./dist/types/index.d.ts\"\n ],\n \"client\": [\n \"./dist/types/client.d.ts\"\n ],\n \"built\": [\n \"./dist/types/built.d.ts\"\n ],\n \"package.json\": [\n \"./package.json\"\n ]\n }\n },\n \"files\": [\n \"./dist\",\n \"./package.json\"\n ],\n \"scripts\": {\n \"build\": \"tsdown --config tsdown.config.ts\",\n \"build:ci\": \"tsdown --config tsdown.config.ts\",\n \"clean\": \"rimraf ./dist .turbo\",\n \"dev\": \"tsdown --config tsdown.config.ts --watch\",\n \"format\": \"biome format . --check\",\n \"format:fix\": \"biome format --write .\",\n \"lint\": \"biome lint .\",\n \"lint:fix\": \"biome lint --write .\",\n \"prepublish\": \"cp -f ../../../README.md ./README.md\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"typecheck\": \"tsc --noEmit --project tsconfig.types.json\"\n },\n \"dependencies\": {\n \"@intlayer/types\": \"workspace:*\",\n \"deepmerge\": \"4.3.1\",\n \"dotenv\": \"16.6.1\",\n \"esbuild\": \"0.25.2\"\n },\n \"devDependencies\": {\n \"@types/node\": \"24.9.2\",\n \"@utils/ts-config\": \"workspace:*\",\n \"@utils/ts-config-types\": \"workspace:*\",\n \"@utils/tsdown-config\": \"workspace:*\",\n \"rimraf\": \"6.0.1\",\n \"tsdown\": \"0.15.11\",\n \"typescript\": \"5.9.3\",\n \"vitest\": \"4.0.5\"\n },\n \"peerDependencies\": {\n \"intlayer\": \"workspace:*\",\n \"react\": \">=16.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"intlayer\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n }\n },\n \"engines\": {\n \"node\": \">=14.18\"\n },\n \"bug\": {\n \"url\": \"https://github.com/aymericzip/intlayer/issues\"\n }\n}\n"],"mappings":";cAEa"}
|
|
@@ -9,7 +9,10 @@ const isESModule = typeof import.meta.url === "string";
|
|
|
9
9
|
*
|
|
10
10
|
* Note: Can resolve package that are installed in the user project, ex `'intlayer'`
|
|
11
11
|
*/
|
|
12
|
-
const
|
|
12
|
+
const getProjectRequire = (startDir) => {
|
|
13
|
+
const { packageJsonPath } = getPackageJsonPath(startDir);
|
|
14
|
+
return createRequire(packageJsonPath);
|
|
15
|
+
};
|
|
13
16
|
/**
|
|
14
17
|
* Require relative to the @intlayer/config package
|
|
15
18
|
*
|
|
@@ -18,5 +21,5 @@ const ESMxCJSRequire = createRequire(getPackageJsonPath().packageJsonPath);
|
|
|
18
21
|
const configESMxCJSRequire = isESModule ? createRequire(import.meta.url) : __require;
|
|
19
22
|
|
|
20
23
|
//#endregion
|
|
21
|
-
export {
|
|
24
|
+
export { configESMxCJSRequire, getProjectRequire, isESModule };
|
|
22
25
|
//# sourceMappingURL=ESMxCJSHelpers.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ESMxCJSHelpers.mjs","names":["
|
|
1
|
+
{"version":3,"file":"ESMxCJSHelpers.mjs","names":["configESMxCJSRequire: NodeJS.Require"],"sources":["../../../src/utils/ESMxCJSHelpers.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { getPackageJsonPath } from './getPackageJsonPath';\n\nexport const isESModule = typeof import.meta.url === 'string';\n\n/**\n * Require relative to the user project\n *\n * Note: Can resolve package that are installed in the user project, ex `'intlayer'`\n */\nexport const getProjectRequire = (startDir?: string): NodeJS.Require => {\n // Can fail on VSCode extensions\n const { packageJsonPath } = getPackageJsonPath(startDir);\n\n return createRequire(packageJsonPath);\n};\n\n/**\n * Require relative to the @intlayer/config package\n *\n * Note: Can resolve package that are installed in the config package, ex `'@intlayer/types'`\n */\nexport const configESMxCJSRequire: NodeJS.Require = isESModule\n ? createRequire(import.meta.url)\n : require;\n"],"mappings":";;;;;AAGA,MAAa,aAAa,OAAO,OAAO,KAAK,QAAQ;;;;;;AAOrD,MAAa,qBAAqB,aAAsC;CAEtE,MAAM,EAAE,oBAAoB,mBAAmB,SAAS;AAExD,QAAO,cAAc,gBAAgB;;;;;;;AAQvC,MAAaA,uBAAuC,aAChD,cAAc,OAAO,KAAK,IAAI"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { configESMxCJSRequire } from "./ESMxCJSHelpers.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/clearModuleCache.ts
|
|
4
4
|
/**
|
|
@@ -8,13 +8,13 @@ const clearModuleCache = (modulePath, visited = /* @__PURE__ */ new Set()) => {
|
|
|
8
8
|
if (visited.has(modulePath)) return;
|
|
9
9
|
visited.add(modulePath);
|
|
10
10
|
try {
|
|
11
|
-
const resolvedPath =
|
|
12
|
-
const cachedModule =
|
|
11
|
+
const resolvedPath = configESMxCJSRequire.resolve(modulePath);
|
|
12
|
+
const cachedModule = configESMxCJSRequire.cache[resolvedPath];
|
|
13
13
|
if (cachedModule) {
|
|
14
14
|
if (cachedModule.children) cachedModule.children.forEach((child) => {
|
|
15
15
|
clearModuleCache(child.filename, visited);
|
|
16
16
|
});
|
|
17
|
-
delete
|
|
17
|
+
delete configESMxCJSRequire.cache[resolvedPath];
|
|
18
18
|
}
|
|
19
19
|
} catch (error) {
|
|
20
20
|
console.warn(`Could not clear cache for module: ${modulePath}`, error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clearModuleCache.mjs","names":[],"sources":["../../../src/utils/clearModuleCache.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"clearModuleCache.mjs","names":[],"sources":["../../../src/utils/clearModuleCache.ts"],"sourcesContent":["import { configESMxCJSRequire } from './ESMxCJSHelpers';\n\n/**\n * Recursively clears the require cache for a module and all its dependencies\n */\nexport const clearModuleCache = (\n modulePath: string,\n visited = new Set<string>()\n) => {\n // Avoid infinite loops\n if (visited.has(modulePath)) {\n return;\n }\n visited.add(modulePath);\n\n try {\n const resolvedPath = configESMxCJSRequire.resolve(modulePath);\n\n // Get the cached module\n const cachedModule = configESMxCJSRequire.cache[resolvedPath];\n\n if (cachedModule) {\n // Clear cache for all children (dependencies) first\n if (cachedModule.children) {\n cachedModule.children.forEach((child) => {\n clearModuleCache(child.filename, visited);\n });\n }\n\n // Clear the cache for this module\n delete configESMxCJSRequire.cache[resolvedPath];\n }\n } catch (error) {\n // Module might not exist or be resolvable, skip it\n console.warn(`Could not clear cache for module: ${modulePath}`, error);\n }\n};\n"],"mappings":";;;;;;AAKA,MAAa,oBACX,YACA,0BAAU,IAAI,KAAa,KACxB;AAEH,KAAI,QAAQ,IAAI,WAAW,CACzB;AAEF,SAAQ,IAAI,WAAW;AAEvB,KAAI;EACF,MAAM,eAAe,qBAAqB,QAAQ,WAAW;EAG7D,MAAM,eAAe,qBAAqB,MAAM;AAEhD,MAAI,cAAc;AAEhB,OAAI,aAAa,SACf,cAAa,SAAS,SAAS,UAAU;AACvC,qBAAiB,MAAM,UAAU,QAAQ;KACzC;AAIJ,UAAO,qBAAqB,MAAM;;UAE7B,OAAO;AAEd,UAAQ,KAAK,qCAAqC,cAAc,MAAM"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { cache } from "./cache.mjs";
|
|
2
|
+
import { logStack } from "./logStack.mjs";
|
|
2
3
|
import { dirname, join } from "node:path";
|
|
3
4
|
import { existsSync } from "node:fs";
|
|
4
5
|
|
|
@@ -25,7 +26,8 @@ const getPackageJsonPath = (startDir = process.cwd()) => {
|
|
|
25
26
|
if (parentDir === currentDir) break;
|
|
26
27
|
currentDir = parentDir;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
+
logStack("test");
|
|
30
|
+
throw new Error(`Could not find package.json in current directory or any of the ${MAX_LEVELS} parent directories. Searched from: ${startDir}`);
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageJsonPath.mjs","names":[],"sources":["../../../src/utils/getPackageJsonPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { cache } from './cache';\n\nexport const isESModule = typeof import.meta.url === 'string';\n\nconst MAX_LEVELS = 15;\n\ntype PackageJsonPathCache = {\n packageJsonPath: string;\n baseDir: string;\n};\n\nexport const getPackageJsonPath = (\n startDir: string = process.cwd()\n): PackageJsonPathCache => {\n const checkedCache = cache.get<PackageJsonPathCache>(\n 'packageJsonPath',\n startDir\n );\n\n if (checkedCache) return checkedCache;\n\n let currentDir = startDir;\n\n for (let level = 0; level < MAX_LEVELS; level++) {\n const packageJsonPath = join(currentDir, 'package.json');\n\n if (existsSync(packageJsonPath)) {\n cache.set('packageJsonPath', startDir, {\n packageJsonPath,\n baseDir: currentDir,\n });\n\n return { packageJsonPath, baseDir: currentDir };\n }\n\n const parentDir = dirname(currentDir);\n\n // If we've reached the root directory, stop\n if (parentDir === currentDir) {\n break;\n }\n\n currentDir = parentDir;\n }\n\n throw new Error(\n `Could not find package.json in current directory or any of the ${MAX_LEVELS} parent directories. Searched from: ${
|
|
1
|
+
{"version":3,"file":"getPackageJsonPath.mjs","names":[],"sources":["../../../src/utils/getPackageJsonPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { logStack } from '..';\nimport { cache } from './cache';\n\nexport const isESModule = typeof import.meta.url === 'string';\n\nconst MAX_LEVELS = 15;\n\ntype PackageJsonPathCache = {\n packageJsonPath: string;\n baseDir: string;\n};\n\nexport const getPackageJsonPath = (\n startDir: string = process.cwd()\n): PackageJsonPathCache => {\n const checkedCache = cache.get<PackageJsonPathCache>(\n 'packageJsonPath',\n startDir\n );\n\n if (checkedCache) return checkedCache;\n\n let currentDir = startDir;\n\n for (let level = 0; level < MAX_LEVELS; level++) {\n const packageJsonPath = join(currentDir, 'package.json');\n\n if (existsSync(packageJsonPath)) {\n cache.set('packageJsonPath', startDir, {\n packageJsonPath,\n baseDir: currentDir,\n });\n\n return { packageJsonPath, baseDir: currentDir };\n }\n\n const parentDir = dirname(currentDir);\n\n // If we've reached the root directory, stop\n if (parentDir === currentDir) {\n break;\n }\n\n currentDir = parentDir;\n }\n\n logStack('test');\n\n throw new Error(\n `Could not find package.json in current directory or any of the ${MAX_LEVELS} parent directories. Searched from: ${startDir}`\n );\n};\n"],"mappings":";;;;;;AAKA,MAAa,aAAa,OAAO,OAAO,KAAK,QAAQ;AAErD,MAAM,aAAa;AAOnB,MAAa,sBACX,WAAmB,QAAQ,KAAK,KACP;CACzB,MAAM,eAAe,MAAM,IACzB,mBACA,SACD;AAED,KAAI,aAAc,QAAO;CAEzB,IAAI,aAAa;AAEjB,MAAK,IAAI,QAAQ,GAAG,QAAQ,YAAY,SAAS;EAC/C,MAAM,kBAAkB,KAAK,YAAY,eAAe;AAExD,MAAI,WAAW,gBAAgB,EAAE;AAC/B,SAAM,IAAI,mBAAmB,UAAU;IACrC;IACA,SAAS;IACV,CAAC;AAEF,UAAO;IAAE;IAAiB,SAAS;IAAY;;EAGjD,MAAM,YAAY,QAAQ,WAAW;AAGrC,MAAI,cAAc,WAChB;AAGF,eAAa;;AAGf,UAAS,OAAO;AAEhB,OAAM,IAAI,MACR,kEAAkE,WAAW,sCAAsC,WACpH"}
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { index_d_exports } from "./defaultValues/index.js";
|
|
2
|
-
import { ANSIColors, clock, colon, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, getAppLogger, logger, spinnerFrames, v, x } from "./logger.js";
|
|
2
|
+
import { ANSIColors, Logger, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, getAppLogger, logger, removeColor, spinnerFrames, v, x } from "./logger.js";
|
|
3
|
+
import { extractErrorMessage } from "./utils/extractErrorMessage.js";
|
|
3
4
|
import { logStack } from "./utils/logStack.js";
|
|
4
|
-
export { ANSIColors, index_d_exports as DefaultValues, clock, colon, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, getAppLogger, logStack, logger, spinnerFrames, v, x };
|
|
5
|
+
export { ANSIColors, index_d_exports as DefaultValues, type Logger, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, extractErrorMessage, getAppLogger, logStack, logger, removeColor, spinnerFrames, v, x };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildConfigurationFields.d.ts","names":[],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"buildConfigurationFields.d.ts","names":[],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":[],"mappings":";;;;;;AAktBA;AACwB,cADX,wBACW,EAAA,CAAA,mBAAA,CAAA,EAAA,oBAAA,EAAA,OAAA,CAAA,EAAA,MAAA,EAAA,YAAA,CAAA,EAEP,YAFO,EAAA,GAGrB,cAHqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConfiguration.d.ts","names":[],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":[],"mappings":";;;;KAeY,uBAAA;;EAAA,QAAA,CAAA,EAEC,oBAFsB;EAEtB,GAAA,CAAA,EAAA,MAAA;EAKI,OAAA,CAAA,EAAA,MAAA;EAEL,YAAO,CAAA,EAFF,YAEE;EACV,OAAA,CAAA,EADG,MAAA,CAAO,OACV;CAAL,GAAA,IAAA,CAAK,qBAAL,EAAA,gBAAA,CAAA;AAAI,KAEI,iCAAA,GAFJ;EAEI,aAAA,EACK,cADL;EAQC,qBAAA,EAAA,MAAA,
|
|
1
|
+
{"version":3,"file":"getConfiguration.d.ts","names":[],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":[],"mappings":";;;;KAeY,uBAAA;;EAAA,QAAA,CAAA,EAEC,oBAFsB;EAEtB,GAAA,CAAA,EAAA,MAAA;EAKI,OAAA,CAAA,EAAA,MAAA;EAEL,YAAO,CAAA,EAFF,YAEE;EACV,OAAA,CAAA,EADG,MAAA,CAAO,OACV;CAAL,GAAA,IAAA,CAAK,qBAAL,EAAA,gBAAA,CAAA;AAAI,KAEI,iCAAA,GAFJ;EAEI,aAAA,EACK,cADL;EAQC,qBAAA,EAAA,MAAA,GA6EZ,SAAA;AAKD,CAAA;;;;cAlFa,wCACD,4BACT;;;;cAgFU,6BACD,4BACT"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { getAlias } from "./alias.js";
|
|
|
2
2
|
import { bundleJSFile } from "./bundleJSFile.js";
|
|
3
3
|
import { index_d_exports } from "./defaultValues/index.js";
|
|
4
4
|
import { ANSIColors, Logger, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, getAppLogger, logger, removeColor, spinnerFrames, v, x } from "./logger.js";
|
|
5
|
+
import { extractErrorMessage } from "./utils/extractErrorMessage.js";
|
|
5
6
|
import { logStack } from "./utils/logStack.js";
|
|
6
7
|
import { buildConfigurationFields } from "./configFile/buildConfigurationFields.js";
|
|
7
8
|
import { getEnvFilePath, loadEnvFile } from "./loadEnvFile.js";
|
|
@@ -13,9 +14,8 @@ import { bundleFile, bundleFileSync } from "./loadExternalFile/bundleFile.js";
|
|
|
13
14
|
import { retryManager } from "./retryManager.js";
|
|
14
15
|
import { cache, clearCache, getCache, localCache, setCache } from "./utils/cache.js";
|
|
15
16
|
import { clearModuleCache } from "./utils/clearModuleCache.js";
|
|
16
|
-
import {
|
|
17
|
-
import { extractErrorMessage } from "./utils/extractErrorMessage.js";
|
|
17
|
+
import { configESMxCJSRequire, getProjectRequire, isESModule } from "./utils/ESMxCJSHelpers.js";
|
|
18
18
|
import { getExtension } from "./utils/getExtension.js";
|
|
19
19
|
import { getPackageJsonPath } from "./utils/getPackageJsonPath.js";
|
|
20
20
|
import { normalizePath } from "./utils/normalizePath.js";
|
|
21
|
-
export { ANSIColors, index_d_exports as DefaultValues, type ESBuildPlugin,
|
|
21
|
+
export { ANSIColors, index_d_exports as DefaultValues, type ESBuildPlugin, type GetConfigurationAndFilePathResult, type GetConfigurationOptions, type Logger, buildConfigurationFields, bundleFile, bundleFileSync, bundleJSFile, cache, clearCache, clearModuleCache, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, configESMxCJSRequire, extractErrorMessage, getAlias, getAppLogger, getCache, getConfiguration, getConfigurationAndFilePath, getEnvFilePath, getExtension, getPackageJsonPath, getProjectRequire, isESModule, loadEnvFile, loadExternalFile, loadExternalFileSync, localCache, logStack, logger, normalizePath, parseFileContent, removeColor, retryManager, searchConfigurationFile, setCache, spinnerFrames, v, x };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpileTSToMJS.d.ts","names":[],"sources":["../../../src/loadExternalFile/transpileTSToMJS.ts"],"sourcesContent":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"transpileTSToMJS.d.ts","names":[],"sources":["../../../src/loadExternalFile/transpileTSToMJS.ts"],"sourcesContent":[],"mappings":";;;KAYY,aAAA,GAAgB;cA6Bf,iEAGD;AAhCA,cAqDC,gBArDe,EAAM,CAAA,IAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAwDtB,YAxDsB,EAAA,GAyD/B,OAzD+B,CAAA,MAAA,GAAA,SAAA,CAAA"}
|