@intlayer/dictionaries-entry 6.0.1 → 6.0.2-canary.0

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.
@@ -25,32 +25,13 @@ module.exports = __toCommonJS(index_exports);
25
25
  var import_config = require("@intlayer/config");
26
26
  var import_fs = require("fs");
27
27
  var import_path = require("path");
28
- const clearModuleCache = (modulePath, visited = /* @__PURE__ */ new Set()) => {
29
- if (visited.has(modulePath)) {
30
- return;
31
- }
32
- visited.add(modulePath);
33
- try {
34
- const resolvedPath = import_config.ESMxCJSRequire.resolve(modulePath);
35
- const cachedModule = import_config.ESMxCJSRequire.cache[resolvedPath];
36
- if (cachedModule) {
37
- if (cachedModule.children) {
38
- cachedModule.children.forEach((child) => {
39
- clearModuleCache(child.filename, visited);
40
- });
41
- }
42
- delete import_config.ESMxCJSRequire.cache[resolvedPath];
43
- }
44
- } catch (error) {
45
- console.warn(`Could not clear cache for module: ${modulePath}`, error);
46
- }
47
- };
48
28
  const getDictionaries = (configuration = (0, import_config.getConfiguration)()) => {
49
29
  const { content } = configuration;
50
- const dictionariesPath = (0, import_path.join)(content.mainDir, "dictionaries.cjs");
30
+ const extension = (0, import_config.getExtension)(configuration);
31
+ const dictionariesPath = (0, import_path.join)(content.mainDir, `dictionaries.${extension}`);
51
32
  let dictionaries = {};
52
33
  if ((0, import_fs.existsSync)(dictionariesPath)) {
53
- clearModuleCache(dictionariesPath);
34
+ (0, import_config.clearModuleCache)(dictionariesPath);
54
35
  dictionaries = (0, import_config.ESMxCJSRequire)(dictionariesPath);
55
36
  }
56
37
  return dictionaries ?? {};
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry file.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\n\nimport {\n ESMxCJSRequire,\n getConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config';\nimport { existsSync } from 'fs';\nimport { join } from 'path';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\n\n/**\n * Recursively clears the require cache for a module and all its dependencies\n */\nconst clearModuleCache = (modulePath: string, visited = new Set<string>()) => {\n // Avoid infinite loops\n if (visited.has(modulePath)) {\n return;\n }\n visited.add(modulePath);\n\n try {\n const resolvedPath = ESMxCJSRequire.resolve(modulePath);\n\n // Get the cached module\n const cachedModule = ESMxCJSRequire.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 ESMxCJSRequire.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\nexport const getDictionaries = (\n configuration: IntlayerConfig = getConfiguration()\n) => {\n const { content } = configuration;\n\n const dictionariesPath = join(content.mainDir, 'dictionaries.cjs');\n\n let dictionaries = {};\n if (existsSync(dictionariesPath)) {\n // Clear cache for dictionaries.cjs and all its dependencies (JSON files)\n clearModuleCache(dictionariesPath);\n\n dictionaries = ESMxCJSRequire(dictionariesPath);\n }\n\n return (dictionaries ?? {}) as Record<\n IntlayerDictionaryTypesConnector['key'],\n IntlayerDictionaryTypesConnector\n >;\n};\n\nexport default (() => getDictionaries())();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,oBAIO;AACP,gBAA2B;AAC3B,kBAAqB;AAOrB,MAAM,mBAAmB,CAAC,YAAoB,UAAU,oBAAI,IAAY,MAAM;AAE5E,MAAI,QAAQ,IAAI,UAAU,GAAG;AAC3B;AAAA,EACF;AACA,UAAQ,IAAI,UAAU;AAEtB,MAAI;AACF,UAAM,eAAe,6BAAe,QAAQ,UAAU;AAGtD,UAAM,eAAe,6BAAe,MAAM,YAAY;AAEtD,QAAI,cAAc;AAEhB,UAAI,aAAa,UAAU;AACzB,qBAAa,SAAS,QAAQ,CAAC,UAAU;AACvC,2BAAiB,MAAM,UAAU,OAAO;AAAA,QAC1C,CAAC;AAAA,MACH;AAGA,aAAO,6BAAe,MAAM,YAAY;AAAA,IAC1C;AAAA,EACF,SAAS,OAAO;AAEd,YAAQ,KAAK,qCAAqC,UAAU,IAAI,KAAK;AAAA,EACvE;AACF;AAEO,MAAM,kBAAkB,CAC7B,oBAAgC,gCAAiB,MAC9C;AACH,QAAM,EAAE,QAAQ,IAAI;AAEpB,QAAM,uBAAmB,kBAAK,QAAQ,SAAS,kBAAkB;AAEjE,MAAI,eAAe,CAAC;AACpB,UAAI,sBAAW,gBAAgB,GAAG;AAEhC,qBAAiB,gBAAgB;AAEjC,uBAAe,8BAAe,gBAAgB;AAAA,EAChD;AAEA,SAAQ,gBAAgB,CAAC;AAI3B;AAEA,IAAO,iBAAS,MAAM,gBAAgB,GAAG;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry file.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\n\nimport {\n clearModuleCache,\n ESMxCJSRequire,\n getConfiguration,\n getExtension,\n type IntlayerConfig,\n} from '@intlayer/config';\nimport { existsSync } from 'fs';\nimport { join } from 'path';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\n\nexport const getDictionaries = (\n configuration: IntlayerConfig = getConfiguration()\n) => {\n const { content } = configuration;\n\n const extension = getExtension(configuration);\n\n const dictionariesPath = join(content.mainDir, `dictionaries.${extension}`);\n\n let dictionaries = {};\n if (existsSync(dictionariesPath)) {\n // Clear cache for dictionaries.cjs and all its dependencies (JSON files)\n clearModuleCache(dictionariesPath);\n\n dictionaries = ESMxCJSRequire(dictionariesPath);\n }\n\n return (dictionaries ?? {}) as Record<\n IntlayerDictionaryTypesConnector['key'],\n IntlayerDictionaryTypesConnector\n >;\n};\n\nexport default (() => getDictionaries())();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,oBAMO;AACP,gBAA2B;AAC3B,kBAAqB;AAId,MAAM,kBAAkB,CAC7B,oBAAgC,gCAAiB,MAC9C;AACH,QAAM,EAAE,QAAQ,IAAI;AAEpB,QAAM,gBAAY,4BAAa,aAAa;AAE5C,QAAM,uBAAmB,kBAAK,QAAQ,SAAS,gBAAgB,SAAS,EAAE;AAE1E,MAAI,eAAe,CAAC;AACpB,UAAI,sBAAW,gBAAgB,GAAG;AAEhC,wCAAiB,gBAAgB;AAEjC,uBAAe,8BAAe,gBAAgB;AAAA,EAChD;AAEA,SAAQ,gBAAgB,CAAC;AAI3B;AAEA,IAAO,iBAAS,MAAM,gBAAgB,GAAG;","names":[]}
@@ -1,32 +1,15 @@
1
1
  import {
2
+ clearModuleCache,
2
3
  ESMxCJSRequire,
3
- getConfiguration
4
+ getConfiguration,
5
+ getExtension
4
6
  } from "@intlayer/config";
5
7
  import { existsSync } from "fs";
6
8
  import { join } from "path";
7
- const clearModuleCache = (modulePath, visited = /* @__PURE__ */ new Set()) => {
8
- if (visited.has(modulePath)) {
9
- return;
10
- }
11
- visited.add(modulePath);
12
- try {
13
- const resolvedPath = ESMxCJSRequire.resolve(modulePath);
14
- const cachedModule = ESMxCJSRequire.cache[resolvedPath];
15
- if (cachedModule) {
16
- if (cachedModule.children) {
17
- cachedModule.children.forEach((child) => {
18
- clearModuleCache(child.filename, visited);
19
- });
20
- }
21
- delete ESMxCJSRequire.cache[resolvedPath];
22
- }
23
- } catch (error) {
24
- console.warn(`Could not clear cache for module: ${modulePath}`, error);
25
- }
26
- };
27
9
  const getDictionaries = (configuration = getConfiguration()) => {
28
10
  const { content } = configuration;
29
- const dictionariesPath = join(content.mainDir, "dictionaries.cjs");
11
+ const extension = getExtension(configuration);
12
+ const dictionariesPath = join(content.mainDir, `dictionaries.${extension}`);
30
13
  let dictionaries = {};
31
14
  if (existsSync(dictionariesPath)) {
32
15
  clearModuleCache(dictionariesPath);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry file.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\n\nimport {\n ESMxCJSRequire,\n getConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config';\nimport { existsSync } from 'fs';\nimport { join } from 'path';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\n\n/**\n * Recursively clears the require cache for a module and all its dependencies\n */\nconst clearModuleCache = (modulePath: string, visited = new Set<string>()) => {\n // Avoid infinite loops\n if (visited.has(modulePath)) {\n return;\n }\n visited.add(modulePath);\n\n try {\n const resolvedPath = ESMxCJSRequire.resolve(modulePath);\n\n // Get the cached module\n const cachedModule = ESMxCJSRequire.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 ESMxCJSRequire.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\nexport const getDictionaries = (\n configuration: IntlayerConfig = getConfiguration()\n) => {\n const { content } = configuration;\n\n const dictionariesPath = join(content.mainDir, 'dictionaries.cjs');\n\n let dictionaries = {};\n if (existsSync(dictionariesPath)) {\n // Clear cache for dictionaries.cjs and all its dependencies (JSON files)\n clearModuleCache(dictionariesPath);\n\n dictionaries = ESMxCJSRequire(dictionariesPath);\n }\n\n return (dictionaries ?? {}) as Record<\n IntlayerDictionaryTypesConnector['key'],\n IntlayerDictionaryTypesConnector\n >;\n};\n\nexport default (() => getDictionaries())();\n"],"mappings":"AAMA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AAOrB,MAAM,mBAAmB,CAAC,YAAoB,UAAU,oBAAI,IAAY,MAAM;AAE5E,MAAI,QAAQ,IAAI,UAAU,GAAG;AAC3B;AAAA,EACF;AACA,UAAQ,IAAI,UAAU;AAEtB,MAAI;AACF,UAAM,eAAe,eAAe,QAAQ,UAAU;AAGtD,UAAM,eAAe,eAAe,MAAM,YAAY;AAEtD,QAAI,cAAc;AAEhB,UAAI,aAAa,UAAU;AACzB,qBAAa,SAAS,QAAQ,CAAC,UAAU;AACvC,2BAAiB,MAAM,UAAU,OAAO;AAAA,QAC1C,CAAC;AAAA,MACH;AAGA,aAAO,eAAe,MAAM,YAAY;AAAA,IAC1C;AAAA,EACF,SAAS,OAAO;AAEd,YAAQ,KAAK,qCAAqC,UAAU,IAAI,KAAK;AAAA,EACvE;AACF;AAEO,MAAM,kBAAkB,CAC7B,gBAAgC,iBAAiB,MAC9C;AACH,QAAM,EAAE,QAAQ,IAAI;AAEpB,QAAM,mBAAmB,KAAK,QAAQ,SAAS,kBAAkB;AAEjE,MAAI,eAAe,CAAC;AACpB,MAAI,WAAW,gBAAgB,GAAG;AAEhC,qBAAiB,gBAAgB;AAEjC,mBAAe,eAAe,gBAAgB;AAAA,EAChD;AAEA,SAAQ,gBAAgB,CAAC;AAI3B;AAEA,IAAO,iBAAS,MAAM,gBAAgB,GAAG;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry file.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\n\nimport {\n clearModuleCache,\n ESMxCJSRequire,\n getConfiguration,\n getExtension,\n type IntlayerConfig,\n} from '@intlayer/config';\nimport { existsSync } from 'fs';\nimport { join } from 'path';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\n\nexport const getDictionaries = (\n configuration: IntlayerConfig = getConfiguration()\n) => {\n const { content } = configuration;\n\n const extension = getExtension(configuration);\n\n const dictionariesPath = join(content.mainDir, `dictionaries.${extension}`);\n\n let dictionaries = {};\n if (existsSync(dictionariesPath)) {\n // Clear cache for dictionaries.cjs and all its dependencies (JSON files)\n clearModuleCache(dictionariesPath);\n\n dictionaries = ESMxCJSRequire(dictionariesPath);\n }\n\n return (dictionaries ?? {}) as Record<\n IntlayerDictionaryTypesConnector['key'],\n IntlayerDictionaryTypesConnector\n >;\n};\n\nexport default (() => getDictionaries())();\n"],"mappings":"AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AAId,MAAM,kBAAkB,CAC7B,gBAAgC,iBAAiB,MAC9C;AACH,QAAM,EAAE,QAAQ,IAAI;AAEpB,QAAM,YAAY,aAAa,aAAa;AAE5C,QAAM,mBAAmB,KAAK,QAAQ,SAAS,gBAAgB,SAAS,EAAE;AAE1E,MAAI,eAAe,CAAC;AACpB,MAAI,WAAW,gBAAgB,GAAG;AAEhC,qBAAiB,gBAAgB;AAEjC,mBAAe,eAAe,gBAAgB;AAAA,EAChD;AAEA,SAAQ,gBAAgB,CAAC;AAI3B;AAEA,IAAO,iBAAS,MAAM,gBAAgB,GAAG;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAmCjE,eAAO,MAAM,eAAe,GAC1B,gBAAe,cAAmC,KAcnB,MAAM,CACnC,gCAAgC,CAAC,KAAK,CAAC,EACvC,gCAAgC,CAEnC,CAAC;;AAEF,wBAA2C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAEjE,eAAO,MAAM,eAAe,GAC1B,gBAAe,cAAmC,KAgBnB,MAAM,CACnC,gCAAgC,CAAC,KAAK,CAAC,EACvC,gCAAgC,CAEnC,CAAC;;AAEF,wBAA2C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/dictionaries-entry",
3
- "version": "6.0.1",
3
+ "version": "6.0.2-canary.0",
4
4
  "private": false,
5
5
  "description": "Provides the entry path for Intlayer dictionaries, solving filesystem retrieval issues for bundlers like Webpack and Rollup.",
6
6
  "keywords": [
@@ -58,7 +58,7 @@
58
58
  "./package.json"
59
59
  ],
60
60
  "dependencies": {
61
- "@intlayer/config": "6.0.1"
61
+ "@intlayer/config": "6.0.2-canary.0"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@types/node": "^24.2.1",
@@ -72,13 +72,13 @@
72
72
  "typescript": "^5.9.2",
73
73
  "vitest": "^3.2.4",
74
74
  "@utils/eslint-config": "1.0.4",
75
+ "@utils/ts-config-types": "1.0.4",
75
76
  "@utils/tsup-config": "1.0.4",
76
- "@utils/ts-config": "1.0.4",
77
- "@utils/ts-config-types": "1.0.4"
77
+ "@utils/ts-config": "1.0.4"
78
78
  },
79
79
  "peerDependencies": {
80
- "@intlayer/config": "6.0.1",
81
- "intlayer": "6.0.1"
80
+ "@intlayer/config": "6.0.2-canary.0",
81
+ "intlayer": "6.0.2-canary.0"
82
82
  },
83
83
  "engines": {
84
84
  "node": ">=14.18"