@intlayer/fetch-dictionaries-entry 8.4.8 → 8.4.10

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.
@@ -4,7 +4,6 @@ let node_fs = require("node:fs");
4
4
  let node_path = require("node:path");
5
5
  let _intlayer_config_built = require("@intlayer/config/built");
6
6
  _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
7
- let _intlayer_config_utils = require("@intlayer/config/utils");
8
7
 
9
8
  //#region src/index.ts
10
9
  /**
@@ -13,12 +12,16 @@ let _intlayer_config_utils = require("@intlayer/config/utils");
13
12
  * The alias allow hot reload the app (such as nextjs) on any dictionary change.
14
13
  */
15
14
  const getDynamicDictionaries = (configuration = _intlayer_config_built.default) => {
16
- const { system, build } = configuration;
17
- const dictionariesPath = (0, node_path.join)(system.mainDir, `fetch_dictionaries.cjs`);
18
- let dictionaries = {};
19
- if ((0, node_fs.existsSync)(dictionariesPath)) {
20
- (0, _intlayer_config_utils.clearModuleCache)(dictionariesPath);
21
- dictionaries = (build.require ?? _intlayer_config_utils.configESMxCJSRequire)(dictionariesPath);
15
+ const { system } = configuration;
16
+ const { fetchDictionariesDir } = system;
17
+ const dictionaries = {};
18
+ if ((0, node_fs.existsSync)(fetchDictionariesDir)) {
19
+ const files = (0, node_fs.readdirSync)(fetchDictionariesDir).filter((file) => file.endsWith(".json"));
20
+ for (const file of files) {
21
+ const key = (0, node_path.basename)(file, (0, node_path.extname)(file));
22
+ const content = (0, node_fs.readFileSync)((0, node_path.join)(fetchDictionariesDir, file), "utf-8");
23
+ dictionaries[key] = JSON.parse(content);
24
+ }
22
25
  }
23
26
  return dictionaries;
24
27
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["config","configESMxCJSRequire"],"sources":["../../src/index.ts"],"sourcesContent":["/**\n * @intlayer/fetch-dictionaries-entry is a package that only returns the fetch 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 { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport config from '@intlayer/config/built';\nimport { clearModuleCache, configESMxCJSRequire } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\n\nexport type FetchDictionaries = Record<\n DictionaryKeys,\n StrictModeLocaleMap<Dictionary>\n>;\n\ntype GetFetchDictionaries = (\n configuration?: IntlayerConfig\n) => FetchDictionaries;\n\nexport const getDynamicDictionaries: GetFetchDictionaries = (\n configuration: IntlayerConfig = config\n) => {\n const { system, build } = configuration;\n\n // Always use cjs for dictionaries entry as it uses require\n const dictionariesPath = join(system.mainDir, `fetch_dictionaries.cjs`);\n let dictionaries: Record<\n DictionaryKeys,\n StrictModeLocaleMap<Dictionary>\n > = {};\n\n if (existsSync(dictionariesPath)) {\n // Clear cache for dynamic_dictionaries.cjs and all its dependencies (JSON files)\n clearModuleCache(dictionariesPath);\n dictionaries = (build.require ?? configESMxCJSRequire)(dictionariesPath);\n }\n\n return dictionaries;\n};\n"],"mappings":";;;;;;;;;;;;;;AA0BA,MAAa,0BACX,gBAAgCA,mCAC7B;CACH,MAAM,EAAE,QAAQ,UAAU;CAG1B,MAAM,uCAAwB,OAAO,SAAS,yBAAyB;CACvE,IAAI,eAGA,EAAE;AAEN,6BAAe,iBAAiB,EAAE;AAEhC,+CAAiB,iBAAiB;AAClC,kBAAgB,MAAM,WAAWC,6CAAsB,iBAAiB;;AAG1E,QAAO"}
1
+ {"version":3,"file":"index.cjs","names":["config"],"sources":["../../src/index.ts"],"sourcesContent":["/**\n * @intlayer/fetch-dictionaries-entry is a package that only returns the fetch 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 { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { basename, extname, join } from 'node:path';\nimport config from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\n\nexport type FetchDictionaries = Record<\n DictionaryKeys,\n StrictModeLocaleMap<Dictionary>\n>;\n\ntype GetFetchDictionaries = (\n configuration?: IntlayerConfig\n) => FetchDictionaries;\n\nexport const getDynamicDictionaries: GetFetchDictionaries = (\n configuration: IntlayerConfig = config\n) => {\n const { system } = configuration;\n const { fetchDictionariesDir } = system;\n\n const dictionaries: Record<string, any> = {};\n\n if (existsSync(fetchDictionariesDir)) {\n // Read JSON files directly to avoid require.cache memory leak\n const files = readdirSync(fetchDictionariesDir).filter((file) =>\n file.endsWith('.json')\n );\n\n for (const file of files) {\n const key = basename(file, extname(file));\n const content = readFileSync(join(fetchDictionariesDir, file), 'utf-8');\n dictionaries[key] = JSON.parse(content);\n }\n }\n\n return dictionaries as FetchDictionaries;\n};\n"],"mappings":";;;;;;;;;;;;;AAyBA,MAAa,0BACX,gBAAgCA,mCAC7B;CACH,MAAM,EAAE,WAAW;CACnB,MAAM,EAAE,yBAAyB;CAEjC,MAAM,eAAoC,EAAE;AAE5C,6BAAe,qBAAqB,EAAE;EAEpC,MAAM,iCAAoB,qBAAqB,CAAC,QAAQ,SACtD,KAAK,SAAS,QAAQ,CACvB;AAED,OAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,8BAAe,6BAAc,KAAK,CAAC;GACzC,MAAM,wDAA4B,sBAAsB,KAAK,EAAE,QAAQ;AACvE,gBAAa,OAAO,KAAK,MAAM,QAAQ;;;AAI3C,QAAO"}
@@ -1,7 +1,6 @@
1
- import { existsSync } from "node:fs";
2
- import { join } from "node:path";
1
+ import { existsSync, readFileSync, readdirSync } from "node:fs";
2
+ import { basename, extname, join } from "node:path";
3
3
  import config from "@intlayer/config/built";
4
- import { clearModuleCache, configESMxCJSRequire } from "@intlayer/config/utils";
5
4
 
6
5
  //#region src/index.ts
7
6
  /**
@@ -10,12 +9,16 @@ import { clearModuleCache, configESMxCJSRequire } from "@intlayer/config/utils";
10
9
  * The alias allow hot reload the app (such as nextjs) on any dictionary change.
11
10
  */
12
11
  const getDynamicDictionaries = (configuration = config) => {
13
- const { system, build } = configuration;
14
- const dictionariesPath = join(system.mainDir, `fetch_dictionaries.cjs`);
15
- let dictionaries = {};
16
- if (existsSync(dictionariesPath)) {
17
- clearModuleCache(dictionariesPath);
18
- dictionaries = (build.require ?? configESMxCJSRequire)(dictionariesPath);
12
+ const { system } = configuration;
13
+ const { fetchDictionariesDir } = system;
14
+ const dictionaries = {};
15
+ if (existsSync(fetchDictionariesDir)) {
16
+ const files = readdirSync(fetchDictionariesDir).filter((file) => file.endsWith(".json"));
17
+ for (const file of files) {
18
+ const key = basename(file, extname(file));
19
+ const content = readFileSync(join(fetchDictionariesDir, file), "utf-8");
20
+ dictionaries[key] = JSON.parse(content);
21
+ }
19
22
  }
20
23
  return dictionaries;
21
24
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/index.ts"],"sourcesContent":["/**\n * @intlayer/fetch-dictionaries-entry is a package that only returns the fetch 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 { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport config from '@intlayer/config/built';\nimport { clearModuleCache, configESMxCJSRequire } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\n\nexport type FetchDictionaries = Record<\n DictionaryKeys,\n StrictModeLocaleMap<Dictionary>\n>;\n\ntype GetFetchDictionaries = (\n configuration?: IntlayerConfig\n) => FetchDictionaries;\n\nexport const getDynamicDictionaries: GetFetchDictionaries = (\n configuration: IntlayerConfig = config\n) => {\n const { system, build } = configuration;\n\n // Always use cjs for dictionaries entry as it uses require\n const dictionariesPath = join(system.mainDir, `fetch_dictionaries.cjs`);\n let dictionaries: Record<\n DictionaryKeys,\n StrictModeLocaleMap<Dictionary>\n > = {};\n\n if (existsSync(dictionariesPath)) {\n // Clear cache for dynamic_dictionaries.cjs and all its dependencies (JSON files)\n clearModuleCache(dictionariesPath);\n dictionaries = (build.require ?? configESMxCJSRequire)(dictionariesPath);\n }\n\n return dictionaries;\n};\n"],"mappings":";;;;;;;;;;;AA0BA,MAAa,0BACX,gBAAgC,WAC7B;CACH,MAAM,EAAE,QAAQ,UAAU;CAG1B,MAAM,mBAAmB,KAAK,OAAO,SAAS,yBAAyB;CACvE,IAAI,eAGA,EAAE;AAEN,KAAI,WAAW,iBAAiB,EAAE;AAEhC,mBAAiB,iBAAiB;AAClC,kBAAgB,MAAM,WAAW,sBAAsB,iBAAiB;;AAG1E,QAAO"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/index.ts"],"sourcesContent":["/**\n * @intlayer/fetch-dictionaries-entry is a package that only returns the fetch 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 { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { basename, extname, join } from 'node:path';\nimport config from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\n\nexport type FetchDictionaries = Record<\n DictionaryKeys,\n StrictModeLocaleMap<Dictionary>\n>;\n\ntype GetFetchDictionaries = (\n configuration?: IntlayerConfig\n) => FetchDictionaries;\n\nexport const getDynamicDictionaries: GetFetchDictionaries = (\n configuration: IntlayerConfig = config\n) => {\n const { system } = configuration;\n const { fetchDictionariesDir } = system;\n\n const dictionaries: Record<string, any> = {};\n\n if (existsSync(fetchDictionariesDir)) {\n // Read JSON files directly to avoid require.cache memory leak\n const files = readdirSync(fetchDictionariesDir).filter((file) =>\n file.endsWith('.json')\n );\n\n for (const file of files) {\n const key = basename(file, extname(file));\n const content = readFileSync(join(fetchDictionariesDir, file), 'utf-8');\n dictionaries[key] = JSON.parse(content);\n }\n }\n\n return dictionaries as FetchDictionaries;\n};\n"],"mappings":";;;;;;;;;;AAyBA,MAAa,0BACX,gBAAgC,WAC7B;CACH,MAAM,EAAE,WAAW;CACnB,MAAM,EAAE,yBAAyB;CAEjC,MAAM,eAAoC,EAAE;AAE5C,KAAI,WAAW,qBAAqB,EAAE;EAEpC,MAAM,QAAQ,YAAY,qBAAqB,CAAC,QAAQ,SACtD,KAAK,SAAS,QAAQ,CACvB;AAED,OAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,MAAM,SAAS,MAAM,QAAQ,KAAK,CAAC;GACzC,MAAM,UAAU,aAAa,KAAK,sBAAsB,KAAK,EAAE,QAAQ;AACvE,gBAAa,OAAO,KAAK,MAAM,QAAQ;;;AAI3C,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;;KAiBY,iBAAA,GAAoB,MAAA,CAC9B,cAAA,EACA,mBAAA,CAAoB,UAAA;AAAA,KAGjB,oBAAA,IACH,aAAA,GAAgB,cAAA,KACb,iBAAA;AAAA,cAEQ,sBAAA,EAAwB,oBAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;;KAgBY,iBAAA,GAAoB,MAAA,CAC9B,cAAA,EACA,mBAAA,CAAoB,UAAA;AAAA,KAGjB,oBAAA,IACH,aAAA,GAAgB,cAAA,KACb,iBAAA;AAAA,cAEQ,sBAAA,EAAwB,oBAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/fetch-dictionaries-entry",
3
- "version": "8.4.8",
3
+ "version": "8.4.10",
4
4
  "private": false,
5
5
  "description": "Provides the entry path for Intlayer fetch dictionaries, solving filesystem retrieval issues for bundlers like Webpack and Rollup.",
6
6
  "keywords": [
@@ -76,9 +76,9 @@
76
76
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
77
77
  },
78
78
  "dependencies": {
79
- "@intlayer/config": "8.4.8",
80
- "@intlayer/core": "8.4.8",
81
- "@intlayer/types": "8.4.8"
79
+ "@intlayer/config": "8.4.10",
80
+ "@intlayer/core": "8.4.10",
81
+ "@intlayer/types": "8.4.10"
82
82
  },
83
83
  "devDependencies": {
84
84
  "@types/node": "25.5.0",
@@ -87,8 +87,8 @@
87
87
  "@utils/tsdown-config": "1.0.4",
88
88
  "rimraf": "6.1.3",
89
89
  "tsdown": "0.21.4",
90
- "typescript": "5.9.3",
91
- "vitest": "4.1.0"
90
+ "typescript": "6.0.2",
91
+ "vitest": "4.1.1"
92
92
  },
93
93
  "engines": {
94
94
  "node": ">=14.18"