@intlayer/config 8.6.4 → 8.6.6

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.
Files changed (35) hide show
  1. package/dist/cjs/bundle/index.cjs +130 -0
  2. package/dist/cjs/bundle/index.cjs.map +1 -0
  3. package/dist/cjs/bundle/logBundle.cjs +79 -0
  4. package/dist/cjs/bundle/logBundle.cjs.map +1 -0
  5. package/dist/cjs/envVars/envVars.cjs +10 -11
  6. package/dist/cjs/envVars/envVars.cjs.map +1 -1
  7. package/dist/cjs/node.cjs +0 -4
  8. package/dist/cjs/utils/index.cjs +0 -4
  9. package/dist/esm/bundle/index.mjs +126 -0
  10. package/dist/esm/bundle/index.mjs.map +1 -0
  11. package/dist/esm/bundle/logBundle.mjs +78 -0
  12. package/dist/esm/bundle/logBundle.mjs.map +1 -0
  13. package/dist/esm/envVars/envVars.mjs +10 -11
  14. package/dist/esm/envVars/envVars.mjs.map +1 -1
  15. package/dist/esm/node.mjs +1 -2
  16. package/dist/esm/utils/cacheDisk.mjs +4 -4
  17. package/dist/esm/utils/cacheDisk.mjs.map +1 -1
  18. package/dist/esm/utils/index.mjs +1 -2
  19. package/dist/types/bundle/index.d.ts +23 -0
  20. package/dist/types/bundle/index.d.ts.map +1 -0
  21. package/dist/types/bundle/logBundle.d.ts +23 -0
  22. package/dist/types/bundle/logBundle.d.ts.map +1 -0
  23. package/dist/types/configFile/configurationSchema.d.ts +2 -2
  24. package/dist/types/configFile/index.d.ts +1 -1
  25. package/dist/types/envVars/envVars.d.ts +2 -2
  26. package/dist/types/envVars/envVars.d.ts.map +1 -1
  27. package/dist/types/node.d.ts +2 -3
  28. package/dist/types/utils/index.d.ts +1 -2
  29. package/package.json +11 -3
  30. package/dist/cjs/utils/importMap.cjs +0 -73
  31. package/dist/cjs/utils/importMap.cjs.map +0 -1
  32. package/dist/esm/utils/importMap.mjs +0 -70
  33. package/dist/esm/utils/importMap.mjs.map +0 -1
  34. package/dist/types/utils/importMap.d.ts +0 -85
  35. package/dist/types/utils/importMap.d.ts.map +0 -1
package/dist/esm/node.mjs CHANGED
@@ -1,8 +1,7 @@
1
- import { getImportMap, getImportMapContent, getImportMapScript } from "./utils/importMap.mjs";
2
1
  import { buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration } from "./configFile/buildBrowserConfiguration.mjs";
3
2
  import { aiSchema, buildSchema, compilerSchema, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, storageAttributesSchema, storageSchema, systemSchema } from "./configFile/configurationSchema.mjs";
4
3
  import { buildConfigurationFields } from "./configFile/buildConfigurationFields.mjs";
5
4
  import { configurationFilesCandidates, searchConfigurationFile } from "./configFile/searchConfigurationFile.mjs";
6
5
  import { getConfiguration, getConfigurationAndFilePath } from "./configFile/getConfiguration.mjs";
7
6
 
8
- export { aiSchema, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, buildSchema, compilerSchema, configurationFilesCandidates, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, extractBrowserConfiguration, getConfiguration, getConfigurationAndFilePath, getImportMap, getImportMapContent, getImportMapScript, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, searchConfigurationFile, storageAttributesSchema, storageSchema, systemSchema };
7
+ export { aiSchema, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, buildSchema, compilerSchema, configurationFilesCandidates, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, extractBrowserConfiguration, getConfiguration, getConfigurationAndFilePath, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, searchConfigurationFile, storageAttributesSchema, storageSchema, systemSchema };
@@ -3,7 +3,7 @@ import { basename, dirname, join } from "node:path";
3
3
  import { mkdir, readFile, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
4
4
  import { deserialize, serialize } from "node:v8";
5
5
  import { gunzipSync, gzipSync } from "node:zlib";
6
- import configPackageJson from "@intlayer/types/package.json" with { type: "json" };
6
+ import packageJSON from "@intlayer/types/package.json" with { type: "json" };
7
7
 
8
8
  //#region src/utils/cacheDisk.ts
9
9
  const DEFAULTS = { compress: true };
@@ -60,7 +60,7 @@ const cacheDisk = (intlayerConfig, keys, options) => {
60
60
  const maybeObj = deserialized;
61
61
  if (!!maybeObj && typeof maybeObj === "object" && typeof maybeObj.version === "string" && typeof maybeObj.timestamp === "number" && Object.hasOwn(maybeObj, "data")) {
62
62
  const entry = maybeObj;
63
- if (entry.version !== configPackageJson.version) {
63
+ if (entry.version !== packageJSON.version) {
64
64
  try {
65
65
  await unlink(filePath);
66
66
  } catch {}
@@ -96,7 +96,7 @@ const cacheDisk = (intlayerConfig, keys, options) => {
96
96
  try {
97
97
  await ensureDir(dirname(filePath));
98
98
  const envelope = {
99
- version: configPackageJson.version,
99
+ version: packageJSON.version,
100
100
  timestamp: Date.now(),
101
101
  data: value
102
102
  };
@@ -151,7 +151,7 @@ const cacheDisk = (intlayerConfig, keys, options) => {
151
151
  const maybeObj = deserialize(flag === 1 ? gunzipSync(raw) : raw);
152
152
  if (!!maybeObj && typeof maybeObj === "object" && typeof maybeObj.version === "string" && typeof maybeObj.timestamp === "number" && Object.hasOwn(maybeObj, "data")) {
153
153
  const entry = maybeObj;
154
- if (entry.version !== configPackageJson.version) return false;
154
+ if (entry.version !== packageJSON.version) return false;
155
155
  if (typeof maxTimeMs === "number" && maxTimeMs > 0) {
156
156
  if (Date.now() - entry.timestamp > maxTimeMs) return false;
157
157
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cacheDisk.mjs","names":[],"sources":["../../../src/utils/cacheDisk.ts"],"sourcesContent":["import {\n mkdir,\n readFile,\n rename,\n rm,\n stat,\n unlink,\n writeFile,\n} from 'node:fs/promises';\nimport { basename, dirname, join } from 'node:path';\nimport { deserialize, serialize } from 'node:v8';\nimport { gunzipSync, gzipSync } from 'node:zlib';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport configPackageJson from '@intlayer/types/package.json' with {\n type: 'json',\n};\nimport { type CacheKey, clearAllCache, computeKeyId } from './cacheMemory';\n\n/** ------------------------- Persistence layer ------------------------- **/\n\n/** Cache envelope structure stored on disk */\ntype CacheEnvelope = {\n /** Version of the config package (for cache invalidation) */\n version: string;\n /** Timestamp when the cache entry was created (in milliseconds) */\n timestamp: number;\n /** Data payload (the actual cached value) */\n data: unknown;\n};\n\ntype LocalCacheOptions = {\n /** Preferred new option name */\n persistent?: boolean;\n /** Time-to-live in ms; if expired, disk entry is ignored. */\n ttlMs?: number;\n /** Max age in ms based on stored creation timestamp; invalidates on exceed. */\n maxTimeMs?: number;\n /** Optional namespace to separate different logical caches. */\n namespace?: string;\n /** Gzip values on disk (on by default for blobs > 1KB). */\n compress?: boolean;\n};\n\nconst DEFAULTS: Required<Pick<LocalCacheOptions, 'compress'>> = {\n compress: true,\n};\n\nconst ensureDir = async (dir: string) => {\n await mkdir(dir, { recursive: true });\n};\n\nconst atomicWriteFile = async (\n file: string,\n data: Buffer,\n tempDir?: string\n) => {\n if (tempDir) {\n try {\n await ensureDir(tempDir);\n } catch {}\n }\n\n const tempFileName = `${basename(file)}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n const tmp = tempDir\n ? join(tempDir, tempFileName)\n : `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n try {\n await writeFile(tmp, data);\n await rename(tmp, file);\n } catch (error) {\n try {\n await rm(tmp, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\n};\n\nconst shouldUseCompression = (buf: Buffer, force?: boolean) =>\n force === true || (force !== false && buf.byteLength > 1024);\n\n/** Derive on-disk path from config dir + namespace + key id. */\nconst cachePath = (cacheDir: string, id: string, ns?: string) =>\n join(cacheDir, ns ? join(ns, id) : id);\n\n/** ------------------------- Local cache facade ------------------------- **/\n\nconst cacheMap = new Map<string, any>();\n\n/** Clears the in-memory portion of the disk cache without touching disk files. */\nexport const clearDiskCacheMemory = (): void => {\n cacheMap.clear();\n};\n\nexport const cacheDisk = (\n intlayerConfig: IntlayerConfig,\n keys: CacheKey[],\n options?: LocalCacheOptions\n) => {\n const { cacheDir, tempDir } = intlayerConfig.system;\n const buildCacheEnabled = intlayerConfig.build.cache ?? true;\n const persistent =\n options?.persistent === true ||\n (typeof options?.persistent === 'undefined' && buildCacheEnabled);\n\n const { compress, ttlMs, maxTimeMs, namespace } = {\n ...DEFAULTS,\n ...options,\n };\n\n // single stable id for this key tuple (works for both memory & disk)\n const id = computeKeyId(keys);\n const filePath = cachePath(cacheDir, id, namespace);\n\n const readFromDisk = async (): Promise<unknown | undefined> => {\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n\n if (!statValue) return undefined;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return undefined;\n }\n let raw = await readFile(filePath);\n // header: 1 byte flag (0x00 raw, 0x01 gzip)\n const flag = raw[0];\n\n raw = raw.subarray(1);\n\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n let value: unknown;\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof (maybeObj as any).version === 'string' &&\n typeof (maybeObj as any).timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n\n if (entry.version !== configPackageJson.version) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n\n value = entry.data;\n } else {\n // Backward compatibility: old entries had raw serialized value.\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n value = deserialized;\n }\n\n // hydrate memory cache as well\n cacheMap.set(id, value);\n return value;\n } catch {\n return undefined;\n }\n };\n\n const writeToDisk = async (value: unknown) => {\n try {\n await ensureDir(dirname(filePath));\n const envelope: CacheEnvelope = {\n version: configPackageJson.version,\n timestamp: Date.now(),\n data: value,\n };\n const payload = Buffer.from(serialize(envelope));\n\n const gz = shouldUseCompression(payload, compress)\n ? gzipSync(payload)\n : payload;\n\n // prepend a 1-byte header indicating compression\n const buf = Buffer.concat([\n Buffer.from([gz === payload ? 0x00 : 0x01]),\n gz,\n ]);\n\n await atomicWriteFile(filePath, buf, tempDir);\n } catch {\n // swallow disk errors for cache writes\n }\n };\n\n return {\n /** In-memory first, then disk (if enabled), otherwise undefined. */\n get: async <T>(): Promise<T | undefined> => {\n const mem = cacheMap.get(id);\n\n if (mem !== undefined) return mem as T;\n\n if (persistent && buildCacheEnabled) {\n return (await readFromDisk()) as T | undefined;\n }\n return undefined;\n },\n /** Sets in-memory (always) and persists to disk if enabled. */\n set: async (value: unknown): Promise<void> => {\n cacheMap.set(id, value);\n\n if (persistent && buildCacheEnabled) {\n await writeToDisk(value);\n }\n },\n /** Clears only this entry from memory and disk. */\n clear: async (): Promise<void> => {\n cacheMap.delete(id);\n\n try {\n await unlink(filePath);\n } catch {}\n },\n /** Clears ALL cached entries (memory Map and entire cacheDir namespace if persistent). */\n clearAll: async (): Promise<void> => {\n clearAllCache();\n if (persistent && buildCacheEnabled) {\n // remove only the current namespace (if provided), else the root dir\n const base = namespace ? join(cacheDir, namespace) : cacheDir;\n\n try {\n await rm(base, { recursive: true, force: true });\n } catch {}\n\n try {\n await mkdir(base, { recursive: true });\n } catch {}\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n isValid: async (): Promise<boolean> => {\n const cachedValue = cacheMap.get(id);\n if (cachedValue !== undefined) return true;\n\n // If persistence is disabled or build cache disabled, only memory can be valid\n if (!persistent || !buildCacheEnabled) return false;\n\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n if (!statValue) return false;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return false;\n }\n\n let raw = await readFile(filePath);\n const flag = raw[0];\n raw = raw.subarray(1);\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof maybeObj.version === 'string' &&\n typeof maybeObj.timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n if (entry.version !== configPackageJson.version) return false;\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) return false;\n }\n return true;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) return false;\n }\n return true;\n } catch {\n return false;\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n id,\n /** Expose the absolute file path for debugging. */\n filePath,\n };\n};\n"],"mappings":";;;;;;;;AA2CA,MAAM,WAA0D,EAC9D,UAAU,MACX;AAED,MAAM,YAAY,OAAO,QAAgB;AACvC,OAAM,MAAM,KAAK,EAAE,WAAW,MAAM,CAAC;;AAGvC,MAAM,kBAAkB,OACtB,MACA,MACA,YACG;AACH,KAAI,QACF,KAAI;AACF,QAAM,UAAU,QAAQ;SAClB;CAGV,MAAM,eAAe,GAAG,SAAS,KAAK,CAAC,OAAO,QAAQ,IAA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;SADY,KAAK,KAAK,GAAG,UAAU,UACzB,UAAW,QAAO;;AAE9B,WAAO;WACD;AACN,WAAO;;;EAIX;EAEA;EACD"}
1
+ {"version":3,"file":"cacheDisk.mjs","names":["configPackageJson"],"sources":["../../../src/utils/cacheDisk.ts"],"sourcesContent":["import {\n mkdir,\n readFile,\n rename,\n rm,\n stat,\n unlink,\n writeFile,\n} from 'node:fs/promises';\nimport { basename, dirname, join } from 'node:path';\nimport { deserialize, serialize } from 'node:v8';\nimport { gunzipSync, gzipSync } from 'node:zlib';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport configPackageJson from '@intlayer/types/package.json' with {\n type: 'json',\n};\nimport { type CacheKey, clearAllCache, computeKeyId } from './cacheMemory';\n\n/** ------------------------- Persistence layer ------------------------- **/\n\n/** Cache envelope structure stored on disk */\ntype CacheEnvelope = {\n /** Version of the config package (for cache invalidation) */\n version: string;\n /** Timestamp when the cache entry was created (in milliseconds) */\n timestamp: number;\n /** Data payload (the actual cached value) */\n data: unknown;\n};\n\ntype LocalCacheOptions = {\n /** Preferred new option name */\n persistent?: boolean;\n /** Time-to-live in ms; if expired, disk entry is ignored. */\n ttlMs?: number;\n /** Max age in ms based on stored creation timestamp; invalidates on exceed. */\n maxTimeMs?: number;\n /** Optional namespace to separate different logical caches. */\n namespace?: string;\n /** Gzip values on disk (on by default for blobs > 1KB). */\n compress?: boolean;\n};\n\nconst DEFAULTS: Required<Pick<LocalCacheOptions, 'compress'>> = {\n compress: true,\n};\n\nconst ensureDir = async (dir: string) => {\n await mkdir(dir, { recursive: true });\n};\n\nconst atomicWriteFile = async (\n file: string,\n data: Buffer,\n tempDir?: string\n) => {\n if (tempDir) {\n try {\n await ensureDir(tempDir);\n } catch {}\n }\n\n const tempFileName = `${basename(file)}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n const tmp = tempDir\n ? join(tempDir, tempFileName)\n : `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n try {\n await writeFile(tmp, data);\n await rename(tmp, file);\n } catch (error) {\n try {\n await rm(tmp, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\n};\n\nconst shouldUseCompression = (buf: Buffer, force?: boolean) =>\n force === true || (force !== false && buf.byteLength > 1024);\n\n/** Derive on-disk path from config dir + namespace + key id. */\nconst cachePath = (cacheDir: string, id: string, ns?: string) =>\n join(cacheDir, ns ? join(ns, id) : id);\n\n/** ------------------------- Local cache facade ------------------------- **/\n\nconst cacheMap = new Map<string, any>();\n\n/** Clears the in-memory portion of the disk cache without touching disk files. */\nexport const clearDiskCacheMemory = (): void => {\n cacheMap.clear();\n};\n\nexport const cacheDisk = (\n intlayerConfig: IntlayerConfig,\n keys: CacheKey[],\n options?: LocalCacheOptions\n) => {\n const { cacheDir, tempDir } = intlayerConfig.system;\n const buildCacheEnabled = intlayerConfig.build.cache ?? true;\n const persistent =\n options?.persistent === true ||\n (typeof options?.persistent === 'undefined' && buildCacheEnabled);\n\n const { compress, ttlMs, maxTimeMs, namespace } = {\n ...DEFAULTS,\n ...options,\n };\n\n // single stable id for this key tuple (works for both memory & disk)\n const id = computeKeyId(keys);\n const filePath = cachePath(cacheDir, id, namespace);\n\n const readFromDisk = async (): Promise<unknown | undefined> => {\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n\n if (!statValue) return undefined;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return undefined;\n }\n let raw = await readFile(filePath);\n // header: 1 byte flag (0x00 raw, 0x01 gzip)\n const flag = raw[0];\n\n raw = raw.subarray(1);\n\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n let value: unknown;\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof (maybeObj as any).version === 'string' &&\n typeof (maybeObj as any).timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n\n if (entry.version !== configPackageJson.version) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n\n value = entry.data;\n } else {\n // Backward compatibility: old entries had raw serialized value.\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n value = deserialized;\n }\n\n // hydrate memory cache as well\n cacheMap.set(id, value);\n return value;\n } catch {\n return undefined;\n }\n };\n\n const writeToDisk = async (value: unknown) => {\n try {\n await ensureDir(dirname(filePath));\n const envelope: CacheEnvelope = {\n version: configPackageJson.version,\n timestamp: Date.now(),\n data: value,\n };\n const payload = Buffer.from(serialize(envelope));\n\n const gz = shouldUseCompression(payload, compress)\n ? gzipSync(payload)\n : payload;\n\n // prepend a 1-byte header indicating compression\n const buf = Buffer.concat([\n Buffer.from([gz === payload ? 0x00 : 0x01]),\n gz,\n ]);\n\n await atomicWriteFile(filePath, buf, tempDir);\n } catch {\n // swallow disk errors for cache writes\n }\n };\n\n return {\n /** In-memory first, then disk (if enabled), otherwise undefined. */\n get: async <T>(): Promise<T | undefined> => {\n const mem = cacheMap.get(id);\n\n if (mem !== undefined) return mem as T;\n\n if (persistent && buildCacheEnabled) {\n return (await readFromDisk()) as T | undefined;\n }\n return undefined;\n },\n /** Sets in-memory (always) and persists to disk if enabled. */\n set: async (value: unknown): Promise<void> => {\n cacheMap.set(id, value);\n\n if (persistent && buildCacheEnabled) {\n await writeToDisk(value);\n }\n },\n /** Clears only this entry from memory and disk. */\n clear: async (): Promise<void> => {\n cacheMap.delete(id);\n\n try {\n await unlink(filePath);\n } catch {}\n },\n /** Clears ALL cached entries (memory Map and entire cacheDir namespace if persistent). */\n clearAll: async (): Promise<void> => {\n clearAllCache();\n if (persistent && buildCacheEnabled) {\n // remove only the current namespace (if provided), else the root dir\n const base = namespace ? join(cacheDir, namespace) : cacheDir;\n\n try {\n await rm(base, { recursive: true, force: true });\n } catch {}\n\n try {\n await mkdir(base, { recursive: true });\n } catch {}\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n isValid: async (): Promise<boolean> => {\n const cachedValue = cacheMap.get(id);\n if (cachedValue !== undefined) return true;\n\n // If persistence is disabled or build cache disabled, only memory can be valid\n if (!persistent || !buildCacheEnabled) return false;\n\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n if (!statValue) return false;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return false;\n }\n\n let raw = await readFile(filePath);\n const flag = raw[0];\n raw = raw.subarray(1);\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof maybeObj.version === 'string' &&\n typeof maybeObj.timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n if (entry.version !== configPackageJson.version) return false;\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) return false;\n }\n return true;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) return false;\n }\n return true;\n } catch {\n return false;\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n id,\n /** Expose the absolute file path for debugging. */\n filePath,\n };\n};\n"],"mappings":";;;;;;;;AA2CA,MAAM,WAA0D,EAC9D,UAAU,MACX;AAED,MAAM,YAAY,OAAO,QAAgB;AACvC,OAAM,MAAM,KA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MAAM,YAAYA,YAAkB,QAAS,QAAO;AAExD,SAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;UADY,KAAK,KAAK,GAAG,MAAM,YACrB,UAAW,QAAO;;AAE9B,YAAO;;AAGT,QAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;SADY,KAAK,KAAK,GAAG,UAAU,UACzB,UAAW,QAAO;;AAE9B,WAAO;WACD;AACN,WAAO;;;EAIX;EAEA;EACD"}
@@ -9,7 +9,6 @@ import { clearModuleCache } from "./clearModuleCache.mjs";
9
9
  import { compareVersions } from "./compareVersions.mjs";
10
10
  import { extractErrorMessage } from "./extractErrorMessage.mjs";
11
11
  import { getStorageAttributes } from "./getStorageAttributes.mjs";
12
- import { getImportMap, getImportMapContent, getImportMapScript } from "./importMap.mjs";
13
12
  import { getUnusedNodeTypes, getUnusedNodeTypesAsync, getUsedNodeTypes, getUsedNodeTypesAsync } from "./getUsedNodeTypes.mjs";
14
13
  import { logStack } from "./logStack.mjs";
15
14
  import { parseFilePathPattern, parseStringPattern } from "./parseFilePathPattern.mjs";
@@ -20,4 +19,4 @@ import { camelCaseToSentence } from "./stringFormatter/camelCaseToSentence.mjs";
20
19
  import { kebabCaseToCamelCase } from "./stringFormatter/kebabCaseToCamelCase.mjs";
21
20
  import { toLowerCamelCase } from "./stringFormatter/toLowerCamelCase.mjs";
22
21
 
23
- export { cacheDisk, cacheMemory, camelCaseToKebabCase, camelCaseToSentence, clearAllCache, clearCache, clearDiskCacheMemory, clearModuleCache, compareVersions, computeKeyId, configESMxCJSRequire, extractErrorMessage, getAlias, getCache, getExtension, getImportMap, getImportMapContent, getImportMapScript, getPackageJsonPath, getProjectRequire, getStorageAttributes, getUnusedNodeTypes, getUnusedNodeTypesAsync, getUsedNodeTypes, getUsedNodeTypesAsync, isESModule, kebabCaseToCamelCase, logStack, normalizePath, parseFilePathPattern, parseStringPattern, retryManager, setCache, setIntlayerIdentifier, stableStringify, toLowerCamelCase };
22
+ export { cacheDisk, cacheMemory, camelCaseToKebabCase, camelCaseToSentence, clearAllCache, clearCache, clearDiskCacheMemory, clearModuleCache, compareVersions, computeKeyId, configESMxCJSRequire, extractErrorMessage, getAlias, getCache, getExtension, getPackageJsonPath, getProjectRequire, getStorageAttributes, getUnusedNodeTypes, getUnusedNodeTypesAsync, getUsedNodeTypes, getUsedNodeTypesAsync, isESModule, kebabCaseToCamelCase, logStack, normalizePath, parseFilePathPattern, parseStringPattern, retryManager, setCache, setIntlayerIdentifier, stableStringify, toLowerCamelCase };
@@ -0,0 +1,23 @@
1
+ import { GetConfigurationOptions } from "../configFile/getConfiguration.js";
2
+ import * as _$esbuild from "esbuild";
3
+ import { BuildOptions } from "esbuild";
4
+
5
+ //#region src/bundle/index.d.ts
6
+ declare const packageList: readonly ["next-intlayer", "react-intlayer", "vue-intlayer", "svelte-intlayer", "preact-intlayer", "solid-intlayer", "angular-intlayer", "lit-intlayer", "express-intlayer", "hono-intlayer", "fastify-intlayer", "adonis-intlayer", "vanilla-intlayer", "intlayer"];
7
+ type BundleIntlayerOptions = {
8
+ outfile?: string;
9
+ configOptions?: GetConfigurationOptions;
10
+ bundlePackages?: string[];
11
+ version?: string;
12
+ } & BuildOptions;
13
+ /**
14
+ * Bundle the application content using esbuild.
15
+ * It uses the Intlayer configuration to set up aliases and other esbuild options.
16
+ *
17
+ * @param options - Bundle options including entryPoint, outfile, and esbuild options.
18
+ * @returns The build result.
19
+ */
20
+ declare const bundleIntlayer: (options: BundleIntlayerOptions) => Promise<_$esbuild.BuildResult<BuildOptions>>;
21
+ //#endregion
22
+ export { BundleIntlayerOptions, bundleIntlayer, packageList };
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/bundle/index.ts"],"mappings":";;;;;cAgBa,WAAA;AAAA,KAmBD,qBAAA;EACV,OAAA;EACA,aAAA,GAAgB,uBAAA;EAChB,cAAA;EACA,OAAA;AAAA,IACE,YAAA;;AALJ;;;;;;cAca,cAAA,GAAwB,OAAA,EAAS,qBAAA,KAAqB,OAAA,CAAA,SAAA,CAAA,WAAA,CAAA,YAAA"}
@@ -0,0 +1,23 @@
1
+ import { IntlayerConfig } from "@intlayer/types/config";
2
+
3
+ //#region src/bundle/logBundle.d.ts
4
+ declare class BundleLogger {
5
+ private status;
6
+ private spinnerTimer;
7
+ private spinnerIndex;
8
+ private renderedLines;
9
+ private isFinished;
10
+ private readonly prefix;
11
+ private lastRenderedState;
12
+ private error;
13
+ constructor(configuration?: IntlayerConfig);
14
+ setStatus(status: 'installing' | 'bundling' | 'success'): void;
15
+ setError(error?: unknown): void;
16
+ private startSpinner;
17
+ private stopSpinner;
18
+ private finish;
19
+ private render;
20
+ }
21
+ //#endregion
22
+ export { BundleLogger };
23
+ //# sourceMappingURL=logBundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logBundle.d.ts","names":[],"sources":["../../../src/bundle/logBundle.ts"],"mappings":";;;cAKa,YAAA;EAAA,QACH,MAAA;EAAA,QAEA,YAAA;EAAA,QACA,YAAA;EAAA,QACA,aAAA;EAAA,QACA,UAAA;EAAA,iBACS,MAAA;EAAA,QACT,iBAAA;EAAA,QACA,KAAA;cAEI,aAAA,GAAgB,cAAA;EAI5B,SAAA,CAAU,MAAA;EAWV,QAAA,CAAS,KAAA;EAAA,QAOD,YAAA;EAAA,QAQA,WAAA;EAAA,QAMA,MAAA;EAAA,QAMA,MAAA;AAAA"}
@@ -271,8 +271,8 @@ declare const buildSchema: z.ZodObject<{
271
271
  }>>;
272
272
  traversePattern: z.ZodOptional<z.ZodArray<z.ZodString>>;
273
273
  outputFormat: z.ZodOptional<z.ZodArray<z.ZodEnum<{
274
- esm: "esm";
275
274
  cjs: "cjs";
275
+ esm: "esm";
276
276
  }>>>;
277
277
  cache: z.ZodOptional<z.ZodBoolean>;
278
278
  require: z.ZodOptional<z.ZodUnknown>;
@@ -465,8 +465,8 @@ declare const intlayerConfigSchema: z.ZodObject<{
465
465
  }>>;
466
466
  traversePattern: z.ZodOptional<z.ZodArray<z.ZodString>>;
467
467
  outputFormat: z.ZodOptional<z.ZodArray<z.ZodEnum<{
468
- esm: "esm";
469
468
  cjs: "cjs";
469
+ esm: "esm";
470
470
  }>>>;
471
471
  cache: z.ZodOptional<z.ZodBoolean>;
472
472
  require: z.ZodOptional<z.ZodUnknown>;
@@ -1,6 +1,6 @@
1
+ import { GetConfigurationAndFilePathResult, GetConfigurationOptions, getConfiguration, getConfigurationAndFilePath } from "./getConfiguration.js";
1
2
  import { BrowserIntlayerConfig, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration } from "./buildBrowserConfiguration.js";
2
3
  import { buildConfigurationFields } from "./buildConfigurationFields.js";
3
4
  import { aiSchema, buildSchema, compilerSchema, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, storageAttributesSchema, storageSchema, systemSchema } from "./configurationSchema.js";
4
- import { GetConfigurationAndFilePathResult, GetConfigurationOptions, getConfiguration, getConfigurationAndFilePath } from "./getConfiguration.js";
5
5
  import { configurationFilesCandidates, searchConfigurationFile } from "./searchConfigurationFile.js";
6
6
  export { BrowserIntlayerConfig, GetConfigurationAndFilePathResult, GetConfigurationOptions, aiSchema, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, buildSchema, compilerSchema, configurationFilesCandidates, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, extractBrowserConfiguration, getConfiguration, getConfigurationAndFilePath, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, searchConfigurationFile, storageAttributesSchema, storageSchema, systemSchema };
@@ -12,7 +12,7 @@ import { IntlayerConfig } from "@intlayer/types/config";
12
12
  * formatNodeTypeToEnvVar(['enumeration'], true)
13
13
  * // { 'process.env.INTLAYER_NODE_TYPE_ENUMERATION': '"false"' }
14
14
  */
15
- declare const formatNodeTypeToEnvVar: (nodeTypes: string[], addProcessEnv?: boolean) => Record<string, string>;
15
+ declare const formatNodeTypeToEnvVar: (nodeTypes: string[], wrapKey?: (key: string) => string, wrapValue?: (value: string) => string) => Record<string, string>;
16
16
  /**
17
17
  * Returns env-var definitions for the full Intlayer config to be injected at
18
18
  * build time. Allows bundlers to dead-code-eliminate unused routing modes,
@@ -25,7 +25,7 @@ declare const formatNodeTypeToEnvVar: (nodeTypes: string[], addProcessEnv?: bool
25
25
  * getConfigEnvVars(config, true)
26
26
  * // { 'process.env.INTLAYER_ROUTING_MODE': '"prefix-no-default"', ... }
27
27
  */
28
- declare const getConfigEnvVars: (config: IntlayerConfig, addProcessEnv?: boolean, wrapValue?: (value: string) => string) => Record<string, string>;
28
+ declare const getConfigEnvVars: (config: IntlayerConfig, wrapKey?: (key: string) => string, wrapValue?: (value: string) => string) => Record<string, string>;
29
29
  //#endregion
30
30
  export { formatNodeTypeToEnvVar, getConfigEnvVars };
31
31
  //# sourceMappingURL=envVars.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"envVars.d.ts","names":[],"sources":["../../../src/envVars/envVars.ts"],"mappings":";;;;;AAaA;;;;;;;;;cAAa,sBAAA,GACX,SAAA,YACA,aAAA,eACC,MAAA;;;;;;;;;;;;;cAyBU,gBAAA,GACX,MAAA,EAAQ,cAAA,EACR,aAAA,YACA,SAAA,IAAY,KAAA,wBACX,MAAA"}
1
+ {"version":3,"file":"envVars.d.ts","names":[],"sources":["../../../src/envVars/envVars.ts"],"mappings":";;;;;AAaA;;;;;;;;;cAAa,sBAAA,GACX,SAAA,YACA,OAAA,IAAW,GAAA,qBACX,SAAA,IAAa,KAAA,wBACZ,MAAA;;;AAsBH;;;;;;;;;;cAAa,gBAAA,GACX,MAAA,EAAQ,cAAA,EACR,OAAA,IAAW,GAAA,qBACX,SAAA,IAAa,KAAA,wBACZ,MAAA"}
@@ -1,7 +1,6 @@
1
+ import { GetConfigurationAndFilePathResult, GetConfigurationOptions, getConfiguration, getConfigurationAndFilePath } from "./configFile/getConfiguration.js";
1
2
  import { BrowserIntlayerConfig, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration } from "./configFile/buildBrowserConfiguration.js";
2
3
  import { buildConfigurationFields } from "./configFile/buildConfigurationFields.js";
3
4
  import { aiSchema, buildSchema, compilerSchema, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, storageAttributesSchema, storageSchema, systemSchema } from "./configFile/configurationSchema.js";
4
- import { GetConfigurationAndFilePathResult, GetConfigurationOptions, getConfiguration, getConfigurationAndFilePath } from "./configFile/getConfiguration.js";
5
5
  import { configurationFilesCandidates, searchConfigurationFile } from "./configFile/searchConfigurationFile.js";
6
- import { GetImportMapOptions, ImportMap, getImportMap, getImportMapContent, getImportMapScript } from "./utils/importMap.js";
7
- export { BrowserIntlayerConfig, GetConfigurationAndFilePathResult, GetConfigurationOptions, GetImportMapOptions, ImportMap, aiSchema, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, buildSchema, compilerSchema, configurationFilesCandidates, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, extractBrowserConfiguration, getConfiguration, getConfigurationAndFilePath, getImportMap, getImportMapContent, getImportMapScript, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, searchConfigurationFile, storageAttributesSchema, storageSchema, systemSchema };
6
+ export { BrowserIntlayerConfig, GetConfigurationAndFilePathResult, GetConfigurationOptions, aiSchema, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, buildSchema, compilerSchema, configurationFilesCandidates, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, extractBrowserConfiguration, getConfiguration, getConfigurationAndFilePath, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, searchConfigurationFile, storageAttributesSchema, storageSchema, systemSchema };
@@ -6,7 +6,6 @@ import { camelCaseToKebabCase } from "./stringFormatter/camelCaseToKebabCase.js"
6
6
  import { camelCaseToSentence } from "./stringFormatter/camelCaseToSentence.js";
7
7
  import { kebabCaseToCamelCase } from "./stringFormatter/kebabCaseToCamelCase.js";
8
8
  import { toLowerCamelCase } from "./stringFormatter/toLowerCamelCase.js";
9
- import { GetImportMapOptions, ImportMap, getImportMap, getImportMapContent, getImportMapScript } from "./importMap.js";
10
9
  import { configESMxCJSRequire, getProjectRequire, isESModule } from "./ESMxCJSHelpers.js";
11
10
  import { GetAliasOptions, getAlias } from "./alias.js";
12
11
  import { CacheKey, cacheMemory, clearAllCache, clearCache, computeKeyId, getCache, setCache, stableStringify } from "./cacheMemory.js";
@@ -19,4 +18,4 @@ import { getStorageAttributes } from "./getStorageAttributes.js";
19
18
  import { PluginNodeType, getUnusedNodeTypes, getUnusedNodeTypesAsync, getUsedNodeTypes, getUsedNodeTypesAsync } from "./getUsedNodeTypes.js";
20
19
  import { parseFilePathPattern, parseStringPattern } from "./parseFilePathPattern.js";
21
20
  import { RetryManagerOptions, retryManager } from "./retryManager.js";
22
- export { CacheKey, GetAliasOptions, GetImportMapOptions, ImportMap, PluginNodeType, RetryManagerOptions, WindowsWithIntlayer, cacheDisk, cacheMemory, camelCaseToKebabCase, camelCaseToSentence, clearAllCache, clearCache, clearDiskCacheMemory, clearModuleCache, compareVersions, computeKeyId, configESMxCJSRequire, extractErrorMessage, getAlias, getCache, getExtension, getImportMap, getImportMapContent, getImportMapScript, getPackageJsonPath, getProjectRequire, getStorageAttributes, getUnusedNodeTypes, getUnusedNodeTypesAsync, getUsedNodeTypes, getUsedNodeTypesAsync, isESModule, kebabCaseToCamelCase, logStack, normalizePath, parseFilePathPattern, parseStringPattern, retryManager, setCache, setIntlayerIdentifier, stableStringify, toLowerCamelCase };
21
+ export { CacheKey, GetAliasOptions, PluginNodeType, RetryManagerOptions, WindowsWithIntlayer, cacheDisk, cacheMemory, camelCaseToKebabCase, camelCaseToSentence, clearAllCache, clearCache, clearDiskCacheMemory, clearModuleCache, compareVersions, computeKeyId, configESMxCJSRequire, extractErrorMessage, getAlias, getCache, getExtension, getPackageJsonPath, getProjectRequire, getStorageAttributes, getUnusedNodeTypes, getUnusedNodeTypesAsync, getUsedNodeTypes, getUsedNodeTypesAsync, isESModule, kebabCaseToCamelCase, logStack, normalizePath, parseFilePathPattern, parseStringPattern, retryManager, setCache, setIntlayerIdentifier, stableStringify, toLowerCamelCase };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/config",
3
- "version": "8.6.4",
3
+ "version": "8.6.6",
4
4
  "private": false,
5
5
  "description": "Retrieve Intlayer configurations and manage environment variables for both server-side and client-side environments.",
6
6
  "keywords": [
@@ -88,6 +88,11 @@
88
88
  "require": "./dist/cjs/defaultValues/index.cjs",
89
89
  "import": "./dist/esm/defaultValues/index.mjs"
90
90
  },
91
+ "./bundle": {
92
+ "types": "./dist/types/bundle/index.d.ts",
93
+ "require": "./dist/cjs/bundle/index.cjs",
94
+ "import": "./dist/esm/bundle/index.mjs"
95
+ },
91
96
  "./package.json": "./package.json"
92
97
  },
93
98
  "main": "dist/cjs/index.cjs",
@@ -125,6 +130,9 @@
125
130
  "defaultValues": [
126
131
  "./dist/types/defaultValues/index.d.ts"
127
132
  ],
133
+ "bundle": [
134
+ "./dist/types/bundle/index.d.ts"
135
+ ],
128
136
  "package.json": [
129
137
  "./package.json"
130
138
  ]
@@ -152,8 +160,8 @@
152
160
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
153
161
  },
154
162
  "dependencies": {
155
- "@intlayer/types": "8.6.4",
156
- "defu": "6.1.4",
163
+ "@intlayer/types": "8.6.6",
164
+ "defu": "6.1.6",
157
165
  "dotenv": "17.3.1",
158
166
  "esbuild": "0.27.4",
159
167
  "json5": "2.2.3",
@@ -1,73 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_utils_alias = require('./alias.cjs');
3
-
4
- //#region src/utils/importMap.ts
5
- /**
6
- * Generates a browser-native import map object from the Intlayer configuration.
7
- *
8
- * The import map resolves bare module specifiers (e.g. `@intlayer/dictionaries-entry`)
9
- * to their physical `.mjs` file paths relative to the project root, replicating
10
- * what a bundler's `alias` plugin would do.
11
- *
12
- * Paths are always forced to ESM (`.mjs`) and prefixed with `./` so they are
13
- * valid relative URL references for the browser.
14
- *
15
- * @example
16
- * ```json
17
- * {
18
- * "imports": {
19
- * "@intlayer/dictionaries-entry": "./.intlayer/main/dictionaries.mjs",
20
- * "@intlayer/unmerged-dictionaries-entry": "./.intlayer/main/unmerged_dictionaries.mjs",
21
- * "@intlayer/remote-dictionaries-entry": "./.intlayer/main/remote_dictionaries.mjs",
22
- * "@intlayer/dynamic-dictionaries-entry": "./.intlayer/main/dynamic_dictionaries.mjs",
23
- * "@intlayer/fetch-dictionaries-entry": "./.intlayer/main/fetch_dictionaries.mjs",
24
- * "@intlayer/config/built": "./.intlayer/config/configuration.mjs"
25
- * }
26
- * }
27
- * ```
28
- */
29
- const getImportMap = ({ configuration, extraImports = {} }) => {
30
- return { imports: {
31
- ...require_utils_alias.getAlias({
32
- configuration,
33
- format: "esm",
34
- formatter: (value) => `./${value}`
35
- }),
36
- ...extraImports
37
- } };
38
- };
39
- /**
40
- * Returns the JSON string representation of the import map.
41
- *
42
- * Can be embedded directly as the content of a `<script type="importmap">` tag,
43
- * or written to a standalone `.importmap` file and referenced via
44
- * `<script type="importmap" src="./importmap.json">`.
45
- */
46
- const getImportMapContent = (options) => JSON.stringify(getImportMap(options), null, 2);
47
- /**
48
- * Generates a complete `<script type="importmap">` HTML element string.
49
- *
50
- * Inject this into your HTML `<head>` **before** any `<script type="module">`
51
- * tags to enable bare module specifier resolution without a bundler.
52
- *
53
- * Prerequisites:
54
- * - Run `npx intlayer build` so the `.intlayer` folder is populated.
55
- * - Your static server must serve the `.intlayer` directory.
56
- *
57
- * @example
58
- * ```html
59
- * <!DOCTYPE html>
60
- * <html lang="en">
61
- * <head>
62
- * <!-- generated output goes here, before any module scripts -->
63
- * <script type="module" src="./src/main.js"><\/script>
64
- * </head>
65
- * ```
66
- */
67
- const getImportMapScript = (options) => `<script type="importmap">\n${getImportMapContent(options)}\n<\/script>`;
68
-
69
- //#endregion
70
- exports.getImportMap = getImportMap;
71
- exports.getImportMapContent = getImportMapContent;
72
- exports.getImportMapScript = getImportMapScript;
73
- //# sourceMappingURL=importMap.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"importMap.cjs","names":["getAlias"],"sources":["../../../src/utils/importMap.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\nimport { getAlias } from './alias';\n\nexport type GetImportMapOptions = {\n configuration: IntlayerConfig;\n /**\n * Extra module specifier → URL mappings to merge into the import map.\n * Use this to add paths for top-level packages (e.g. `intlayer`, `vanilla-intlayer`)\n * that are not generated by Intlayer's build step.\n *\n * @example\n * ```ts\n * {\n * extraImports: {\n * 'intlayer': './node_modules/intlayer/dist/index.mjs',\n * 'vanilla-intlayer': './node_modules/vanilla-intlayer/dist/index.mjs',\n * }\n * }\n * ```\n */\n extraImports?: Record<string, string>;\n};\n\nexport type ImportMap = {\n imports: Record<string, string>;\n};\n\n/**\n * Generates a browser-native import map object from the Intlayer configuration.\n *\n * The import map resolves bare module specifiers (e.g. `@intlayer/dictionaries-entry`)\n * to their physical `.mjs` file paths relative to the project root, replicating\n * what a bundler's `alias` plugin would do.\n *\n * Paths are always forced to ESM (`.mjs`) and prefixed with `./` so they are\n * valid relative URL references for the browser.\n *\n * @example\n * ```json\n * {\n * \"imports\": {\n * \"@intlayer/dictionaries-entry\": \"./.intlayer/main/dictionaries.mjs\",\n * \"@intlayer/unmerged-dictionaries-entry\": \"./.intlayer/main/unmerged_dictionaries.mjs\",\n * \"@intlayer/remote-dictionaries-entry\": \"./.intlayer/main/remote_dictionaries.mjs\",\n * \"@intlayer/dynamic-dictionaries-entry\": \"./.intlayer/main/dynamic_dictionaries.mjs\",\n * \"@intlayer/fetch-dictionaries-entry\": \"./.intlayer/main/fetch_dictionaries.mjs\",\n * \"@intlayer/config/built\": \"./.intlayer/config/configuration.mjs\"\n * }\n * }\n * ```\n */\nexport const getImportMap = ({\n configuration,\n extraImports = {},\n}: GetImportMapOptions): ImportMap => {\n const aliases = getAlias({\n configuration,\n format: 'esm',\n formatter: (value) => `./${value}`,\n });\n\n return {\n imports: {\n ...aliases,\n ...extraImports,\n },\n };\n};\n\n/**\n * Returns the JSON string representation of the import map.\n *\n * Can be embedded directly as the content of a `<script type=\"importmap\">` tag,\n * or written to a standalone `.importmap` file and referenced via\n * `<script type=\"importmap\" src=\"./importmap.json\">`.\n */\nexport const getImportMapContent = (options: GetImportMapOptions): string =>\n JSON.stringify(getImportMap(options), null, 2);\n\n/**\n * Generates a complete `<script type=\"importmap\">` HTML element string.\n *\n * Inject this into your HTML `<head>` **before** any `<script type=\"module\">`\n * tags to enable bare module specifier resolution without a bundler.\n *\n * Prerequisites:\n * - Run `npx intlayer build` so the `.intlayer` folder is populated.\n * - Your static server must serve the `.intlayer` directory.\n *\n * @example\n * ```html\n * <!DOCTYPE html>\n * <html lang=\"en\">\n * <head>\n * <!-- generated output goes here, before any module scripts -->\n * <script type=\"module\" src=\"./src/main.js\"></script>\n * </head>\n * ```\n */\nexport const getImportMapScript = (options: GetImportMapOptions): string =>\n `<script type=\"importmap\">\\n${getImportMapContent(options)}\\n</script>`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAa,gBAAgB,EAC3B,eACA,eAAe,EAAE,OACmB;AAOpC,QAAO,EACL,SAAS;EACP,GARYA,6BAAS;GACvB;GACA,QAAQ;GACR,YAAY,UAAU,KAAK;GAC5B,CAAC;EAKE,GAAG;EACJ,EACF;;;;;;;;;AAUH,MAAa,uBAAuB,YAClC,KAAK,UAAU,aAAa,QAAQ,EAAE,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;AAsBhD,MAAa,sBAAsB,YACjC,8BAA8B,oBAAoB,QAAQ,CAAC"}
@@ -1,70 +0,0 @@
1
- import { getAlias } from "./alias.mjs";
2
-
3
- //#region src/utils/importMap.ts
4
- /**
5
- * Generates a browser-native import map object from the Intlayer configuration.
6
- *
7
- * The import map resolves bare module specifiers (e.g. `@intlayer/dictionaries-entry`)
8
- * to their physical `.mjs` file paths relative to the project root, replicating
9
- * what a bundler's `alias` plugin would do.
10
- *
11
- * Paths are always forced to ESM (`.mjs`) and prefixed with `./` so they are
12
- * valid relative URL references for the browser.
13
- *
14
- * @example
15
- * ```json
16
- * {
17
- * "imports": {
18
- * "@intlayer/dictionaries-entry": "./.intlayer/main/dictionaries.mjs",
19
- * "@intlayer/unmerged-dictionaries-entry": "./.intlayer/main/unmerged_dictionaries.mjs",
20
- * "@intlayer/remote-dictionaries-entry": "./.intlayer/main/remote_dictionaries.mjs",
21
- * "@intlayer/dynamic-dictionaries-entry": "./.intlayer/main/dynamic_dictionaries.mjs",
22
- * "@intlayer/fetch-dictionaries-entry": "./.intlayer/main/fetch_dictionaries.mjs",
23
- * "@intlayer/config/built": "./.intlayer/config/configuration.mjs"
24
- * }
25
- * }
26
- * ```
27
- */
28
- const getImportMap = ({ configuration, extraImports = {} }) => {
29
- return { imports: {
30
- ...getAlias({
31
- configuration,
32
- format: "esm",
33
- formatter: (value) => `./${value}`
34
- }),
35
- ...extraImports
36
- } };
37
- };
38
- /**
39
- * Returns the JSON string representation of the import map.
40
- *
41
- * Can be embedded directly as the content of a `<script type="importmap">` tag,
42
- * or written to a standalone `.importmap` file and referenced via
43
- * `<script type="importmap" src="./importmap.json">`.
44
- */
45
- const getImportMapContent = (options) => JSON.stringify(getImportMap(options), null, 2);
46
- /**
47
- * Generates a complete `<script type="importmap">` HTML element string.
48
- *
49
- * Inject this into your HTML `<head>` **before** any `<script type="module">`
50
- * tags to enable bare module specifier resolution without a bundler.
51
- *
52
- * Prerequisites:
53
- * - Run `npx intlayer build` so the `.intlayer` folder is populated.
54
- * - Your static server must serve the `.intlayer` directory.
55
- *
56
- * @example
57
- * ```html
58
- * <!DOCTYPE html>
59
- * <html lang="en">
60
- * <head>
61
- * <!-- generated output goes here, before any module scripts -->
62
- * <script type="module" src="./src/main.js"><\/script>
63
- * </head>
64
- * ```
65
- */
66
- const getImportMapScript = (options) => `<script type="importmap">\n${getImportMapContent(options)}\n<\/script>`;
67
-
68
- //#endregion
69
- export { getImportMap, getImportMapContent, getImportMapScript };
70
- //# sourceMappingURL=importMap.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"importMap.mjs","names":[],"sources":["../../../src/utils/importMap.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\nimport { getAlias } from './alias';\n\nexport type GetImportMapOptions = {\n configuration: IntlayerConfig;\n /**\n * Extra module specifier → URL mappings to merge into the import map.\n * Use this to add paths for top-level packages (e.g. `intlayer`, `vanilla-intlayer`)\n * that are not generated by Intlayer's build step.\n *\n * @example\n * ```ts\n * {\n * extraImports: {\n * 'intlayer': './node_modules/intlayer/dist/index.mjs',\n * 'vanilla-intlayer': './node_modules/vanilla-intlayer/dist/index.mjs',\n * }\n * }\n * ```\n */\n extraImports?: Record<string, string>;\n};\n\nexport type ImportMap = {\n imports: Record<string, string>;\n};\n\n/**\n * Generates a browser-native import map object from the Intlayer configuration.\n *\n * The import map resolves bare module specifiers (e.g. `@intlayer/dictionaries-entry`)\n * to their physical `.mjs` file paths relative to the project root, replicating\n * what a bundler's `alias` plugin would do.\n *\n * Paths are always forced to ESM (`.mjs`) and prefixed with `./` so they are\n * valid relative URL references for the browser.\n *\n * @example\n * ```json\n * {\n * \"imports\": {\n * \"@intlayer/dictionaries-entry\": \"./.intlayer/main/dictionaries.mjs\",\n * \"@intlayer/unmerged-dictionaries-entry\": \"./.intlayer/main/unmerged_dictionaries.mjs\",\n * \"@intlayer/remote-dictionaries-entry\": \"./.intlayer/main/remote_dictionaries.mjs\",\n * \"@intlayer/dynamic-dictionaries-entry\": \"./.intlayer/main/dynamic_dictionaries.mjs\",\n * \"@intlayer/fetch-dictionaries-entry\": \"./.intlayer/main/fetch_dictionaries.mjs\",\n * \"@intlayer/config/built\": \"./.intlayer/config/configuration.mjs\"\n * }\n * }\n * ```\n */\nexport const getImportMap = ({\n configuration,\n extraImports = {},\n}: GetImportMapOptions): ImportMap => {\n const aliases = getAlias({\n configuration,\n format: 'esm',\n formatter: (value) => `./${value}`,\n });\n\n return {\n imports: {\n ...aliases,\n ...extraImports,\n },\n };\n};\n\n/**\n * Returns the JSON string representation of the import map.\n *\n * Can be embedded directly as the content of a `<script type=\"importmap\">` tag,\n * or written to a standalone `.importmap` file and referenced via\n * `<script type=\"importmap\" src=\"./importmap.json\">`.\n */\nexport const getImportMapContent = (options: GetImportMapOptions): string =>\n JSON.stringify(getImportMap(options), null, 2);\n\n/**\n * Generates a complete `<script type=\"importmap\">` HTML element string.\n *\n * Inject this into your HTML `<head>` **before** any `<script type=\"module\">`\n * tags to enable bare module specifier resolution without a bundler.\n *\n * Prerequisites:\n * - Run `npx intlayer build` so the `.intlayer` folder is populated.\n * - Your static server must serve the `.intlayer` directory.\n *\n * @example\n * ```html\n * <!DOCTYPE html>\n * <html lang=\"en\">\n * <head>\n * <!-- generated output goes here, before any module scripts -->\n * <script type=\"module\" src=\"./src/main.js\"></script>\n * </head>\n * ```\n */\nexport const getImportMapScript = (options: GetImportMapOptions): string =>\n `<script type=\"importmap\">\\n${getImportMapContent(options)}\\n</script>`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAa,gBAAgB,EAC3B,eACA,eAAe,EAAE,OACmB;AAOpC,QAAO,EACL,SAAS;EACP,GARY,SAAS;GACvB;GACA,QAAQ;GACR,YAAY,UAAU,KAAK;GAC5B,CAAC;EAKE,GAAG;EACJ,EACF;;;;;;;;;AAUH,MAAa,uBAAuB,YAClC,KAAK,UAAU,aAAa,QAAQ,EAAE,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;AAsBhD,MAAa,sBAAsB,YACjC,8BAA8B,oBAAoB,QAAQ,CAAC"}
@@ -1,85 +0,0 @@
1
- import { IntlayerConfig } from "@intlayer/types/config";
2
-
3
- //#region src/utils/importMap.d.ts
4
- type GetImportMapOptions = {
5
- configuration: IntlayerConfig;
6
- /**
7
- * Extra module specifier → URL mappings to merge into the import map.
8
- * Use this to add paths for top-level packages (e.g. `intlayer`, `vanilla-intlayer`)
9
- * that are not generated by Intlayer's build step.
10
- *
11
- * @example
12
- * ```ts
13
- * {
14
- * extraImports: {
15
- * 'intlayer': './node_modules/intlayer/dist/index.mjs',
16
- * 'vanilla-intlayer': './node_modules/vanilla-intlayer/dist/index.mjs',
17
- * }
18
- * }
19
- * ```
20
- */
21
- extraImports?: Record<string, string>;
22
- };
23
- type ImportMap = {
24
- imports: Record<string, string>;
25
- };
26
- /**
27
- * Generates a browser-native import map object from the Intlayer configuration.
28
- *
29
- * The import map resolves bare module specifiers (e.g. `@intlayer/dictionaries-entry`)
30
- * to their physical `.mjs` file paths relative to the project root, replicating
31
- * what a bundler's `alias` plugin would do.
32
- *
33
- * Paths are always forced to ESM (`.mjs`) and prefixed with `./` so they are
34
- * valid relative URL references for the browser.
35
- *
36
- * @example
37
- * ```json
38
- * {
39
- * "imports": {
40
- * "@intlayer/dictionaries-entry": "./.intlayer/main/dictionaries.mjs",
41
- * "@intlayer/unmerged-dictionaries-entry": "./.intlayer/main/unmerged_dictionaries.mjs",
42
- * "@intlayer/remote-dictionaries-entry": "./.intlayer/main/remote_dictionaries.mjs",
43
- * "@intlayer/dynamic-dictionaries-entry": "./.intlayer/main/dynamic_dictionaries.mjs",
44
- * "@intlayer/fetch-dictionaries-entry": "./.intlayer/main/fetch_dictionaries.mjs",
45
- * "@intlayer/config/built": "./.intlayer/config/configuration.mjs"
46
- * }
47
- * }
48
- * ```
49
- */
50
- declare const getImportMap: ({
51
- configuration,
52
- extraImports
53
- }: GetImportMapOptions) => ImportMap;
54
- /**
55
- * Returns the JSON string representation of the import map.
56
- *
57
- * Can be embedded directly as the content of a `<script type="importmap">` tag,
58
- * or written to a standalone `.importmap` file and referenced via
59
- * `<script type="importmap" src="./importmap.json">`.
60
- */
61
- declare const getImportMapContent: (options: GetImportMapOptions) => string;
62
- /**
63
- * Generates a complete `<script type="importmap">` HTML element string.
64
- *
65
- * Inject this into your HTML `<head>` **before** any `<script type="module">`
66
- * tags to enable bare module specifier resolution without a bundler.
67
- *
68
- * Prerequisites:
69
- * - Run `npx intlayer build` so the `.intlayer` folder is populated.
70
- * - Your static server must serve the `.intlayer` directory.
71
- *
72
- * @example
73
- * ```html
74
- * <!DOCTYPE html>
75
- * <html lang="en">
76
- * <head>
77
- * <!-- generated output goes here, before any module scripts -->
78
- * <script type="module" src="./src/main.js"></script>
79
- * </head>
80
- * ```
81
- */
82
- declare const getImportMapScript: (options: GetImportMapOptions) => string;
83
- //#endregion
84
- export { GetImportMapOptions, ImportMap, getImportMap, getImportMapContent, getImportMapScript };
85
- //# sourceMappingURL=importMap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"importMap.d.ts","names":[],"sources":["../../../src/utils/importMap.ts"],"mappings":";;;KAGY,mBAAA;EACV,aAAA,EAAe,cAAA;EADL;;;;;;;;;;AAoBZ;;;;;EAHE,YAAA,GAAe,MAAA;AAAA;AAAA,KAGL,SAAA;EACV,OAAA,EAAS,MAAA;AAAA;;;;;;;;;;;;;AAoDX;;;;;AAuBA;;;;;;;cAhDa,YAAA;EAAgB,aAAA;EAAA;AAAA,GAG1B,mBAAA,KAAsB,SAAA;;;;;;;;cAsBZ,mBAAA,GAAuB,OAAA,EAAS,mBAAA;;;;;;;;;;;;;;;;;;;;;cAuBhC,kBAAA,GAAsB,OAAA,EAAS,mBAAA"}