@intlayer/dictionaries-entry 8.4.7 → 8.4.9

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.
@@ -2,9 +2,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
3
  let node_fs = require("node:fs");
4
4
  let node_path = require("node:path");
5
- let node_vm = require("node:vm");
6
5
  let _intlayer_config_built = require("@intlayer/config/built");
7
6
  _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
7
+ let _intlayer_config_utils = require("@intlayer/config/utils");
8
8
 
9
9
  //#region src/index.ts
10
10
  /**
@@ -13,15 +13,10 @@ _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
13
13
  * The alias allow hot reload the app (such as nextjs) on any dictionary change.
14
14
  */
15
15
  const getDictionaries = (configuration = _intlayer_config_built.default) => {
16
- const { system } = configuration;
16
+ const { system, build } = configuration;
17
17
  const dictionariesPath = (0, node_path.join)(system.mainDir, `dictionaries.cjs`);
18
18
  let dictionaries = {};
19
- if ((0, node_fs.existsSync)(dictionariesPath)) {
20
- const code = (0, node_fs.readFileSync)(dictionariesPath, "utf-8");
21
- const moduleObj = { exports: {} };
22
- (0, node_vm.runInThisContext)(`(function(exports, require, module, __filename, __dirname) {\n${code}\n})`, { filename: dictionariesPath })(moduleObj.exports, require, moduleObj, dictionariesPath, (0, node_path.dirname)(dictionariesPath));
23
- dictionaries = moduleObj.exports;
24
- }
19
+ if ((0, node_fs.existsSync)(dictionariesPath)) dictionaries = (build.require ?? _intlayer_config_utils.configESMxCJSRequire)(dictionariesPath);
25
20
  return dictionaries ?? {};
26
21
  };
27
22
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["config"],"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 { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { runInThisContext } from 'node:vm';\nimport config from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { DictionaryRegistry } from '@intlayer/types/module_augmentation';\n\ntype GetDictionaries = (configuration?: IntlayerConfig) => DictionaryRegistry;\n\nexport const getDictionaries: GetDictionaries = (\n configuration: IntlayerConfig = config\n) => {\n const { system } = configuration;\n\n const dictionariesPath = join(system.mainDir, `dictionaries.cjs`);\n\n let dictionaries = {};\n if (existsSync(dictionariesPath)) {\n // Execute directly instead of require() to avoid require.cache memory leak\n const code = readFileSync(dictionariesPath, 'utf-8');\n const moduleObj = { exports: {} as any };\n const wrappedFn = runInThisContext(\n `(function(exports, require, module, __filename, __dirname) {\\n${code}\\n})`,\n { filename: dictionariesPath }\n );\n wrappedFn(moduleObj.exports, require, moduleObj, dictionariesPath, dirname(dictionariesPath));\n dictionaries = moduleObj.exports;\n }\n\n return (dictionaries ?? {}) as DictionaryRegistry;\n};\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAa,mBACX,gBAAgCA,mCAC7B;CACH,MAAM,EAAE,WAAW;CAEnB,MAAM,uCAAwB,OAAO,SAAS,mBAAmB;CAEjE,IAAI,eAAe,EAAE;AACrB,6BAAe,iBAAiB,EAAE;EAEhC,MAAM,iCAAoB,kBAAkB,QAAQ;EACpD,MAAM,YAAY,EAAE,SAAS,EAAE,EAAS;AAKxC,gCAHE,iEAAiE,KAAK,OACtE,EAAE,UAAU,kBAAkB,CAC/B,CACS,UAAU,SAAS,SAAS,WAAW,yCAA0B,iBAAiB,CAAC;AAC7F,iBAAe,UAAU;;AAG3B,QAAQ,gBAAgB,EAAE"}
1
+ {"version":3,"file":"index.cjs","names":["config","configESMxCJSRequire"],"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 { 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 { DictionaryRegistry } from '@intlayer/types/module_augmentation';\n\ntype GetDictionaries = (configuration?: IntlayerConfig) => DictionaryRegistry;\n\nexport const getDictionaries: GetDictionaries = (\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, `dictionaries.cjs`);\n\n let dictionaries = {};\n if (existsSync(dictionariesPath)) {\n dictionaries = (build.require ?? configESMxCJSRequire)(dictionariesPath);\n }\n\n return (dictionaries ?? {}) as DictionaryRegistry;\n};\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAa,mBACX,gBAAgCA,mCAC7B;CACH,MAAM,EAAE,QAAQ,UAAU;CAG1B,MAAM,uCAAwB,OAAO,SAAS,mBAAmB;CAEjE,IAAI,eAAe,EAAE;AACrB,6BAAe,iBAAiB,CAC9B,iBAAgB,MAAM,WAAWC,6CAAsB,iBAAiB;AAG1E,QAAQ,gBAAgB,EAAE"}
@@ -1,8 +1,7 @@
1
- import { __require } from "./_virtual/_rolldown/runtime.mjs";
2
- import { existsSync, readFileSync } from "node:fs";
3
- import { dirname, join } from "node:path";
4
- import { runInThisContext } from "node:vm";
1
+ import { existsSync } from "node:fs";
2
+ import { join } from "node:path";
5
3
  import config from "@intlayer/config/built";
4
+ import { configESMxCJSRequire } from "@intlayer/config/utils";
6
5
 
7
6
  //#region src/index.ts
8
7
  /**
@@ -11,15 +10,10 @@ import config from "@intlayer/config/built";
11
10
  * The alias allow hot reload the app (such as nextjs) on any dictionary change.
12
11
  */
13
12
  const getDictionaries = (configuration = config) => {
14
- const { system } = configuration;
13
+ const { system, build } = configuration;
15
14
  const dictionariesPath = join(system.mainDir, `dictionaries.cjs`);
16
15
  let dictionaries = {};
17
- if (existsSync(dictionariesPath)) {
18
- const code = readFileSync(dictionariesPath, "utf-8");
19
- const moduleObj = { exports: {} };
20
- runInThisContext(`(function(exports, require, module, __filename, __dirname) {\n${code}\n})`, { filename: dictionariesPath })(moduleObj.exports, __require, moduleObj, dictionariesPath, dirname(dictionariesPath));
21
- dictionaries = moduleObj.exports;
22
- }
16
+ if (existsSync(dictionariesPath)) dictionaries = (build.require ?? configESMxCJSRequire)(dictionariesPath);
23
17
  return dictionaries ?? {};
24
18
  };
25
19
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"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 { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { runInThisContext } from 'node:vm';\nimport config from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { DictionaryRegistry } from '@intlayer/types/module_augmentation';\n\ntype GetDictionaries = (configuration?: IntlayerConfig) => DictionaryRegistry;\n\nexport const getDictionaries: GetDictionaries = (\n configuration: IntlayerConfig = config\n) => {\n const { system } = configuration;\n\n const dictionariesPath = join(system.mainDir, `dictionaries.cjs`);\n\n let dictionaries = {};\n if (existsSync(dictionariesPath)) {\n // Execute directly instead of require() to avoid require.cache memory leak\n const code = readFileSync(dictionariesPath, 'utf-8');\n const moduleObj = { exports: {} as any };\n const wrappedFn = runInThisContext(\n `(function(exports, require, module, __filename, __dirname) {\\n${code}\\n})`,\n { filename: dictionariesPath }\n );\n wrappedFn(moduleObj.exports, require, moduleObj, dictionariesPath, dirname(dictionariesPath));\n dictionaries = moduleObj.exports;\n }\n\n return (dictionaries ?? {}) as DictionaryRegistry;\n};\n"],"mappings":";;;;;;;;;;;;AAeA,MAAa,mBACX,gBAAgC,WAC7B;CACH,MAAM,EAAE,WAAW;CAEnB,MAAM,mBAAmB,KAAK,OAAO,SAAS,mBAAmB;CAEjE,IAAI,eAAe,EAAE;AACrB,KAAI,WAAW,iBAAiB,EAAE;EAEhC,MAAM,OAAO,aAAa,kBAAkB,QAAQ;EACpD,MAAM,YAAY,EAAE,SAAS,EAAE,EAAS;AAKxC,EAJkB,iBAChB,iEAAiE,KAAK,OACtE,EAAE,UAAU,kBAAkB,CAC/B,CACS,UAAU,oBAAkB,WAAW,kBAAkB,QAAQ,iBAAiB,CAAC;AAC7F,iBAAe,UAAU;;AAG3B,QAAQ,gBAAgB,EAAE"}
1
+ {"version":3,"file":"index.mjs","names":[],"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 { 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 { DictionaryRegistry } from '@intlayer/types/module_augmentation';\n\ntype GetDictionaries = (configuration?: IntlayerConfig) => DictionaryRegistry;\n\nexport const getDictionaries: GetDictionaries = (\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, `dictionaries.cjs`);\n\n let dictionaries = {};\n if (existsSync(dictionariesPath)) {\n dictionaries = (build.require ?? configESMxCJSRequire)(dictionariesPath);\n }\n\n return (dictionaries ?? {}) as DictionaryRegistry;\n};\n"],"mappings":";;;;;;;;;;;AAeA,MAAa,mBACX,gBAAgC,WAC7B;CACH,MAAM,EAAE,QAAQ,UAAU;CAG1B,MAAM,mBAAmB,KAAK,OAAO,SAAS,mBAAmB;CAEjE,IAAI,eAAe,EAAE;AACrB,KAAI,WAAW,iBAAiB,CAC9B,iBAAgB,MAAM,WAAW,sBAAsB,iBAAiB;AAG1E,QAAQ,gBAAgB,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/dictionaries-entry",
3
- "version": "8.4.7",
3
+ "version": "8.4.9",
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": [
@@ -76,10 +76,10 @@
76
76
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
77
77
  },
78
78
  "dependencies": {
79
- "@intlayer/config": "8.4.7"
79
+ "@intlayer/config": "8.4.9"
80
80
  },
81
81
  "devDependencies": {
82
- "@intlayer/types": "8.4.7",
82
+ "@intlayer/types": "8.4.9",
83
83
  "@types/node": "25.5.0",
84
84
  "@utils/ts-config": "1.0.4",
85
85
  "@utils/ts-config-types": "1.0.4",
@@ -1,8 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
3
- if (typeof require !== "undefined") return require.apply(this, arguments);
4
- throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
5
- });
6
-
7
- //#endregion
8
- export { __require };