@intlayer/chokidar 8.11.0-canary.0 → 8.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +1 -1
- package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
- package/dist/cjs/handleContentDeclarationFileChange.cjs +11 -5
- package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
- package/dist/esm/handleAdditionalContentDeclarationFile.mjs +1 -1
- package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -1
- package/dist/esm/handleContentDeclarationFileChange.mjs +11 -5
- package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
- package/dist/types/handleContentDeclarationFileChange.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -16,7 +16,7 @@ const handleAdditionalContentDeclarationFile = async (filePath, config) => {
|
|
|
16
16
|
await require_createType_createType.createTypes(Object.values(dictionariesOutput?.mergedDictionaries ?? {}).map((dictionary) => dictionary.dictionary), config);
|
|
17
17
|
await require_createDictionaryEntryPoint_createDictionaryEntryPoint.createDictionaryEntryPoint(config);
|
|
18
18
|
appLogger("Dictionaries built", { isVerbose: true });
|
|
19
|
-
require_createType_createModuleAugmentation.createModuleAugmentation(config);
|
|
19
|
+
await require_createType_createModuleAugmentation.createModuleAugmentation(config);
|
|
20
20
|
appLogger("Module augmentation built", { isVerbose: true });
|
|
21
21
|
for await (const plugin of config.plugins ?? []) {
|
|
22
22
|
const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleAdditionalContentDeclarationFile.cjs","names":["formatPath","buildDictionary","loadLocalDictionaries","createTypes","createDictionaryEntryPoint"],"sources":["../../src/handleAdditionalContentDeclarationFile.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleAdditionalContentDeclarationFile = async (\n filePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Additional file detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath, config);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n\n const dictionariesToBuild = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionary);\n\n await createTypes(dictionariesToBuild, config);\n\n await createDictionaryEntryPoint(config);\n\n appLogger('Dictionaries built', {\n isVerbose: true,\n });\n\n createModuleAugmentation(config);\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of config.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration: config,\n });\n }\n};\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,yCAAyC,OACpD,UACA,WACG;CACH,MAAM,sDAAyB,MAAM;CAGrC,UAAU,6BAA6BA,mCAAW,QAAQ,KAAK,EAC7D,WAAW,KACb,CAAC;CAID,MAAM,qBAAqB,MAAMC,wEAAgB,MAFhBC,qEAAsB,UAAU,MAAM,GAEF,MAAM;CAM3E,MAAMC,0CAJsB,OAAO,OACjC,oBAAoB,sBAAsB,CAAC,CAC7C,EAAE,KAAK,eAAe,WAAW,UAEG,GAAG,MAAM;CAE7C,MAAMC,yFAA2B,MAAM;CAEvC,UAAU,sBAAsB,EAC9B,WAAW,KACb,CAAC;CAED,qEAAyB,MAAM;
|
|
1
|
+
{"version":3,"file":"handleAdditionalContentDeclarationFile.cjs","names":["formatPath","buildDictionary","loadLocalDictionaries","createTypes","createDictionaryEntryPoint","createModuleAugmentation"],"sources":["../../src/handleAdditionalContentDeclarationFile.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleAdditionalContentDeclarationFile = async (\n filePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Additional file detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath, config);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n\n const dictionariesToBuild = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionary);\n\n await createTypes(dictionariesToBuild, config);\n\n await createDictionaryEntryPoint(config);\n\n appLogger('Dictionaries built', {\n isVerbose: true,\n });\n\n await createModuleAugmentation(config);\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of config.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration: config,\n });\n }\n};\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,yCAAyC,OACpD,UACA,WACG;CACH,MAAM,sDAAyB,MAAM;CAGrC,UAAU,6BAA6BA,mCAAW,QAAQ,KAAK,EAC7D,WAAW,KACb,CAAC;CAID,MAAM,qBAAqB,MAAMC,wEAAgB,MAFhBC,qEAAsB,UAAU,MAAM,GAEF,MAAM;CAM3E,MAAMC,0CAJsB,OAAO,OACjC,oBAAoB,sBAAsB,CAAC,CAC7C,EAAE,KAAK,eAAe,WAAW,UAEG,GAAG,MAAM;CAE7C,MAAMC,yFAA2B,MAAM;CAEvC,UAAU,sBAAsB,EAC9B,WAAW,KACb,CAAC;CAED,MAAMC,qEAAyB,MAAM;CAErC,UAAU,6BAA6B,EACrC,WAAW,KACb,CAAC;CAID,WAAW,MAAM,UAAU,OAAO,WAAW,CAAC,GAAG;EAC/C,MAAM,EAAE,sBAAsB,uBAAuB;EAErD,MAAM,OAAO,aAAa;GACxB,cAAc;IACZ;IACA;GACF;GACA,eAAe;EACjB,CAAC;CACH;AACF"}
|
|
@@ -8,7 +8,10 @@ const require_buildIntlayerDictionary_buildIntlayerDictionary = require('./build
|
|
|
8
8
|
const require_createType_createModuleAugmentation = require('./createType/createModuleAugmentation.cjs');
|
|
9
9
|
const require_createType_createType = require('./createType/createType.cjs');
|
|
10
10
|
const require_loadDictionaries_loadLocalDictionaries = require('./loadDictionaries/loadLocalDictionaries.cjs');
|
|
11
|
+
let node_fs_promises = require("node:fs/promises");
|
|
12
|
+
let node_path = require("node:path");
|
|
11
13
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
14
|
+
let node_fs = require("node:fs");
|
|
12
15
|
|
|
13
16
|
//#region src/handleContentDeclarationFileChange.ts
|
|
14
17
|
const handleContentDeclarationFileChange = async (filePath, config) => {
|
|
@@ -21,17 +24,20 @@ const handleContentDeclarationFileChange = async (filePath, config) => {
|
|
|
21
24
|
const updatedDictionariesPaths = updatedDictionaries.map((dictionary) => dictionary.dictionaryPath);
|
|
22
25
|
const { excludeKeys, hasRebuilt } = await require_cleanRemovedContentDeclaration.cleanRemovedContentDeclaration(filePath, localeDictionaries.map((dictionary) => dictionary.key), config);
|
|
23
26
|
const hasNewDictionaries = updatedDictionariesPaths.some((updatedDictionaryPath) => !allDictionariesPaths.includes(updatedDictionaryPath));
|
|
27
|
+
await require_createType_createType.createTypes(updatedDictionaries.map((dictionary) => dictionary.dictionary), config);
|
|
28
|
+
appLogger("TypeScript types built", { isVerbose: true });
|
|
29
|
+
await require_createType_createModuleAugmentation.createModuleAugmentation(config);
|
|
30
|
+
appLogger("Module augmentation built", { isVerbose: true });
|
|
24
31
|
if (hasRebuilt || hasNewDictionaries) {
|
|
25
32
|
if (!hasRebuilt) {
|
|
26
33
|
await require_createDictionaryEntryPoint_createDictionaryEntryPoint.createDictionaryEntryPoint(config, { excludeKeys });
|
|
27
34
|
appLogger("Dictionary list built", { isVerbose: true });
|
|
28
35
|
}
|
|
29
36
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
await
|
|
34
|
-
appLogger("Module augmentation built", { isVerbose: true });
|
|
37
|
+
const { mainDir } = config.system;
|
|
38
|
+
for (const extension of config.build.outputFormat) {
|
|
39
|
+
const entryPointPath = (0, node_path.join)(mainDir, `dictionaries.${extension}`);
|
|
40
|
+
if ((0, node_fs.existsSync)(entryPointPath)) await (0, node_fs_promises.writeFile)(entryPointPath, await (0, node_fs_promises.readFile)(entryPointPath, "utf-8"));
|
|
35
41
|
}
|
|
36
42
|
for await (const plugin of config.plugins ?? []) {
|
|
37
43
|
const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleContentDeclarationFileChange.cjs","names":["formatPath","getBuiltDictionariesPath","loadLocalDictionaries","buildDictionary","cleanRemovedContentDeclaration","
|
|
1
|
+
{"version":3,"file":"handleContentDeclarationFileChange.cjs","names":["formatPath","getBuiltDictionariesPath","loadLocalDictionaries","buildDictionary","cleanRemovedContentDeclaration","createTypes","createModuleAugmentation","createDictionaryEntryPoint"],"sources":["../../src/handleContentDeclarationFileChange.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { readFile, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { cleanRemovedContentDeclaration } from './cleanRemovedContentDeclaration';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { getBuiltDictionariesPath } from './createDictionaryEntryPoint/getBuiltDictionariesPath';\nimport { createTypes } from './createType';\nimport { createModuleAugmentation } from './createType/createModuleAugmentation';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleContentDeclarationFileChange = async (\n filePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const allDictionariesPaths: string[] = await getBuiltDictionariesPath(config);\n\n const localeDictionaries = await loadLocalDictionaries(filePath, config);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n const updatedDictionaries = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n );\n const updatedDictionariesPaths = updatedDictionaries.map(\n (dictionary) => dictionary.dictionaryPath\n );\n\n const { excludeKeys, hasRebuilt } = await cleanRemovedContentDeclaration(\n filePath,\n localeDictionaries.map((dictionary) => dictionary.key),\n config\n );\n\n const hasNewDictionaries = updatedDictionariesPaths.some(\n (updatedDictionaryPath) =>\n !allDictionariesPaths.includes(updatedDictionaryPath)\n );\n\n // Rebuild Types first — types must be ready before anything triggers a bundler rebuild.\n // esbuild (used by Angular, Vite, etc.) only watches files in its JS bundle graph; it does\n // NOT watch .intlayer/types/*.ts (TypeScript-only files). Generating types here, before\n // updating the entry point, guarantees that when the entry point write below fires esbuild's\n // file watcher the types are already up-to-date.\n const dictionariesToBuild = updatedDictionaries.map(\n (dictionary) => dictionary.dictionary\n );\n\n await createTypes(dictionariesToBuild, config);\n appLogger('TypeScript types built', {\n isVerbose: true,\n });\n\n // Always regenerate the module augmentation so that structural changes to existing\n // dictionaries (new content keys, type changes) are reflected in intlayer.d.ts.\n await createModuleAugmentation(config);\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n\n // Rebuild Entry Point\n // Only needed when the *list* of dictionaries changed (Add/Remove/Rename).\n if (hasRebuilt || hasNewDictionaries) {\n // If hasRebuilt is true, cleanRemovedContentDeclaration has already updated the entry point\n // to remove the old keys (and it likely included the new ones if they were already on disk).\n // If NOT hasRebuilt, we explicitly need to update the entry point to include the new dictionaries.\n if (!hasRebuilt) {\n await createDictionaryEntryPoint(config, { excludeKeys });\n appLogger('Dictionary list built', {\n isVerbose: true,\n });\n }\n }\n\n // Force-write the entry point files so esbuild detects a change and triggers a fresh rebuild\n // now that all types are ready. Without this, the only rebuild esbuild sees is the one\n // triggered by buildDictionary's JSON writes above — which races against type generation\n // and often runs before the new .intlayer/types/*.ts files are on disk.\n const { mainDir } = config.system;\n\n for (const extension of config.build.outputFormat) {\n const entryPointPath = join(mainDir, `dictionaries.${extension}`);\n\n if (existsSync(entryPointPath)) {\n const content = await readFile(entryPointPath, 'utf-8');\n await writeFile(entryPointPath, content);\n }\n }\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of config.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration: config,\n });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,MAAa,qCAAqC,OAChD,UACA,WACG;CACH,MAAM,sDAAyB,MAAM;CAGrC,UAAU,oBAAoBA,mCAAW,QAAQ,KAAK,EACpD,WAAW,KACb,CAAC;CAED,MAAM,uBAAiC,MAAMC,qFAAyB,MAAM;CAE5E,MAAM,qBAAqB,MAAMC,qEAAsB,UAAU,MAAM;CAEvE,MAAM,qBAAqB,MAAMC,wEAAgB,oBAAoB,MAAM;CAC3E,MAAM,sBAAsB,OAAO,OACjC,oBAAoB,sBAAsB,CAAC,CAC7C;CACA,MAAM,2BAA2B,oBAAoB,KAClD,eAAe,WAAW,cAC7B;CAEA,MAAM,EAAE,aAAa,eAAe,MAAMC,sEACxC,UACA,mBAAmB,KAAK,eAAe,WAAW,GAAG,GACrD,MACF;CAEA,MAAM,qBAAqB,yBAAyB,MACjD,0BACC,CAAC,qBAAqB,SAAS,qBAAqB,CACxD;CAWA,MAAMC,0CAJsB,oBAAoB,KAC7C,eAAe,WAAW,UAGO,GAAG,MAAM;CAC7C,UAAU,0BAA0B,EAClC,WAAW,KACb,CAAC;CAID,MAAMC,qEAAyB,MAAM;CACrC,UAAU,6BAA6B,EACrC,WAAW,KACb,CAAC;CAID,IAAI,cAAc,oBAIhB;MAAI,CAAC,YAAY;GACf,MAAMC,yFAA2B,QAAQ,EAAE,YAAY,CAAC;GACxD,UAAU,yBAAyB,EACjC,WAAW,KACb,CAAC;EACH;;CAOF,MAAM,EAAE,YAAY,OAAO;CAE3B,KAAK,MAAM,aAAa,OAAO,MAAM,cAAc;EACjD,MAAM,qCAAsB,SAAS,gBAAgB,WAAW;EAEhE,4BAAe,cAAc,GAE3B,sCAAgB,gBAAgB,qCADD,gBAAgB,OAAO,CACf;CAE3C;CAIA,WAAW,MAAM,UAAU,OAAO,WAAW,CAAC,GAAG;EAC/C,MAAM,EAAE,sBAAsB,uBAAuB;EAErD,MAAM,OAAO,aAAa;GACxB,cAAc;IACZ;IACA;GACF;GACA,eAAe;EACjB,CAAC;CACH;AACF"}
|
|
@@ -14,7 +14,7 @@ const handleAdditionalContentDeclarationFile = async (filePath, config) => {
|
|
|
14
14
|
await createTypes(Object.values(dictionariesOutput?.mergedDictionaries ?? {}).map((dictionary) => dictionary.dictionary), config);
|
|
15
15
|
await createDictionaryEntryPoint(config);
|
|
16
16
|
appLogger("Dictionaries built", { isVerbose: true });
|
|
17
|
-
createModuleAugmentation(config);
|
|
17
|
+
await createModuleAugmentation(config);
|
|
18
18
|
appLogger("Module augmentation built", { isVerbose: true });
|
|
19
19
|
for await (const plugin of config.plugins ?? []) {
|
|
20
20
|
const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleAdditionalContentDeclarationFile.mjs","names":[],"sources":["../../src/handleAdditionalContentDeclarationFile.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleAdditionalContentDeclarationFile = async (\n filePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Additional file detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath, config);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n\n const dictionariesToBuild = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionary);\n\n await createTypes(dictionariesToBuild, config);\n\n await createDictionaryEntryPoint(config);\n\n appLogger('Dictionaries built', {\n isVerbose: true,\n });\n\n createModuleAugmentation(config);\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of config.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration: config,\n });\n }\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,yCAAyC,OACpD,UACA,WACG;CACH,MAAM,YAAY,aAAa,MAAM;CAGrC,UAAU,6BAA6B,WAAW,QAAQ,KAAK,EAC7D,WAAW,KACb,CAAC;CAID,MAAM,qBAAqB,MAAM,gBAAgB,MAFhB,sBAAsB,UAAU,MAAM,GAEF,MAAM;CAM3E,MAAM,YAJsB,OAAO,OACjC,oBAAoB,sBAAsB,CAAC,CAC7C,EAAE,KAAK,eAAe,WAAW,UAEG,GAAG,MAAM;CAE7C,MAAM,2BAA2B,MAAM;CAEvC,UAAU,sBAAsB,EAC9B,WAAW,KACb,CAAC;CAED,yBAAyB,MAAM;
|
|
1
|
+
{"version":3,"file":"handleAdditionalContentDeclarationFile.mjs","names":[],"sources":["../../src/handleAdditionalContentDeclarationFile.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleAdditionalContentDeclarationFile = async (\n filePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Additional file detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath, config);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n\n const dictionariesToBuild = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionary);\n\n await createTypes(dictionariesToBuild, config);\n\n await createDictionaryEntryPoint(config);\n\n appLogger('Dictionaries built', {\n isVerbose: true,\n });\n\n await createModuleAugmentation(config);\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of config.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration: config,\n });\n }\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,yCAAyC,OACpD,UACA,WACG;CACH,MAAM,YAAY,aAAa,MAAM;CAGrC,UAAU,6BAA6B,WAAW,QAAQ,KAAK,EAC7D,WAAW,KACb,CAAC;CAID,MAAM,qBAAqB,MAAM,gBAAgB,MAFhB,sBAAsB,UAAU,MAAM,GAEF,MAAM;CAM3E,MAAM,YAJsB,OAAO,OACjC,oBAAoB,sBAAsB,CAAC,CAC7C,EAAE,KAAK,eAAe,WAAW,UAEG,GAAG,MAAM;CAE7C,MAAM,2BAA2B,MAAM;CAEvC,UAAU,sBAAsB,EAC9B,WAAW,KACb,CAAC;CAED,MAAM,yBAAyB,MAAM;CAErC,UAAU,6BAA6B,EACrC,WAAW,KACb,CAAC;CAID,WAAW,MAAM,UAAU,OAAO,WAAW,CAAC,GAAG;EAC/C,MAAM,EAAE,sBAAsB,uBAAuB;EAErD,MAAM,OAAO,aAAa;GACxB,cAAc;IACZ;IACA;GACF;GACA,eAAe;EACjB,CAAC;CACH;AACF"}
|
|
@@ -6,7 +6,10 @@ import { buildDictionary } from "./buildIntlayerDictionary/buildIntlayerDictiona
|
|
|
6
6
|
import { createModuleAugmentation } from "./createType/createModuleAugmentation.mjs";
|
|
7
7
|
import { createTypes } from "./createType/createType.mjs";
|
|
8
8
|
import { loadLocalDictionaries } from "./loadDictionaries/loadLocalDictionaries.mjs";
|
|
9
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
10
|
+
import { join } from "node:path";
|
|
9
11
|
import { getAppLogger } from "@intlayer/config/logger";
|
|
12
|
+
import { existsSync } from "node:fs";
|
|
10
13
|
|
|
11
14
|
//#region src/handleContentDeclarationFileChange.ts
|
|
12
15
|
const handleContentDeclarationFileChange = async (filePath, config) => {
|
|
@@ -19,17 +22,20 @@ const handleContentDeclarationFileChange = async (filePath, config) => {
|
|
|
19
22
|
const updatedDictionariesPaths = updatedDictionaries.map((dictionary) => dictionary.dictionaryPath);
|
|
20
23
|
const { excludeKeys, hasRebuilt } = await cleanRemovedContentDeclaration(filePath, localeDictionaries.map((dictionary) => dictionary.key), config);
|
|
21
24
|
const hasNewDictionaries = updatedDictionariesPaths.some((updatedDictionaryPath) => !allDictionariesPaths.includes(updatedDictionaryPath));
|
|
25
|
+
await createTypes(updatedDictionaries.map((dictionary) => dictionary.dictionary), config);
|
|
26
|
+
appLogger("TypeScript types built", { isVerbose: true });
|
|
27
|
+
await createModuleAugmentation(config);
|
|
28
|
+
appLogger("Module augmentation built", { isVerbose: true });
|
|
22
29
|
if (hasRebuilt || hasNewDictionaries) {
|
|
23
30
|
if (!hasRebuilt) {
|
|
24
31
|
await createDictionaryEntryPoint(config, { excludeKeys });
|
|
25
32
|
appLogger("Dictionary list built", { isVerbose: true });
|
|
26
33
|
}
|
|
27
34
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
await
|
|
32
|
-
appLogger("Module augmentation built", { isVerbose: true });
|
|
35
|
+
const { mainDir } = config.system;
|
|
36
|
+
for (const extension of config.build.outputFormat) {
|
|
37
|
+
const entryPointPath = join(mainDir, `dictionaries.${extension}`);
|
|
38
|
+
if (existsSync(entryPointPath)) await writeFile(entryPointPath, await readFile(entryPointPath, "utf-8"));
|
|
33
39
|
}
|
|
34
40
|
for await (const plugin of config.plugins ?? []) {
|
|
35
41
|
const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleContentDeclarationFileChange.mjs","names":[],"sources":["../../src/handleContentDeclarationFileChange.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { cleanRemovedContentDeclaration } from './cleanRemovedContentDeclaration';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { getBuiltDictionariesPath } from './createDictionaryEntryPoint/getBuiltDictionariesPath';\nimport { createTypes } from './createType';\nimport { createModuleAugmentation } from './createType/createModuleAugmentation';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleContentDeclarationFileChange = async (\n filePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const allDictionariesPaths: string[] = await getBuiltDictionariesPath(config);\n\n const localeDictionaries = await loadLocalDictionaries(filePath, config);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n const updatedDictionaries = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n );\n const updatedDictionariesPaths = updatedDictionaries.map(\n (dictionary) => dictionary.dictionaryPath\n );\n\n const { excludeKeys, hasRebuilt } = await cleanRemovedContentDeclaration(\n filePath,\n localeDictionaries.map((dictionary) => dictionary.key),\n config\n );\n\n const hasNewDictionaries = updatedDictionariesPaths.some(\n (updatedDictionaryPath) =>\n !allDictionariesPaths.includes(updatedDictionaryPath)\n );\n\n // Rebuild
|
|
1
|
+
{"version":3,"file":"handleContentDeclarationFileChange.mjs","names":[],"sources":["../../src/handleContentDeclarationFileChange.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { readFile, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { cleanRemovedContentDeclaration } from './cleanRemovedContentDeclaration';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { getBuiltDictionariesPath } from './createDictionaryEntryPoint/getBuiltDictionariesPath';\nimport { createTypes } from './createType';\nimport { createModuleAugmentation } from './createType/createModuleAugmentation';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleContentDeclarationFileChange = async (\n filePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const allDictionariesPaths: string[] = await getBuiltDictionariesPath(config);\n\n const localeDictionaries = await loadLocalDictionaries(filePath, config);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n const updatedDictionaries = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n );\n const updatedDictionariesPaths = updatedDictionaries.map(\n (dictionary) => dictionary.dictionaryPath\n );\n\n const { excludeKeys, hasRebuilt } = await cleanRemovedContentDeclaration(\n filePath,\n localeDictionaries.map((dictionary) => dictionary.key),\n config\n );\n\n const hasNewDictionaries = updatedDictionariesPaths.some(\n (updatedDictionaryPath) =>\n !allDictionariesPaths.includes(updatedDictionaryPath)\n );\n\n // Rebuild Types first — types must be ready before anything triggers a bundler rebuild.\n // esbuild (used by Angular, Vite, etc.) only watches files in its JS bundle graph; it does\n // NOT watch .intlayer/types/*.ts (TypeScript-only files). Generating types here, before\n // updating the entry point, guarantees that when the entry point write below fires esbuild's\n // file watcher the types are already up-to-date.\n const dictionariesToBuild = updatedDictionaries.map(\n (dictionary) => dictionary.dictionary\n );\n\n await createTypes(dictionariesToBuild, config);\n appLogger('TypeScript types built', {\n isVerbose: true,\n });\n\n // Always regenerate the module augmentation so that structural changes to existing\n // dictionaries (new content keys, type changes) are reflected in intlayer.d.ts.\n await createModuleAugmentation(config);\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n\n // Rebuild Entry Point\n // Only needed when the *list* of dictionaries changed (Add/Remove/Rename).\n if (hasRebuilt || hasNewDictionaries) {\n // If hasRebuilt is true, cleanRemovedContentDeclaration has already updated the entry point\n // to remove the old keys (and it likely included the new ones if they were already on disk).\n // If NOT hasRebuilt, we explicitly need to update the entry point to include the new dictionaries.\n if (!hasRebuilt) {\n await createDictionaryEntryPoint(config, { excludeKeys });\n appLogger('Dictionary list built', {\n isVerbose: true,\n });\n }\n }\n\n // Force-write the entry point files so esbuild detects a change and triggers a fresh rebuild\n // now that all types are ready. Without this, the only rebuild esbuild sees is the one\n // triggered by buildDictionary's JSON writes above — which races against type generation\n // and often runs before the new .intlayer/types/*.ts files are on disk.\n const { mainDir } = config.system;\n\n for (const extension of config.build.outputFormat) {\n const entryPointPath = join(mainDir, `dictionaries.${extension}`);\n\n if (existsSync(entryPointPath)) {\n const content = await readFile(entryPointPath, 'utf-8');\n await writeFile(entryPointPath, content);\n }\n }\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of config.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration: config,\n });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAa,qCAAqC,OAChD,UACA,WACG;CACH,MAAM,YAAY,aAAa,MAAM;CAGrC,UAAU,oBAAoB,WAAW,QAAQ,KAAK,EACpD,WAAW,KACb,CAAC;CAED,MAAM,uBAAiC,MAAM,yBAAyB,MAAM;CAE5E,MAAM,qBAAqB,MAAM,sBAAsB,UAAU,MAAM;CAEvE,MAAM,qBAAqB,MAAM,gBAAgB,oBAAoB,MAAM;CAC3E,MAAM,sBAAsB,OAAO,OACjC,oBAAoB,sBAAsB,CAAC,CAC7C;CACA,MAAM,2BAA2B,oBAAoB,KAClD,eAAe,WAAW,cAC7B;CAEA,MAAM,EAAE,aAAa,eAAe,MAAM,+BACxC,UACA,mBAAmB,KAAK,eAAe,WAAW,GAAG,GACrD,MACF;CAEA,MAAM,qBAAqB,yBAAyB,MACjD,0BACC,CAAC,qBAAqB,SAAS,qBAAqB,CACxD;CAWA,MAAM,YAJsB,oBAAoB,KAC7C,eAAe,WAAW,UAGO,GAAG,MAAM;CAC7C,UAAU,0BAA0B,EAClC,WAAW,KACb,CAAC;CAID,MAAM,yBAAyB,MAAM;CACrC,UAAU,6BAA6B,EACrC,WAAW,KACb,CAAC;CAID,IAAI,cAAc,oBAIhB;MAAI,CAAC,YAAY;GACf,MAAM,2BAA2B,QAAQ,EAAE,YAAY,CAAC;GACxD,UAAU,yBAAyB,EACjC,WAAW,KACb,CAAC;EACH;;CAOF,MAAM,EAAE,YAAY,OAAO;CAE3B,KAAK,MAAM,aAAa,OAAO,MAAM,cAAc;EACjD,MAAM,iBAAiB,KAAK,SAAS,gBAAgB,WAAW;EAEhE,IAAI,WAAW,cAAc,GAE3B,MAAM,UAAU,gBAAgB,MADV,SAAS,gBAAgB,OAAO,CACf;CAE3C;CAIA,WAAW,MAAM,UAAU,OAAO,WAAW,CAAC,GAAG;EAC/C,MAAM,EAAE,sBAAsB,uBAAuB;EAErD,MAAM,OAAO,aAAa;GACxB,cAAc;IACZ;IACA;GACF;GACA,eAAe;EACjB,CAAC;CACH;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleContentDeclarationFileChange.d.ts","names":[],"sources":["../../src/handleContentDeclarationFileChange.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"handleContentDeclarationFileChange.d.ts","names":[],"sources":["../../src/handleContentDeclarationFileChange.ts"],"mappings":";;;cAca,kCAAA,GACX,QAAA,UACA,MAAA,EAAQ,cAAA,KAAc,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/chokidar",
|
|
3
|
-
"version": "8.11.
|
|
3
|
+
"version": "8.11.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.",
|
|
6
6
|
"keywords": [
|
|
@@ -109,13 +109,13 @@
|
|
|
109
109
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
110
110
|
},
|
|
111
111
|
"dependencies": {
|
|
112
|
-
"@intlayer/api": "8.11.
|
|
113
|
-
"@intlayer/config": "8.11.
|
|
114
|
-
"@intlayer/core": "8.11.
|
|
115
|
-
"@intlayer/dictionaries-entry": "8.11.
|
|
116
|
-
"@intlayer/remote-dictionaries-entry": "8.11.
|
|
117
|
-
"@intlayer/types": "8.11.
|
|
118
|
-
"@intlayer/unmerged-dictionaries-entry": "8.11.
|
|
112
|
+
"@intlayer/api": "8.11.1",
|
|
113
|
+
"@intlayer/config": "8.11.1",
|
|
114
|
+
"@intlayer/core": "8.11.1",
|
|
115
|
+
"@intlayer/dictionaries-entry": "8.11.1",
|
|
116
|
+
"@intlayer/remote-dictionaries-entry": "8.11.1",
|
|
117
|
+
"@intlayer/types": "8.11.1",
|
|
118
|
+
"@intlayer/unmerged-dictionaries-entry": "8.11.1",
|
|
119
119
|
"chokidar": "5.0.0",
|
|
120
120
|
"defu": "6.1.7",
|
|
121
121
|
"fast-glob": "3.3.3",
|