next-intlayer 9.5.0 → 9.5.2

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 (30) hide show
  1. package/dist/cjs/server/startContentWatcher.cjs +22 -15
  2. package/dist/cjs/server/startContentWatcher.cjs.map +1 -1
  3. package/dist/cjs/server/useLocale.cjs +1 -1
  4. package/dist/cjs/server/useLocale.cjs.map +1 -1
  5. package/dist/cjs/server/withIntlayer.cjs +2 -9
  6. package/dist/cjs/server/withIntlayer.cjs.map +1 -1
  7. package/dist/esm/rsc/index.mjs +5 -5
  8. package/dist/esm/server/index.mjs +6 -6
  9. package/dist/esm/server/startContentWatcher.mjs +22 -15
  10. package/dist/esm/server/startContentWatcher.mjs.map +1 -1
  11. package/dist/esm/server/useLocale.mjs +1 -1
  12. package/dist/esm/server/useLocale.mjs.map +1 -1
  13. package/dist/esm/server/withIntlayer.mjs +2 -9
  14. package/dist/esm/server/withIntlayer.mjs.map +1 -1
  15. package/dist/types/@intlayer/babel/dist/types/babel-plugin-intlayer-extract.d.ts +1 -1
  16. package/dist/types/@intlayer/babel/dist/types/babel-plugin-intlayer-purge.d.ts +2 -2
  17. package/dist/types/@intlayer/babel/dist/types/extractContent/contentWriter.d.ts +2 -2
  18. package/dist/types/@intlayer/babel/dist/types/extractContent/extractContent.d.ts +2 -2
  19. package/dist/types/@intlayer/babel/dist/types/extractContent/utils/extractDictionaryInfo.d.ts +1 -1
  20. package/dist/types/generateStaticParams.d.ts +4 -1
  21. package/dist/types/generateStaticParams.d.ts.map +1 -1
  22. package/dist/types/intlayer/dist/types/index.d.ts +14 -0
  23. package/dist/types/server/prepareSwcOptimization.d.ts +1 -1
  24. package/dist/types/server/startContentWatcher.d.ts.map +1 -1
  25. package/dist/types/server/useDictionary.d.ts +1 -1
  26. package/dist/types/server/useDictionaryAsync.d.ts +1 -1
  27. package/dist/types/server/useDictionaryDynamic.d.ts +1 -1
  28. package/dist/types/server/useLocale.d.ts.map +1 -1
  29. package/dist/types/server/withIntlayer.d.ts.map +1 -1
  30. package/package.json +8 -9
@@ -4,16 +4,28 @@ let _intlayer_engine_utils = require("@intlayer/engine/utils");
4
4
 
5
5
  //#region src/server/startContentWatcher.ts
6
6
  /**
7
- * Release from which `withIntlayer` watches the content declarations on
8
- * Turbopack, making `intlayer watch --with` redundant on Next.js.
9
- */
10
- const SELF_WATCHING_RELEASE = "9.5.0";
11
- /**
12
7
  * How often a process that lost the ownership race checks whether the owner is
13
8
  * gone. Next.js's short-lived config processes release the lock when they exit,
14
9
  * so the long-lived dev server has to be able to pick it up afterwards.
15
10
  */
16
11
  const TAKEOVER_POLL_INTERVAL_MS = 5e3;
12
+ /**
13
+ * Next.js helper processes that evaluate `next.config.*` without being the dev
14
+ * server, matched on their entry script.
15
+ *
16
+ * `detached-flush` is the telemetry flusher Next spawns **detached**: it loads
17
+ * the config, outlives the dev server, and — left unchecked — wins the watcher
18
+ * lock and keeps watching after Ctrl-C, while the next `next dev` finds the
19
+ * lock taken and runs with no watcher at all.
20
+ */
21
+ const NEXT_HELPER_ENTRY_SCRIPTS = ["detached-flush"];
22
+ /**
23
+ * Whether this process is a Next.js helper rather than the dev server itself.
24
+ *
25
+ * Ownership of the watcher has to follow the process the user actually stops,
26
+ * so a helper must never take it.
27
+ */
28
+ const getIsNextHelperProcess = () => process.argv.some((argument) => NEXT_HELPER_ENTRY_SCRIPTS.some((script) => argument.includes(script)));
17
29
  /** Set once the watcher is running in this process. */
18
30
  let isWatching = false;
19
31
  /**
@@ -27,16 +39,11 @@ let isClaimInFlight = false;
27
39
  /** Reports a redundant `intlayer watch` running alongside this dev server. */
28
40
  const reportRedundantCliWatcher = (configuration, cliWatcherLabel) => (0, _intlayer_engine_utils.reportRedundantContentWatcher)(configuration, {
29
41
  cliLabel: cliWatcherLabel,
30
- bundlerLabel: "next-intlayer",
31
- since: SELF_WATCHING_RELEASE
42
+ bundlerLabel: "next-intlayer"
32
43
  });
33
44
  /**
34
- * Starts the content declaration watcher for a Turbopack dev server.
35
- *
36
- * On webpack this is done by `IntlayerPlugin`, which Turbopack cannot run — so
37
- * before {@link SELF_WATCHING_RELEASE} a Turbopack app had to be started
38
- * through `intlayer watch --with next dev` for `.content` edits to rebuild
39
- * `.intlayer`.
45
+ * Starts the content declaration watcher for a Next.js dev server, on webpack
46
+ * as well as on Turbopack.
40
47
  *
41
48
  * Stands down — with an explanation — when that CLI watcher is running anyway,
42
49
  * since two watchers would rebuild the same dictionaries at the same time.
@@ -50,8 +57,7 @@ const claimAndWatch = async (configuration) => {
50
57
  const appLogger = (0, _intlayer_config_logger.getAppLogger)(configuration);
51
58
  if (!await (0, _intlayer_engine_utils.acquireContentWatcherLock)(configuration, {
52
59
  source: "bundler",
53
- label: "next-intlayer",
54
- since: SELF_WATCHING_RELEASE
60
+ label: "next-intlayer"
55
61
  })) {
56
62
  const owner = await (0, _intlayer_engine_utils.getContentWatcherOwner)(configuration);
57
63
  if (owner?.source === "cli") {
@@ -75,6 +81,7 @@ const claimAndWatch = async (configuration) => {
75
81
  const startContentWatcher = (configuration) => {
76
82
  if (isWatching || isClaimInFlight) return;
77
83
  if (!configuration.content.watch) return;
84
+ if (getIsNextHelperProcess()) return;
78
85
  const cliWatcherLabel = (0, _intlayer_engine_utils.getCliContentWatcherLabel)();
79
86
  if (cliWatcherLabel) {
80
87
  reportRedundantCliWatcher(configuration, cliWatcherLabel);
@@ -1 +1 @@
1
- {"version":3,"file":"startContentWatcher.cjs","names":["reportRedundantContentWatcher","getAppLogger","acquireContentWatcherLock","getContentWatcherOwner","getCliContentWatcherLabel"],"sources":["../../../src/server/startContentWatcher.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config/logger';\nimport {\n acquireContentWatcherLock,\n getCliContentWatcherLabel,\n getContentWatcherOwner,\n reportRedundantContentWatcher,\n} from '@intlayer/engine/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Release from which `withIntlayer` watches the content declarations on\n * Turbopack, making `intlayer watch --with` redundant on Next.js.\n */\nconst SELF_WATCHING_RELEASE = '9.5.0';\n\n/**\n * How often a process that lost the ownership race checks whether the owner is\n * gone. Next.js's short-lived config processes release the lock when they exit,\n * so the long-lived dev server has to be able to pick it up afterwards.\n */\nconst TAKEOVER_POLL_INTERVAL_MS = 5000;\n\n/** Set once the watcher is running in this process. */\nlet isWatching = false;\n\n/**\n * Set while an ownership attempt is in flight.\n *\n * Taking the lock is asynchronous, and `next.config.*` is evaluated several\n * times per command — without this, those evaluations would pile up concurrent\n * attempts, each awaiting the same lock.\n */\nlet isClaimInFlight = false;\n\n/** Reports a redundant `intlayer watch` running alongside this dev server. */\nconst reportRedundantCliWatcher = (\n configuration: IntlayerConfig,\n cliWatcherLabel: string\n): void =>\n reportRedundantContentWatcher(configuration, {\n cliLabel: cliWatcherLabel,\n bundlerLabel: 'next-intlayer',\n since: SELF_WATCHING_RELEASE,\n });\n\n/**\n * Starts the content declaration watcher for a Turbopack dev server.\n *\n * On webpack this is done by `IntlayerPlugin`, which Turbopack cannot run — so\n * before {@link SELF_WATCHING_RELEASE} a Turbopack app had to be started\n * through `intlayer watch --with next dev` for `.content` edits to rebuild\n * `.intlayer`.\n *\n * Stands down — with an explanation — when that CLI watcher is running anyway,\n * since two watchers would rebuild the same dictionaries at the same time.\n * Otherwise starting is idempotent: the first process to take the lock watches,\n * and the others retry in the background so a short-lived config process\n * handing the lock back does not leave the session unwatched.\n *\n * @param configuration - The resolved Intlayer configuration.\n */\nconst claimAndWatch = async (configuration: IntlayerConfig): Promise<void> => {\n const appLogger = getAppLogger(configuration);\n\n const hasAcquiredLock = await acquireContentWatcherLock(configuration, {\n source: 'bundler',\n label: 'next-intlayer',\n since: SELF_WATCHING_RELEASE,\n });\n\n if (!hasAcquiredLock) {\n // A CLI watcher started from another terminal is just as redundant as one\n // wrapping this command, and worth the same explanation.\n const owner = await getContentWatcherOwner(configuration);\n\n if (owner?.source === 'cli') {\n reportRedundantCliWatcher(configuration, owner.label);\n return;\n }\n\n const retryTimer = setTimeout(() => {\n startContentWatcher(configuration);\n }, TAKEOVER_POLL_INTERVAL_MS);\n\n // Unreferenced so a process whose only remaining work is this retry can\n // still exit.\n retryTimer.unref?.();\n\n return;\n }\n\n isWatching = true;\n\n try {\n // Imported lazily: `@intlayer/engine/watcher` pulls in `@parcel/watcher`, a\n // native module that has no business being loaded during a production\n // build. `withIntlayer` already awaited `prepareIntlayer`, so the watcher\n // only has to pick up the changes that follow.\n const { watch } = await import('@intlayer/engine/watcher');\n\n await watch({ configuration });\n } catch (error) {\n isWatching = false;\n\n appLogger(['Failed to watch Intlayer content declarations:', error], {\n level: 'error',\n });\n }\n};\n\nexport const startContentWatcher = (configuration: IntlayerConfig): void => {\n if (isWatching || isClaimInFlight) return;\n if (!configuration.content.watch) return;\n\n // Spawned by `intlayer watch --with`: the CLI watcher covers the project, and\n // this is known from the environment alone — no need to touch the lock.\n const cliWatcherLabel = getCliContentWatcherLabel();\n\n if (cliWatcherLabel) {\n reportRedundantCliWatcher(configuration, cliWatcherLabel);\n return;\n }\n\n isClaimInFlight = true;\n\n // Deliberately not awaited: `withIntlayerSync` is synchronous, and the dev\n // server must not wait on the watcher to start serving.\n claimAndWatch(configuration).finally(() => {\n isClaimInFlight = false;\n });\n};\n"],"mappings":";;;;;;;;;AAaA,MAAM,wBAAwB;;;;;;AAO9B,MAAM,4BAA4B;;AAGlC,IAAI,aAAa;;;;;;;;AASjB,IAAI,kBAAkB;;AAGtB,MAAM,6BACJ,eACA,wBAEAA,sDAA8B,eAAe;CAC3C,UAAU;CACV,cAAc;CACd,OAAO;AACT,CAAC;;;;;;;;;;;;;;;;;AAkBH,MAAM,gBAAgB,OAAO,kBAAiD;CAC5E,MAAM,gBAAYC,sCAAa,aAAa;CAQ5C,IAAI,CAAC,UANyBC,kDAA0B,eAAe;EACrE,QAAQ;EACR,OAAO;EACP,OAAO;CACT,CAAC,GAEqB;EAGpB,MAAM,QAAQ,UAAMC,+CAAuB,aAAa;EAExD,IAAI,OAAO,WAAW,OAAO;GAC3B,0BAA0B,eAAe,MAAM,KAAK;GACpD;EACF;EAQA,AANmB,iBAAiB;GAClC,oBAAoB,aAAa;EACnC,GAAG,yBAIM,CAAC,CAAC,QAAQ;EAEnB;CACF;CAEA,aAAa;CAEb,IAAI;EAKF,MAAM,EAAE,UAAU,MAAM,OAAO;EAE/B,MAAM,MAAM,EAAE,cAAc,CAAC;CAC/B,SAAS,OAAO;EACd,aAAa;EAEb,UAAU,CAAC,kDAAkD,KAAK,GAAG,EACnE,OAAO,QACT,CAAC;CACH;AACF;AAEA,MAAa,uBAAuB,kBAAwC;CAC1E,IAAI,cAAc,iBAAiB;CACnC,IAAI,CAAC,cAAc,QAAQ,OAAO;CAIlC,MAAM,sBAAkBC,kDAA0B;CAElD,IAAI,iBAAiB;EACnB,0BAA0B,eAAe,eAAe;EACxD;CACF;CAEA,kBAAkB;CAIlB,cAAc,aAAa,CAAC,CAAC,cAAc;EACzC,kBAAkB;CACpB,CAAC;AACH"}
1
+ {"version":3,"file":"startContentWatcher.cjs","names":["reportRedundantContentWatcher","getAppLogger","acquireContentWatcherLock","getContentWatcherOwner","getCliContentWatcherLabel"],"sources":["../../../src/server/startContentWatcher.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config/logger';\nimport {\n acquireContentWatcherLock,\n getCliContentWatcherLabel,\n getContentWatcherOwner,\n reportRedundantContentWatcher,\n} from '@intlayer/engine/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * How often a process that lost the ownership race checks whether the owner is\n * gone. Next.js's short-lived config processes release the lock when they exit,\n * so the long-lived dev server has to be able to pick it up afterwards.\n */\nconst TAKEOVER_POLL_INTERVAL_MS = 5000;\n\n/**\n * Next.js helper processes that evaluate `next.config.*` without being the dev\n * server, matched on their entry script.\n *\n * `detached-flush` is the telemetry flusher Next spawns **detached**: it loads\n * the config, outlives the dev server, and — left unchecked — wins the watcher\n * lock and keeps watching after Ctrl-C, while the next `next dev` finds the\n * lock taken and runs with no watcher at all.\n */\nconst NEXT_HELPER_ENTRY_SCRIPTS = ['detached-flush'];\n\n/**\n * Whether this process is a Next.js helper rather than the dev server itself.\n *\n * Ownership of the watcher has to follow the process the user actually stops,\n * so a helper must never take it.\n */\nconst getIsNextHelperProcess = (): boolean =>\n process.argv.some((argument) =>\n NEXT_HELPER_ENTRY_SCRIPTS.some((script) => argument.includes(script))\n );\n\n/** Set once the watcher is running in this process. */\nlet isWatching = false;\n\n/**\n * Set while an ownership attempt is in flight.\n *\n * Taking the lock is asynchronous, and `next.config.*` is evaluated several\n * times per command — without this, those evaluations would pile up concurrent\n * attempts, each awaiting the same lock.\n */\nlet isClaimInFlight = false;\n\n/** Reports a redundant `intlayer watch` running alongside this dev server. */\nconst reportRedundantCliWatcher = (\n configuration: IntlayerConfig,\n cliWatcherLabel: string\n): void =>\n reportRedundantContentWatcher(configuration, {\n cliLabel: cliWatcherLabel,\n bundlerLabel: 'next-intlayer',\n });\n\n/**\n * Starts the content declaration watcher for a Next.js dev server, on webpack\n * as well as on Turbopack.\n *\n * Stands down — with an explanation — when that CLI watcher is running anyway,\n * since two watchers would rebuild the same dictionaries at the same time.\n * Otherwise starting is idempotent: the first process to take the lock watches,\n * and the others retry in the background so a short-lived config process\n * handing the lock back does not leave the session unwatched.\n *\n * @param configuration - The resolved Intlayer configuration.\n */\nconst claimAndWatch = async (configuration: IntlayerConfig): Promise<void> => {\n const appLogger = getAppLogger(configuration);\n\n const hasAcquiredLock = await acquireContentWatcherLock(configuration, {\n source: 'bundler',\n label: 'next-intlayer',\n });\n\n if (!hasAcquiredLock) {\n // A CLI watcher started from another terminal is just as redundant as one\n // wrapping this command, and worth the same explanation.\n const owner = await getContentWatcherOwner(configuration);\n\n if (owner?.source === 'cli') {\n reportRedundantCliWatcher(configuration, owner.label);\n return;\n }\n\n const retryTimer = setTimeout(() => {\n startContentWatcher(configuration);\n }, TAKEOVER_POLL_INTERVAL_MS);\n\n // Unreferenced so a process whose only remaining work is this retry can\n // still exit.\n retryTimer.unref?.();\n\n return;\n }\n\n isWatching = true;\n\n try {\n // Imported lazily: `@intlayer/engine/watcher` pulls in `@parcel/watcher`, a\n // native module that has no business being loaded during a production\n // build. `withIntlayer` already awaited `prepareIntlayer`, so the watcher\n // only has to pick up the changes that follow.\n const { watch } = await import('@intlayer/engine/watcher');\n\n await watch({ configuration });\n } catch (error) {\n isWatching = false;\n\n appLogger(['Failed to watch Intlayer content declarations:', error], {\n level: 'error',\n });\n }\n};\n\nexport const startContentWatcher = (configuration: IntlayerConfig): void => {\n if (isWatching || isClaimInFlight) return;\n if (!configuration.content.watch) return;\n if (getIsNextHelperProcess()) return;\n\n // Spawned by `intlayer watch --with`: the CLI watcher covers the project, and\n // this is known from the environment alone — no need to touch the lock.\n const cliWatcherLabel = getCliContentWatcherLabel();\n\n if (cliWatcherLabel) {\n reportRedundantCliWatcher(configuration, cliWatcherLabel);\n return;\n }\n\n isClaimInFlight = true;\n\n // Deliberately not awaited: `withIntlayerSync` is synchronous, and the dev\n // server must not wait on the watcher to start serving.\n claimAndWatch(configuration).finally(() => {\n isClaimInFlight = false;\n });\n};\n"],"mappings":";;;;;;;;;;AAcA,MAAM,4BAA4B;;;;;;;;;;AAWlC,MAAM,4BAA4B,CAAC,gBAAgB;;;;;;;AAQnD,MAAM,+BACJ,QAAQ,KAAK,MAAM,aACjB,0BAA0B,MAAM,WAAW,SAAS,SAAS,MAAM,CAAC,CACtE;;AAGF,IAAI,aAAa;;;;;;;;AASjB,IAAI,kBAAkB;;AAGtB,MAAM,6BACJ,eACA,wBAEAA,sDAA8B,eAAe;CAC3C,UAAU;CACV,cAAc;AAChB,CAAC;;;;;;;;;;;;;AAcH,MAAM,gBAAgB,OAAO,kBAAiD;CAC5E,MAAM,gBAAYC,sCAAa,aAAa;CAO5C,IAAI,CAAC,UALyBC,kDAA0B,eAAe;EACrE,QAAQ;EACR,OAAO;CACT,CAAC,GAEqB;EAGpB,MAAM,QAAQ,UAAMC,+CAAuB,aAAa;EAExD,IAAI,OAAO,WAAW,OAAO;GAC3B,0BAA0B,eAAe,MAAM,KAAK;GACpD;EACF;EAQA,AANmB,iBAAiB;GAClC,oBAAoB,aAAa;EACnC,GAAG,yBAIM,CAAC,CAAC,QAAQ;EAEnB;CACF;CAEA,aAAa;CAEb,IAAI;EAKF,MAAM,EAAE,UAAU,MAAM,OAAO;EAE/B,MAAM,MAAM,EAAE,cAAc,CAAC;CAC/B,SAAS,OAAO;EACd,aAAa;EAEb,UAAU,CAAC,kDAAkD,KAAK,GAAG,EACnE,OAAO,QACT,CAAC;CACH;AACF;AAEA,MAAa,uBAAuB,kBAAwC;CAC1E,IAAI,cAAc,iBAAiB;CACnC,IAAI,CAAC,cAAc,QAAQ,OAAO;CAClC,IAAI,uBAAuB,GAAG;CAI9B,MAAM,sBAAkBC,kDAA0B;CAElD,IAAI,iBAAiB;EACnB,0BAA0B,eAAe,eAAe;EACxD;CACF;CAEA,kBAAkB;CAIlB,cAAc,aAAa,CAAC,CAAC,cAAc;EACzC,kBAAkB;CACpB,CAAC;AACH"}
@@ -3,6 +3,7 @@ const require_server_ambientLocale = require('./ambientLocale.cjs');
3
3
  let _intlayer_config_built = require("@intlayer/config/built");
4
4
 
5
5
  //#region src/server/useLocale.ts
6
+ const { defaultLocale, locales: availableLocales } = _intlayer_config_built.internationalization ?? {};
6
7
  /**
7
8
  * On the server side, hook returning the current locale along with the default
8
9
  * and available ones.
@@ -13,7 +14,6 @@ let _intlayer_config_built = require("@intlayer/config/built");
13
14
  * render the provider did not reach.
14
15
  */
15
16
  const useLocale = () => {
16
- const { defaultLocale, locales: availableLocales } = _intlayer_config_built.internationalization ?? {};
17
17
  return {
18
18
  locale: require_server_ambientLocale.resolveAmbientLocale() ?? defaultLocale,
19
19
  defaultLocale,
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.cjs","names":["internationalization","resolveAmbientLocale"],"sources":["../../../src/server/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { resolveAmbientLocale } from './ambientLocale';\n\nexport type UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n};\n\n/**\n * On the server side, hook returning the current locale along with the default\n * and available ones.\n *\n * Reimplemented rather than re-exported from `react-intlayer/server`: that one\n * takes no locale argument, so there is no way to hand it the ambient locale —\n * it would read the server context alone and report the default locale on any\n * render the provider did not reach.\n */\nexport const useLocale = (): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const locale = (resolveAmbientLocale() ?? defaultLocale) as DeclaredLocales;\n\n return { locale, defaultLocale, availableLocales };\n};\n"],"mappings":";;;;;;;;;;;;;;AAmBA,MAAa,kBAAmC;CAC9C,MAAM,EAAE,eAAe,SAAS,qBAC9BA,+CAAwB,CAAC;CAI3B,OAAO;EAAE,QAFOC,kDAAqB,KAAK;EAEzB;EAAe;CAAiB;AACnD"}
1
+ {"version":3,"file":"useLocale.cjs","names":["internationalization","resolveAmbientLocale"],"sources":["../../../src/server/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { resolveAmbientLocale } from './ambientLocale';\n\nexport type UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n};\n\nconst { defaultLocale, locales: availableLocales } = internationalization ?? {};\n\n/**\n * On the server side, hook returning the current locale along with the default\n * and available ones.\n *\n * Reimplemented rather than re-exported from `react-intlayer/server`: that one\n * takes no locale argument, so there is no way to hand it the ambient locale —\n * it would read the server context alone and report the default locale on any\n * render the provider did not reach.\n */\nexport const useLocale = (): UseLocaleResult => {\n const locale = (resolveAmbientLocale() ?? defaultLocale) as DeclaredLocales;\n\n return { locale, defaultLocale, availableLocales };\n};\n"],"mappings":";;;;;AAUA,MAAM,EAAE,eAAe,SAAS,qBAAqBA,+CAAwB,CAAC;;;;;;;;;;AAW9E,MAAa,kBAAmC;CAG9C,OAAO;EAAE,QAFOC,kDAAqB,KAAK;EAEzB;EAAe;CAAiB;AACnD"}
@@ -17,7 +17,6 @@ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryMan
17
17
  let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
18
18
  let _intlayer_engine_build = require("@intlayer/engine/build");
19
19
  let _intlayer_engine_cli = require("@intlayer/engine/cli");
20
- let _intlayer_webpack = require("@intlayer/webpack");
21
20
  let defu = require("defu");
22
21
  let next_package_json = require("next/package.json");
23
22
  next_package_json = require_runtime.__toESM(next_package_json);
@@ -178,11 +177,7 @@ const getPruneConfig = ({ intlayerConfig, isBuildCommand, isTurbopackEnabled, is
178
177
  const dynamicDictionariesEntryPath = (0, node_path.join)(mainDir, "dynamic_dictionaries.mjs");
179
178
  const unmergedDictionariesEntryPath = (0, node_path.join)(mainDir, "unmerged_dictionaries.mjs");
180
179
  const fetchDictionariesEntryPath = (0, node_path.join)(mainDir, "fetch_dictionaries.mjs");
181
- const filesList = [
182
- ...(0, _intlayer_engine_utils.buildComponentFilesList)(intlayerConfig),
183
- dictionariesEntryPath,
184
- unmergedDictionariesEntryPath
185
- ];
180
+ const filesList = [...(0, _intlayer_engine_utils.buildComponentFilesList)(intlayerConfig), dictionariesEntryPath];
186
181
  const dictionaries = (0, _intlayer_dictionaries_entry.getDictionaries)(intlayerConfig);
187
182
  const dictionaryModeMap = {};
188
183
  Object.values(dictionaries).forEach((dictionary) => {
@@ -269,7 +264,7 @@ const withIntlayerSync = (nextConfig = {}, configOptions) => {
269
264
  if (isTurbopackEnabled && typeof nextConfig.webpack !== "undefined") appLogger("Turbopack is enabled but a custom webpack config is present. It will be ignored.");
270
265
  const { isBuildCommand, isDevCommand } = getCommandsEvent();
271
266
  const extractorLoader = getExtractorLoader(intlayerConfig, isTurbopackEnabled ?? false, isDevCommand);
272
- if (isTurbopackEnabled && isDevCommand) require_server_startContentWatcher.startContentWatcher(intlayerConfig);
267
+ if (isDevCommand) require_server_startContentWatcher.startContentWatcher(intlayerConfig);
273
268
  const turboConfig = {
274
269
  resolveAlias: (0, _intlayer_config_utils.getAlias)({
275
270
  configuration: intlayerConfig,
@@ -345,7 +340,6 @@ const withIntlayerSync = (nextConfig = {}, configOptions) => {
345
340
  } else config = {
346
341
  ...config,
347
342
  webpack: (config, options) => {
348
- const { isServer, nextRuntime } = options;
349
343
  if (typeof nextConfig.webpack === "function") config = nextConfig.webpack(config, options);
350
344
  if (config.externals === false) config.externals = [];
351
345
  const externalExact = /* @__PURE__ */ new Set([
@@ -381,7 +375,6 @@ const withIntlayerSync = (nextConfig = {}, configOptions) => {
381
375
  formatter: (value) => (0, node_path.resolve)(value)
382
376
  })
383
377
  };
384
- if (isDevCommand && isServer && nextRuntime === "nodejs") config.plugins.push(new _intlayer_webpack.IntlayerPlugin(intlayerConfig));
385
378
  return config;
386
379
  }
387
380
  };
@@ -1 +1 @@
1
- {"version":3,"file":"withIntlayer.cjs","names":["nextPackageJSON","getProjectRequire","compareVersions","getIsSwcPluginSupported","normalizePath","relative","COMPILER_ENABLED","getAppLogger","join","colorize","ANSIColors","MINIMUM_SWC_PLUGIN_NEXT_VERSION","IMPORT_MODE","getIsPurgePipelineAvailable","buildComponentFilesList","getDictionaries","getNestedDictionaryGraph","toSwcExtraCallers","resolveSwcLogLevel","getConfiguration","getAlias","getUnusedNodeTypes","formatNodeTypeToEnvVar","formatOptimizedNestingEnvVar","formatDictionarySelectorEnvVar","getHasDictionarySelector","getConfigEnvVars","resolve","IntlayerPlugin","prepareIntlayer","prepareSwcOptimization"],"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { join, relative, resolve } from 'node:path';\nimport {\n type CallerDescriptor,\n toSwcExtraCallers,\n} from '@intlayer/config/callers';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { COMPILER_ENABLED, IMPORT_MODE } from '@intlayer/config/defaultValues';\nimport {\n formatDictionarySelectorEnvVar,\n formatNodeTypeToEnvVar,\n formatOptimizedNestingEnvVar,\n getConfigEnvVars,\n} from '@intlayer/config/envVars';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport {\n compareVersions,\n getAlias,\n getHasDictionarySelector,\n getProjectRequire,\n getUnusedNodeTypes,\n normalizePath,\n} from '@intlayer/config/utils';\nimport { getNestedDictionaryGraph } from '@intlayer/core/dictionaryManipulator';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { prepareIntlayer } from '@intlayer/engine/build';\nimport { logConfigDetails } from '@intlayer/engine/cli';\nimport { buildComponentFilesList, runOnce } from '@intlayer/engine/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { IntlayerPlugin } from '@intlayer/webpack';\nimport { defu } from 'defu';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport nextPackageJSON from 'next/package.json' with { type: 'json' };\nimport {\n type FieldRenameMapByDictionaryKey,\n getIsPurgePipelineAvailable,\n prepareSwcOptimization,\n resolveSwcLogLevel,\n} from './prepareSwcOptimization';\nimport { startContentWatcher } from './startContentWatcher';\nimport {\n getIsSwcPluginSupported,\n MINIMUM_SWC_PLUGIN_NEXT_VERSION,\n} from './swcPluginCompatibility';\n\nexport {\n getIsSwcPluginSupported,\n MINIMUM_SWC_PLUGIN_NEXT_VERSION,\n} from './swcPluginCompatibility';\n\n/**\n * Resolve the Next.js version from the *user's* project at runtime.\n * A static `import from 'next/package.json'` would resolve relative to\n * next-intlayer's own node_modules, which may differ in a monorepo.\n */\nconst getNextVersionFlags = (intlayerConfig: IntlayerConfig) => {\n let nextVersion = nextPackageJSON.version;\n\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n const pkg = requireFunction('next/package.json') as { version: string };\n nextVersion = pkg.version;\n } catch {\n // keep default\n }\n\n return {\n nextVersion,\n isGteNext13: compareVersions(nextVersion, '≥', '13.0.0'),\n isGteNext15: compareVersions(nextVersion, '≥', '15.0.0'),\n isGteNext16: compareVersions(nextVersion, '≥', '16.0.0'),\n isTurbopackStable: compareVersions(nextVersion, '≥', '15.3.0'),\n /**\n * Whether this Next.js release can load the `@intlayer/swc` Wasm plugin.\n * See {@link MINIMUM_SWC_PLUGIN_NEXT_VERSION}.\n */\n isSwcPluginSupported: getIsSwcPluginSupported(nextVersion),\n };\n};\n\n// Check if SWC plugin is available\nconst getIsSwcPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/swc');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\n// Check if Babel plugin is available\nconst getIsBabelExtractPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/babel');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\nconst resolvePluginPath = (\n pluginPath: string,\n intlayerConfig: IntlayerConfig,\n isTurbopackEnabled: boolean\n): string => {\n const requireFunction = intlayerConfig.build?.require ?? getProjectRequire();\n const pluginPathResolved = requireFunction?.resolve(pluginPath);\n\n if (isTurbopackEnabled)\n // Relative path for turbopack\n return normalizePath(`./${relative(process.cwd(), pluginPathResolved)}`);\n\n // Absolute path for webpack\n return pluginPathResolved;\n};\n\n/**\n * Extensions the extraction loader is registered for.\n *\n * The compiler reads its content out of JSX — element text and the\n * translatable attributes — so a file with no JSX in it has nothing to give,\n * and `*.ts` is left out. `*.js` is in because a plain-JavaScript Next.js app\n * writes its components there.\n */\nconst EXTRACTOR_LOADER_EXTENSIONS = ['tsx', 'jsx', 'js'] as const;\n\n/**\n * The subset safe to register as a Turbopack rule on any Next.js version.\n *\n * Turbopack rules match every module it processes, dependencies included, and\n * only Next.js 16 can express \"skip `node_modules`\" (see\n * {@link TURBOPACK_PROJECT_FILES_CONDITION}). Below that, `*.js` would hand\n * every dependency file to a Node loader worker, so it is left out rather than\n * made to cost a cold dev start.\n */\nconst TURBOPACK_ALWAYS_SAFE_EXTENSIONS = ['tsx', 'jsx'] as const;\n\n/**\n * Restricts a Turbopack rule to the project's own files. `foreign` is\n * Turbopack's builtin condition for a module inside `node_modules`.\n *\n * Only understood from Next.js 16 on — earlier releases carry no `condition`\n * field on a rule at all.\n */\nconst TURBOPACK_PROJECT_FILES_CONDITION = { not: 'foreign' } as const;\n\n/** Mode reported to the extraction loader, which cannot read the command. */\ntype ExtractorLoaderMode = 'dev' | 'build';\n\n/**\n * Whether the Intlayer compiler should extract content for this command.\n *\n * Mirrors `getExtractPluginOptions`, which the loader re-evaluates on its side:\n * this is only about not registering a loader that would do nothing.\n */\nconst getIsCompilerEnabled = (\n intlayerConfig: IntlayerConfig,\n isDevCommand: boolean\n): boolean => {\n const enabled = intlayerConfig.compiler?.enabled ?? COMPILER_ENABLED;\n\n if (enabled === 'build-only') return !isDevCommand;\n\n return enabled !== false;\n};\n\n/**\n * Describes the extraction loader for both bundlers, or `null` when the\n * compiler is off or `@intlayer/babel` is not installed.\n *\n * The loader replaces the `babel.config.js` the compiler used to need on\n * Next.js: Turbopack never reads a Babel config, and on webpack the mere\n * presence of one opts the whole project out of SWC — including the\n * `@intlayer/swc` optimize pass.\n */\nconst getExtractorLoader = (\n intlayerConfig: IntlayerConfig,\n isTurbopackEnabled: boolean,\n isDevCommand: boolean\n): { loaderPath: string; mode: ExtractorLoaderMode } | null => {\n if (!getIsCompilerEnabled(intlayerConfig, isDevCommand)) return null;\n if (!getIsBabelExtractPluginAvailable(intlayerConfig)) return null;\n\n try {\n return {\n loaderPath: resolvePluginPath(\n 'next-intlayer/extractor-loader',\n intlayerConfig,\n isTurbopackEnabled\n ),\n mode: isDevCommand ? 'dev' : 'build',\n };\n } catch {\n // An installed `next-intlayer` that cannot resolve its own subpath means a\n // version predating the loader — the Babel setup still applies there.\n return null;\n }\n};\n\ntype GetPruneConfigParams = {\n intlayerConfig: IntlayerConfig;\n isBuildCommand: boolean;\n isTurbopackEnabled: boolean;\n isDevCommand: boolean;\n isGteNext13: boolean;\n /** Whether the resolved Next.js version can load the Wasm plugin. */\n isSwcPluginSupported: boolean;\n /** Resolved Next.js version, reported when the plugin has to stand down. */\n nextVersion: string;\n compatCallers?: CallerDescriptor[];\n fieldRenameMap?: FieldRenameMapByDictionaryKey;\n};\n\nconst getPruneConfig = ({\n intlayerConfig,\n isBuildCommand,\n isTurbopackEnabled,\n isDevCommand,\n isGteNext13,\n isSwcPluginSupported,\n nextVersion,\n compatCallers,\n fieldRenameMap,\n}: GetPruneConfigParams): Partial<NextConfig> => {\n const { optimize, minify, purge } = intlayerConfig.build;\n const importMode =\n intlayerConfig.build.importMode ?? intlayerConfig.dictionary?.importMode;\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n } = intlayerConfig.system;\n const { baseDir } = intlayerConfig.system;\n const logger = getAppLogger(intlayerConfig);\n\n if (optimize === false) {\n return {};\n }\n if (optimize === undefined && !isBuildCommand) {\n return {};\n }\n\n if (!isGteNext13) return {};\n\n const isSwcPluginAvailable = getIsSwcPluginAvailable(intlayerConfig);\n\n runOnce(\n join(baseDir, '.intlayer', 'cache', 'intlayer-prune-plugin-enabled.lock'),\n () => {\n if (isSwcPluginAvailable && !isSwcPluginSupported) {\n logger(\n [\n `Build optimization ${colorize('disabled', ANSIColors.GREY_DARK)}:`,\n colorize('@intlayer/swc', ANSIColors.GREY_LIGHT),\n colorize(\n `cannot run on Next.js ${nextVersion} — its bundled SWC predates the`,\n ANSIColors.GREY\n ),\n colorize(\n 'stable Wasm plugin ABI. Upgrade to Next.js',\n ANSIColors.GREY\n ),\n colorize(MINIMUM_SWC_PLUGIN_NEXT_VERSION, ANSIColors.BLUE),\n colorize('or later to enable it.', ANSIColors.GREY),\n ],\n { level: 'warn' }\n );\n } else if (isSwcPluginAvailable) {\n logger([\n `Build optimization ${colorize('enabled', ANSIColors.GREEN)}`,\n colorize(`(import mode:`, ANSIColors.GREY_DARK),\n colorize(importMode ?? IMPORT_MODE, ANSIColors.BLUE),\n colorize(`)`, ANSIColors.GREY_DARK),\n ]);\n\n // The purge / minify pipeline stands down — with its own explanation —\n // when `@intlayer/babel` (which runs it) is not resolvable. The editor\n // only stands the field-rename step down, not the pipeline.\n const isPurgePipelineEnabled =\n getIsPurgePipelineAvailable(intlayerConfig);\n\n // The purge pipeline reports the field-rename step standing down when\n // the editor is enabled, so this line stays a plain one.\n if (isPurgePipelineEnabled && minify) {\n logger(\n `Dictionary minification ${colorize('enabled', ANSIColors.GREEN)}`\n );\n }\n\n if (isPurgePipelineEnabled && purge) {\n logger(\n `Dictionary purge unused keys ${colorize('enabled', ANSIColors.GREEN)}`\n );\n }\n } else {\n logger([\n colorize('Recommended: Install', ANSIColors.GREY),\n colorize('@intlayer/swc', ANSIColors.GREY_LIGHT),\n colorize(\n 'package to enable build optimization. See documentation:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://intlayer.org/docs/bundle-optimization',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n runOnce(\n join(\n baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-compiler-plugin-enabled.lock'\n ),\n () => {\n const isBabelExtractPluginAvailable =\n getIsBabelExtractPluginAvailable(intlayerConfig);\n\n if (isBabelExtractPluginAvailable) {\n let isEnabled = intlayerConfig.compiler?.enabled ?? true;\n\n if (isEnabled === 'build-only') {\n isEnabled = !isDevCommand;\n }\n\n // Only the enabled state is reported: disabling the compiler is an\n // explicit configuration choice, so announcing it on every build adds\n // noise without telling the user anything they did not ask for.\n if (isEnabled) {\n logger('Intlayer compiler enabled');\n }\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n // Registering the plugin on a host that cannot load it is not a degraded\n // build but a failed one: SWC aborts with `failed to invoke plugin`. Standing\n // down leaves the app running off the runtime dictionary registry, which the\n // transform would otherwise have emptied.\n if (!isSwcPluginAvailable || !isSwcPluginSupported) {\n return {};\n }\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n\n const unmergedDictionariesEntryPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n\n const fetchDictionariesEntryPath = join(mainDir, 'fetch_dictionaries.mjs');\n\n const filesListPattern = buildComponentFilesList(intlayerConfig);\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n unmergedDictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n ];\n\n const dictionaries = getDictionaries(intlayerConfig);\n\n const dictionaryModeMap: Record<string, 'static' | 'dynamic' | 'fetch'> = {};\n\n (Object.values(dictionaries) as Dictionary[]).forEach((dictionary) => {\n dictionaryModeMap[dictionary.key] =\n dictionary.importMode ?? importMode ?? IMPORT_MODE;\n });\n\n // Dictionaries holding `nest()` references: their static import is re-pointed\n // at the companion module carrying the nest targets.\n const nestingDictionaryKeys = [\n ...getNestedDictionaryGraph(Object.values(dictionaries)).keys(),\n ];\n\n return {\n experimental: {\n swcPlugins: [\n [\n resolvePluginPath(\n '@intlayer/swc',\n intlayerConfig,\n isTurbopackEnabled\n ),\n {\n dictionariesDir,\n dictionariesEntryPath,\n unmergedDictionariesEntryPath,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n fetchDictionariesDir,\n fetchDictionariesEntryPath,\n importMode,\n filesList,\n replaceDictionaryEntry: true,\n nestingDictionaryKeys,\n dictionaryModeMap,\n // Compat adapters reach the Wasm plugin as descriptors serialised\n // to its wire format; with none injected the option is empty and\n // the plugin runs the base intlayer rewrite alone.\n extraCallers: toSwcExtraCallers(compatCallers ?? []),\n // Rewrites `content.title` → `content.a` to match the compiled\n // dictionaries the `build.minify` pass already renamed.\n fieldRenameMap: fieldRenameMap ?? {},\n logLevel: resolveSwcLogLevel(intlayerConfig),\n },\n ],\n ],\n },\n };\n};\n\nconst getCommandsEvent = () => {\n const lifecycleEvent = process.env['npm_lifecycle_event'];\n const lifecycleScript = process.env['npm_lifecycle_script'] ?? '';\n\n const isDevCommand =\n lifecycleEvent === 'dev' ||\n process.argv.some((arg) => arg === 'dev') ||\n /(^|\\s)(next\\s+)?dev(\\s|$)/.test(lifecycleScript);\n\n const isBuildCommand =\n lifecycleEvent === 'build' ||\n process.argv.some((arg) => arg === 'build') ||\n /(^|\\s)(next\\s+)?build(\\s|$)/.test(lifecycleScript);\n\n const isStartCommand =\n lifecycleEvent === 'start' ||\n process.argv.some((arg) => arg === 'start') ||\n /(^|\\s)(next\\s+)?start(\\s|$)/.test(lifecycleScript);\n\n return {\n isDevCommand,\n isBuildCommand,\n isStartCommand,\n };\n};\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\ntype WithIntlayerOptions = GetConfigurationOptions & {\n enableTurbopack?: boolean;\n /**\n * Compat-adapter caller descriptors injected by a compat package's bundler\n * plugin (e.g. `@intlayer/next-intl/plugin`). They drive both the SWC\n * optimize rewrite and the Node-side usage analysis, so one registry slice\n * is all a compat plugin has to pass.\n */\n compatCallers?: CallerDescriptor[];\n\n /**\n * Field-rename tables produced by the purge / minify pipeline, forwarded to\n * the `@intlayer/swc` plugin so it rewrites source accesses to match the\n * renamed dictionaries.\n *\n * @internal Set by {@link withIntlayer}; `withIntlayerSync` on its own runs\n * no dictionary rewrite, so it leaves this unset and no rename is applied.\n */\n fieldRenameMap?: FieldRenameMapByDictionaryKey;\n};\n\n/**\n * Pin the env file used to resolve the Intlayer configuration to the Next.js\n * command being run (`dev` → `development`, `build`/`start` → `production`).\n *\n * Next.js loads the config file in several processes during a single command\n * (the main `build` process plus one or more Turbopack/webpack workers), and\n * `process.env.NODE_ENV` is not guaranteed to hold the same value in all of\n * them. Since `getConfiguration` falls back to `NODE_ENV` to pick its env file\n * (`.env.development.local` vs `.env.production.local`), those processes could\n * otherwise resolve *different* env values (e.g. `applicationURL`,\n * `INTLAYER_CLIENT_ID`). The resulting configuration would differ between\n * processes, defeating the `isCachedConfigurationUpToDate` check and forcing a\n * redundant full dictionary rebuild.\n *\n * Passing an explicit `env` keeps configuration resolution deterministic across\n * every process of the command. An `env` already set by the caller is\n * respected, and when the command cannot be determined we fall back to\n * `getConfiguration`'s own default (i.e. leave `env` unset).\n */\nconst resolveConfigOptions = (\n configOptions?: WithIntlayerOptions\n): WithIntlayerOptions | undefined => {\n // Respect an explicit override from the caller (idempotent on re-entry).\n if (configOptions?.env) return configOptions;\n\n const { isDevCommand, isBuildCommand, isStartCommand } = getCommandsEvent();\n\n const env = isDevCommand\n ? 'development'\n : isBuildCommand || isStartCommand\n ? 'production'\n : undefined;\n\n if (!env) return configOptions;\n\n return {\n ...configOptions,\n env,\n };\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayerSync(nextConfig)\n * ```\n */\nexport const withIntlayerSync = <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T,\n configOptions?: WithIntlayerOptions\n): NextConfig & T => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const resolvedConfigOptions = resolveConfigOptions(configOptions);\n\n const intlayerConfig = getConfiguration(resolvedConfigOptions);\n\n logConfigDetails(resolvedConfigOptions);\n\n const appLogger = getAppLogger(intlayerConfig);\n\n const {\n nextVersion,\n isGteNext13,\n isGteNext15,\n isGteNext16,\n isTurbopackStable,\n isSwcPluginSupported,\n } = getNextVersionFlags(intlayerConfig);\n\n const isTurbopackEnabledFromCommand = isGteNext16\n ? // Next@16 enables turbopack by default; disable with --webpack\n !process.env['npm_lifecycle_script']?.includes('--webpack')\n : // Next@15 uses --turbopack, Next@14 uses --turbo\n process.env['npm_lifecycle_script']?.includes('--turbo');\n\n const isTurbopackEnabled =\n configOptions?.enableTurbopack ?? isTurbopackEnabledFromCommand;\n\n if (isTurbopackEnabled && typeof nextConfig.webpack !== 'undefined') {\n appLogger(\n 'Turbopack is enabled but a custom webpack config is present. It will be ignored.'\n );\n }\n\n const { isBuildCommand, isDevCommand } = getCommandsEvent();\n\n const extractorLoader = getExtractorLoader(\n intlayerConfig,\n isTurbopackEnabled ?? false,\n isDevCommand\n );\n\n // Turbopack cannot run `IntlayerPlugin`, which is what starts the content\n // watcher on webpack. Without this the dev server had to be wrapped in\n // `intlayer watch --with next dev` for a `.content` edit to reach `.intlayer`.\n if (isTurbopackEnabled && isDevCommand) {\n startContentWatcher(intlayerConfig);\n }\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => `./${value}`, // prefix by './' to consider the path as relative to the project root. This is necessary for turbopack to work correctly.\n }),\n\n rules: {\n '*.node': {\n as: '*.node',\n loaders: ['node-loader'],\n },\n\n // Turbopack serialises loader options to JSON, so the loader reads the\n // Intlayer configuration itself and only the command mode is passed here.\n //\n // No `as`: it renames the module, and naming the extension the rule\n // already matches turns `Component.tsx` into `Component.tsx.tsx`, which\n // then fails to resolve. Left out, Turbopack keeps handling the loader\n // output as the TSX/JSX it still is.\n ...(extractorLoader\n ? Object.fromEntries(\n (isGteNext16\n ? EXTRACTOR_LOADER_EXTENSIONS\n : TURBOPACK_ALWAYS_SAFE_EXTENSIONS\n ).map((extension) => [\n `*.${extension}`,\n {\n loaders: [\n {\n loader: extractorLoader.loaderPath,\n options: { mode: extractorLoader.mode },\n },\n ],\n ...(isGteNext16\n ? { condition: TURBOPACK_PROJECT_FILES_CONDITION }\n : {}),\n },\n ])\n )\n : {}),\n },\n };\n\n const serverExternalPackages = [\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n 'recast',\n '@intlayer/engine',\n '@intlayer/webpack',\n ];\n\n let env: Record<string, string> = {};\n\n if (isBuildCommand) {\n const dictionaries = getDictionaries(intlayerConfig);\n\n if (Object.keys(dictionaries).length === 0) {\n appLogger('No dictionaries found. Please check your configuration.', {\n isVerbose: true,\n });\n }\n\n const unusedNodeTypes = getUnusedNodeTypes(dictionaries);\n\n if (unusedNodeTypes && unusedNodeTypes.length > 0) {\n appLogger(\n [\n 'Filtering out unused logic:',\n unusedNodeTypes\n .filter(\n (key) => !['reactNode', 'solidNode', 'preactNode'].includes(key)\n )\n .map((key) => colorize(key, ANSIColors.BLUE))\n .join(', '),\n ],\n {\n isVerbose: true,\n }\n );\n }\n\n env = {\n ...env,\n\n // Tree shacking based on unused node types\n ...formatNodeTypeToEnvVar(unusedNodeTypes),\n\n // Selects the local `nest()` resolver, which reads the nest targets\n // attached to each dictionary by the optimize transform instead of the\n // registry that transform empties.\n ...formatOptimizedNestingEnvVar(intlayerConfig.build.optimize !== false),\n\n // Tree shacking the dictionary selector logic\n // (collections / variants)\n ...formatDictionarySelectorEnvVar(getHasDictionarySelector(dictionaries)),\n\n // Tree shacking based on config\n ...getConfigEnvVars(intlayerConfig),\n };\n }\n\n const getNewConfig = (): Partial<NextConfig> => {\n let config: Partial<NextConfig> = {\n env,\n };\n\n if (isGteNext15) {\n config = {\n ...config,\n serverExternalPackages,\n };\n }\n\n if (isGteNext13 && !isGteNext15) {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n serverComponentsExternalPackages: serverExternalPackages,\n },\n };\n }\n\n if (isTurbopackEnabled) {\n if (isGteNext15 && isTurbopackStable) {\n config = {\n ...config,\n turbopack: turboConfig,\n };\n } else {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n // @ts-ignore exist in next@14\n turbo: turboConfig,\n },\n };\n }\n } else {\n config = {\n ...config,\n webpack: (config: WebpackParams['0'], options: WebpackParams[1]) => {\n // Only add Intlayer plugin on server side (node runtime)\n const { isServer, nextRuntime } = options;\n\n // If the user has defined their own webpack config, call it\n if (typeof nextConfig.webpack === 'function') {\n config = nextConfig.webpack(config, options);\n }\n\n // Rspack set external as false by default\n // Overwrite it to allow pushing the desired externals\n if (config.externals === false) {\n config.externals = [];\n }\n\n // Mark server-only modules as externals (function form handles subpaths)\n const externalExact = new Set([\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n 'recast',\n ]);\n const externalPrefixes = ['@intlayer/engine', '@intlayer/webpack'];\n config.externals.push(\n (\n { request }: { request?: string },\n callback: (err: Error | null, result?: string) => void\n ) => {\n if (\n request &&\n (externalExact.has(request) ||\n externalPrefixes.some(\n (prefix) =>\n request === prefix || request.startsWith(`${prefix}/`)\n ))\n ) {\n return callback(null, `commonjs ${request}`);\n }\n callback(null);\n }\n );\n\n // Use `node-loader` for any `.node` files\n config.module.rules.push({\n test: /\\.node$/,\n loader: 'node-loader',\n });\n\n // `enforce: 'pre'` puts the extraction ahead of `next-swc-loader`,\n // so the loader reads the original JSX rather than its compiled\n // output. Declaring it here (instead of in a `babel.config.js`)\n // keeps Next.js on SWC, and with it the `@intlayer/swc` optimize\n // pass a Babel config would silently disable.\n if (extractorLoader) {\n config.module.rules.push({\n test: new RegExp(\n `\\\\.(${EXTRACTOR_LOADER_EXTENSIONS.join('|')})$`\n ),\n exclude: /node_modules/,\n enforce: 'pre',\n use: [\n {\n loader: extractorLoader.loaderPath,\n options: { mode: extractorLoader.mode },\n },\n ],\n });\n }\n\n // Always alias on the server (node/edge) for stability.\n // On the client, alias only when not using live sync.\n config.resolve.alias = {\n ...config.resolve.alias,\n ...getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n };\n\n // Activate watch mode webpack plugin\n if (isDevCommand && isServer && nextRuntime === 'nodejs') {\n // Optional as rspack not support plugin yet\n config.plugins.push(new IntlayerPlugin(intlayerConfig));\n }\n\n return config;\n },\n };\n }\n\n return config;\n };\n\n const pruneConfig: Partial<NextConfig> = getPruneConfig({\n intlayerConfig,\n isBuildCommand,\n isTurbopackEnabled: isTurbopackEnabled ?? false,\n isDevCommand,\n isGteNext13,\n isSwcPluginSupported,\n nextVersion,\n compatCallers: configOptions?.compatCallers,\n fieldRenameMap: configOptions?.fieldRenameMap,\n });\n\n const intlayerNextConfig: Partial<NextConfig> = defu(\n getNewConfig(),\n pruneConfig\n );\n\n // Merge the new config with the user's config\n const result = defu(intlayerNextConfig, nextConfig) as NextConfig & T;\n\n return result;\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n *\n * > Node withIntlayer is a promise function. Use withIntlayerSync instead if you want to use it synchronously.\n * > Using the promise allows to prepare the intlayer dictionaries before the build starts.\n *\n */\nexport const withIntlayer = async <T extends NextConfig | Partial<NextConfig>>(\n nextConfig: T | Promise<T> = {} as T,\n configOptions?: WithIntlayerOptions\n): Promise<NextConfig & T> => {\n const { isBuildCommand, isDevCommand, isStartCommand } = getCommandsEvent();\n\n process.env.INTLAYER_IS_DEV_COMMAND = isDevCommand ? 'true' : 'false';\n\n const resolvedConfigOptions = resolveConfigOptions(configOptions);\n\n const intlayerConfig = getConfiguration(resolvedConfigOptions);\n\n const { mode } = intlayerConfig.build;\n\n // Only call prepareIntlayer during `dev` or `build` (not during `start`)\n // If prod: clean and rebuild once\n // If dev: rebuild only once if it's more than 1 hour since last rebuild\n if (!isStartCommand && (isDevCommand || isBuildCommand || mode === 'auto')) {\n // prepareIntlayer use runOnce to ensure to run only once because will run twice on client and server side otherwise\n await prepareIntlayer(intlayerConfig, {\n clean: isBuildCommand,\n cacheTimeoutMs: isBuildCommand\n ? 1000 * 30 // 30 seconds for build (to ensure to rebuild all dictionaries)\n : 1000 * 60 * 60, // 1 hour for dev (default cache timeout)\n env: isBuildCommand ? 'prod' : 'dev',\n });\n }\n\n // Remove unused content fields and rename the remaining ones to short\n // aliases, then hand the rename tables to `withIntlayerSync` so the SWC\n // plugin rewrites the matching source accesses. Only meaningful for a\n // production build — the optimize pipeline is off during `next dev`.\n //\n // `isSwcPluginUsable` gates the dictionary rewrite on the plugin actually\n // running: it is the only half that fixes up the source, so minifying without\n // it would leave the code reading field names the dictionaries no longer have.\n const { isSwcPluginSupported } = getNextVersionFlags(intlayerConfig);\n\n const fieldRenameMap = isBuildCommand\n ? await prepareSwcOptimization(intlayerConfig, {\n configOptions: resolvedConfigOptions,\n compatCallers: configOptions?.compatCallers,\n isSwcPluginUsable:\n isSwcPluginSupported && getIsSwcPluginAvailable(intlayerConfig),\n })\n : {};\n\n const nextConfigResolved = await nextConfig;\n\n return withIntlayerSync(nextConfigResolved, {\n ...resolvedConfigOptions,\n fieldRenameMap,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAM,uBAAuB,mBAAmC;CAC9D,IAAI,cAAcA,0BAAgB;CAElC,IAAI;EAIF,eAFE,eAAe,OAAO,eAAWC,0CAAkB,EAC1B,CAAC,mBACZ,CAAC,CAAC;CACpB,QAAQ,CAER;CAEA,OAAO;EACL;EACA,iBAAaC,wCAAgB,aAAa,KAAK,QAAQ;EACvD,iBAAaA,wCAAgB,aAAa,KAAK,QAAQ;EACvD,iBAAaA,wCAAgB,aAAa,KAAK,QAAQ;EACvD,uBAAmBA,wCAAgB,aAAa,KAAK,QAAQ;;;;;EAK7D,sBAAsBC,8DAAwB,WAAW;CAC3D;AACF;AAGA,MAAM,2BAA2B,mBAAmC;CAClE,IAAI;EAGF,CADE,eAAe,OAAO,eAAWF,0CAAkB,EACtC,CAAC,QAAQ,eAAe;EACvC,OAAO;CACT,SAAS,IAAI;EACX,OAAO;CACT;AACF;AAGA,MAAM,oCAAoC,mBAAmC;CAC3E,IAAI;EAGF,CADE,eAAe,OAAO,eAAWA,0CAAkB,EACtC,CAAC,QAAQ,i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AACd;;;;;;;;;;;;;;;;AAiBA,MAAa,eAAe,OAC1B,aAA6B,CAAC,GAC9B,kBAC4B;CAC5B,MAAM,EAAE,gBAAgB,cAAc,mBAAmB,iBAAiB;CAE1E,QAAQ,IAAI,0BAA0B,eAAe,SAAS;CAE9D,MAAM,wBAAwB,qBAAqB,aAAa;CAEhE,MAAM,qBAAiBT,wCAAiB,qBAAqB;CAE7D,MAAM,EAAE,SAAS,eAAe;CAKhC,IAAI,CAAC,mBAAmB,gBAAgB,kBAAkB,SAAS,SAEjE,UAAMU,wCAAgB,gBAAgB;EACpC,OAAO;EACP,gBAAgB,iBACZ,MACA;EACJ,KAAK,iBAAiB,SAAS;CACjC,CAAC;CAWH,MAAM,EAAE,yBAAyB,oBAAoB,cAAc;CAEnE,MAAM,iBAAiB,iBACnB,MAAMC,6DAAuB,gBAAgB;EAC3C,eAAe;EACf,eAAe,eAAe;EAC9B,mBACE,wBAAwB,wBAAwB,cAAc;CAClE,CAAC,IACD,CAAC;CAEL,MAAM,qBAAqB,MAAM;CAEjC,OAAO,iBAAiB,oBAAoB;EAC1C,GAAG;EACH;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"withIntlayer.cjs","names":["nextPackageJSON","getProjectRequire","compareVersions","getIsSwcPluginSupported","normalizePath","relative","COMPILER_ENABLED","getAppLogger","join","colorize","ANSIColors","MINIMUM_SWC_PLUGIN_NEXT_VERSION","IMPORT_MODE","getIsPurgePipelineAvailable","buildComponentFilesList","getDictionaries","getNestedDictionaryGraph","toSwcExtraCallers","resolveSwcLogLevel","getConfiguration","getAlias","getUnusedNodeTypes","formatNodeTypeToEnvVar","formatOptimizedNestingEnvVar","formatDictionarySelectorEnvVar","getHasDictionarySelector","getConfigEnvVars","resolve","prepareIntlayer","prepareSwcOptimization"],"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { join, relative, resolve } from 'node:path';\nimport {\n type CallerDescriptor,\n toSwcExtraCallers,\n} from '@intlayer/config/callers';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { COMPILER_ENABLED, IMPORT_MODE } from '@intlayer/config/defaultValues';\nimport {\n formatDictionarySelectorEnvVar,\n formatNodeTypeToEnvVar,\n formatOptimizedNestingEnvVar,\n getConfigEnvVars,\n} from '@intlayer/config/envVars';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport {\n compareVersions,\n getAlias,\n getHasDictionarySelector,\n getProjectRequire,\n getUnusedNodeTypes,\n normalizePath,\n} from '@intlayer/config/utils';\nimport { getNestedDictionaryGraph } from '@intlayer/core/dictionaryManipulator';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { prepareIntlayer } from '@intlayer/engine/build';\nimport { logConfigDetails } from '@intlayer/engine/cli';\nimport { buildComponentFilesList, runOnce } from '@intlayer/engine/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { defu } from 'defu';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport nextPackageJSON from 'next/package.json' with { type: 'json' };\nimport {\n type FieldRenameMapByDictionaryKey,\n getIsPurgePipelineAvailable,\n prepareSwcOptimization,\n resolveSwcLogLevel,\n} from './prepareSwcOptimization';\nimport { startContentWatcher } from './startContentWatcher';\nimport {\n getIsSwcPluginSupported,\n MINIMUM_SWC_PLUGIN_NEXT_VERSION,\n} from './swcPluginCompatibility';\n\nexport {\n getIsSwcPluginSupported,\n MINIMUM_SWC_PLUGIN_NEXT_VERSION,\n} from './swcPluginCompatibility';\n\n/**\n * Resolve the Next.js version from the *user's* project at runtime.\n * A static `import from 'next/package.json'` would resolve relative to\n * next-intlayer's own node_modules, which may differ in a monorepo.\n */\nconst getNextVersionFlags = (intlayerConfig: IntlayerConfig) => {\n let nextVersion = nextPackageJSON.version;\n\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n const pkg = requireFunction('next/package.json') as { version: string };\n nextVersion = pkg.version;\n } catch {\n // keep default\n }\n\n return {\n nextVersion,\n isGteNext13: compareVersions(nextVersion, '≥', '13.0.0'),\n isGteNext15: compareVersions(nextVersion, '≥', '15.0.0'),\n isGteNext16: compareVersions(nextVersion, '≥', '16.0.0'),\n isTurbopackStable: compareVersions(nextVersion, '≥', '15.3.0'),\n /**\n * Whether this Next.js release can load the `@intlayer/swc` Wasm plugin.\n * See {@link MINIMUM_SWC_PLUGIN_NEXT_VERSION}.\n */\n isSwcPluginSupported: getIsSwcPluginSupported(nextVersion),\n };\n};\n\n// Check if SWC plugin is available\nconst getIsSwcPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/swc');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\n// Check if Babel plugin is available\nconst getIsBabelExtractPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/babel');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\nconst resolvePluginPath = (\n pluginPath: string,\n intlayerConfig: IntlayerConfig,\n isTurbopackEnabled: boolean\n): string => {\n const requireFunction = intlayerConfig.build?.require ?? getProjectRequire();\n const pluginPathResolved = requireFunction?.resolve(pluginPath);\n\n if (isTurbopackEnabled)\n // Relative path for turbopack\n return normalizePath(`./${relative(process.cwd(), pluginPathResolved)}`);\n\n // Absolute path for webpack\n return pluginPathResolved;\n};\n\n/**\n * Extensions the extraction loader is registered for.\n *\n * The compiler reads its content out of JSX — element text and the\n * translatable attributes — so a file with no JSX in it has nothing to give,\n * and `*.ts` is left out. `*.js` is in because a plain-JavaScript Next.js app\n * writes its components there.\n */\nconst EXTRACTOR_LOADER_EXTENSIONS = ['tsx', 'jsx', 'js'] as const;\n\n/**\n * The subset safe to register as a Turbopack rule on any Next.js version.\n *\n * Turbopack rules match every module it processes, dependencies included, and\n * only Next.js 16 can express \"skip `node_modules`\" (see\n * {@link TURBOPACK_PROJECT_FILES_CONDITION}). Below that, `*.js` would hand\n * every dependency file to a Node loader worker, so it is left out rather than\n * made to cost a cold dev start.\n */\nconst TURBOPACK_ALWAYS_SAFE_EXTENSIONS = ['tsx', 'jsx'] as const;\n\n/**\n * Restricts a Turbopack rule to the project's own files. `foreign` is\n * Turbopack's builtin condition for a module inside `node_modules`.\n *\n * Only understood from Next.js 16 on — earlier releases carry no `condition`\n * field on a rule at all.\n */\nconst TURBOPACK_PROJECT_FILES_CONDITION = { not: 'foreign' } as const;\n\n/** Mode reported to the extraction loader, which cannot read the command. */\ntype ExtractorLoaderMode = 'dev' | 'build';\n\n/**\n * Whether the Intlayer compiler should extract content for this command.\n *\n * Mirrors `getExtractPluginOptions`, which the loader re-evaluates on its side:\n * this is only about not registering a loader that would do nothing.\n */\nconst getIsCompilerEnabled = (\n intlayerConfig: IntlayerConfig,\n isDevCommand: boolean\n): boolean => {\n const enabled = intlayerConfig.compiler?.enabled ?? COMPILER_ENABLED;\n\n if (enabled === 'build-only') return !isDevCommand;\n\n return enabled !== false;\n};\n\n/**\n * Describes the extraction loader for both bundlers, or `null` when the\n * compiler is off or `@intlayer/babel` is not installed.\n *\n * The loader replaces the `babel.config.js` the compiler used to need on\n * Next.js: Turbopack never reads a Babel config, and on webpack the mere\n * presence of one opts the whole project out of SWC — including the\n * `@intlayer/swc` optimize pass.\n */\nconst getExtractorLoader = (\n intlayerConfig: IntlayerConfig,\n isTurbopackEnabled: boolean,\n isDevCommand: boolean\n): { loaderPath: string; mode: ExtractorLoaderMode } | null => {\n if (!getIsCompilerEnabled(intlayerConfig, isDevCommand)) return null;\n if (!getIsBabelExtractPluginAvailable(intlayerConfig)) return null;\n\n try {\n return {\n loaderPath: resolvePluginPath(\n 'next-intlayer/extractor-loader',\n intlayerConfig,\n isTurbopackEnabled\n ),\n mode: isDevCommand ? 'dev' : 'build',\n };\n } catch {\n // An installed `next-intlayer` that cannot resolve its own subpath means a\n // version predating the loader — the Babel setup still applies there.\n return null;\n }\n};\n\ntype GetPruneConfigParams = {\n intlayerConfig: IntlayerConfig;\n isBuildCommand: boolean;\n isTurbopackEnabled: boolean;\n isDevCommand: boolean;\n isGteNext13: boolean;\n /** Whether the resolved Next.js version can load the Wasm plugin. */\n isSwcPluginSupported: boolean;\n /** Resolved Next.js version, reported when the plugin has to stand down. */\n nextVersion: string;\n compatCallers?: CallerDescriptor[];\n fieldRenameMap?: FieldRenameMapByDictionaryKey;\n};\n\nconst getPruneConfig = ({\n intlayerConfig,\n isBuildCommand,\n isTurbopackEnabled,\n isDevCommand,\n isGteNext13,\n isSwcPluginSupported,\n nextVersion,\n compatCallers,\n fieldRenameMap,\n}: GetPruneConfigParams): Partial<NextConfig> => {\n const { optimize, minify, purge } = intlayerConfig.build;\n const importMode =\n intlayerConfig.build.importMode ?? intlayerConfig.dictionary?.importMode;\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n } = intlayerConfig.system;\n const { baseDir } = intlayerConfig.system;\n const logger = getAppLogger(intlayerConfig);\n\n if (optimize === false) {\n return {};\n }\n if (optimize === undefined && !isBuildCommand) {\n return {};\n }\n\n if (!isGteNext13) return {};\n\n const isSwcPluginAvailable = getIsSwcPluginAvailable(intlayerConfig);\n\n runOnce(\n join(baseDir, '.intlayer', 'cache', 'intlayer-prune-plugin-enabled.lock'),\n () => {\n if (isSwcPluginAvailable && !isSwcPluginSupported) {\n logger(\n [\n `Build optimization ${colorize('disabled', ANSIColors.GREY_DARK)}:`,\n colorize('@intlayer/swc', ANSIColors.GREY_LIGHT),\n colorize(\n `cannot run on Next.js ${nextVersion} — its bundled SWC predates the`,\n ANSIColors.GREY\n ),\n colorize(\n 'stable Wasm plugin ABI. Upgrade to Next.js',\n ANSIColors.GREY\n ),\n colorize(MINIMUM_SWC_PLUGIN_NEXT_VERSION, ANSIColors.BLUE),\n colorize('or later to enable it.', ANSIColors.GREY),\n ],\n { level: 'warn' }\n );\n } else if (isSwcPluginAvailable) {\n logger([\n `Build optimization ${colorize('enabled', ANSIColors.GREEN)}`,\n colorize(`(import mode:`, ANSIColors.GREY_DARK),\n colorize(importMode ?? IMPORT_MODE, ANSIColors.BLUE),\n colorize(`)`, ANSIColors.GREY_DARK),\n ]);\n\n // The purge / minify pipeline stands down — with its own explanation —\n // when `@intlayer/babel` (which runs it) is not resolvable. The editor\n // only stands the field-rename step down, not the pipeline.\n const isPurgePipelineEnabled =\n getIsPurgePipelineAvailable(intlayerConfig);\n\n // The purge pipeline reports the field-rename step standing down when\n // the editor is enabled, so this line stays a plain one.\n if (isPurgePipelineEnabled && minify) {\n logger(\n `Dictionary minification ${colorize('enabled', ANSIColors.GREEN)}`\n );\n }\n\n if (isPurgePipelineEnabled && purge) {\n logger(\n `Dictionary purge unused keys ${colorize('enabled', ANSIColors.GREEN)}`\n );\n }\n } else {\n logger([\n colorize('Recommended: Install', ANSIColors.GREY),\n colorize('@intlayer/swc', ANSIColors.GREY_LIGHT),\n colorize(\n 'package to enable build optimization. See documentation:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://intlayer.org/docs/bundle-optimization',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n runOnce(\n join(\n baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-compiler-plugin-enabled.lock'\n ),\n () => {\n const isBabelExtractPluginAvailable =\n getIsBabelExtractPluginAvailable(intlayerConfig);\n\n if (isBabelExtractPluginAvailable) {\n let isEnabled = intlayerConfig.compiler?.enabled ?? true;\n\n if (isEnabled === 'build-only') {\n isEnabled = !isDevCommand;\n }\n\n // Only the enabled state is reported: disabling the compiler is an\n // explicit configuration choice, so announcing it on every build adds\n // noise without telling the user anything they did not ask for.\n if (isEnabled) {\n logger('Intlayer compiler enabled');\n }\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n // Registering the plugin on a host that cannot load it is not a degraded\n // build but a failed one: SWC aborts with `failed to invoke plugin`. Standing\n // down leaves the app running off the runtime dictionary registry, which the\n // transform would otherwise have emptied.\n if (!isSwcPluginAvailable || !isSwcPluginSupported) {\n return {};\n }\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n\n const unmergedDictionariesEntryPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n\n const fetchDictionariesEntryPath = join(mainDir, 'fetch_dictionaries.mjs');\n\n const filesListPattern = buildComponentFilesList(intlayerConfig);\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n ];\n\n const dictionaries = getDictionaries(intlayerConfig);\n\n const dictionaryModeMap: Record<string, 'static' | 'dynamic' | 'fetch'> = {};\n\n (Object.values(dictionaries) as Dictionary[]).forEach((dictionary) => {\n dictionaryModeMap[dictionary.key] =\n dictionary.importMode ?? importMode ?? IMPORT_MODE;\n });\n\n // Dictionaries holding `nest()` references: their static import is re-pointed\n // at the companion module carrying the nest targets.\n const nestingDictionaryKeys = [\n ...getNestedDictionaryGraph(Object.values(dictionaries)).keys(),\n ];\n\n return {\n experimental: {\n swcPlugins: [\n [\n resolvePluginPath(\n '@intlayer/swc',\n intlayerConfig,\n isTurbopackEnabled\n ),\n {\n dictionariesDir,\n dictionariesEntryPath,\n unmergedDictionariesEntryPath,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n fetchDictionariesDir,\n fetchDictionariesEntryPath,\n importMode,\n filesList,\n replaceDictionaryEntry: true,\n nestingDictionaryKeys,\n dictionaryModeMap,\n // Compat adapters reach the Wasm plugin as descriptors serialised\n // to its wire format; with none injected the option is empty and\n // the plugin runs the base intlayer rewrite alone.\n extraCallers: toSwcExtraCallers(compatCallers ?? []),\n // Rewrites `content.title` → `content.a` to match the compiled\n // dictionaries the `build.minify` pass already renamed.\n fieldRenameMap: fieldRenameMap ?? {},\n logLevel: resolveSwcLogLevel(intlayerConfig),\n },\n ],\n ],\n },\n };\n};\n\nconst getCommandsEvent = () => {\n const lifecycleEvent = process.env['npm_lifecycle_event'];\n const lifecycleScript = process.env['npm_lifecycle_script'] ?? '';\n\n const isDevCommand =\n lifecycleEvent === 'dev' ||\n process.argv.some((arg) => arg === 'dev') ||\n /(^|\\s)(next\\s+)?dev(\\s|$)/.test(lifecycleScript);\n\n const isBuildCommand =\n lifecycleEvent === 'build' ||\n process.argv.some((arg) => arg === 'build') ||\n /(^|\\s)(next\\s+)?build(\\s|$)/.test(lifecycleScript);\n\n const isStartCommand =\n lifecycleEvent === 'start' ||\n process.argv.some((arg) => arg === 'start') ||\n /(^|\\s)(next\\s+)?start(\\s|$)/.test(lifecycleScript);\n\n return {\n isDevCommand,\n isBuildCommand,\n isStartCommand,\n };\n};\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\ntype WithIntlayerOptions = GetConfigurationOptions & {\n enableTurbopack?: boolean;\n /**\n * Compat-adapter caller descriptors injected by a compat package's bundler\n * plugin (e.g. `@intlayer/next-intl/plugin`). They drive both the SWC\n * optimize rewrite and the Node-side usage analysis, so one registry slice\n * is all a compat plugin has to pass.\n */\n compatCallers?: CallerDescriptor[];\n\n /**\n * Field-rename tables produced by the purge / minify pipeline, forwarded to\n * the `@intlayer/swc` plugin so it rewrites source accesses to match the\n * renamed dictionaries.\n *\n * @internal Set by {@link withIntlayer}; `withIntlayerSync` on its own runs\n * no dictionary rewrite, so it leaves this unset and no rename is applied.\n */\n fieldRenameMap?: FieldRenameMapByDictionaryKey;\n};\n\n/**\n * Pin the env file used to resolve the Intlayer configuration to the Next.js\n * command being run (`dev` → `development`, `build`/`start` → `production`).\n *\n * Next.js loads the config file in several processes during a single command\n * (the main `build` process plus one or more Turbopack/webpack workers), and\n * `process.env.NODE_ENV` is not guaranteed to hold the same value in all of\n * them. Since `getConfiguration` falls back to `NODE_ENV` to pick its env file\n * (`.env.development.local` vs `.env.production.local`), those processes could\n * otherwise resolve *different* env values (e.g. `applicationURL`,\n * `INTLAYER_CLIENT_ID`). The resulting configuration would differ between\n * processes, defeating the `isCachedConfigurationUpToDate` check and forcing a\n * redundant full dictionary rebuild.\n *\n * Passing an explicit `env` keeps configuration resolution deterministic across\n * every process of the command. An `env` already set by the caller is\n * respected, and when the command cannot be determined we fall back to\n * `getConfiguration`'s own default (i.e. leave `env` unset).\n */\nconst resolveConfigOptions = (\n configOptions?: WithIntlayerOptions\n): WithIntlayerOptions | undefined => {\n // Respect an explicit override from the caller (idempotent on re-entry).\n if (configOptions?.env) return configOptions;\n\n const { isDevCommand, isBuildCommand, isStartCommand } = getCommandsEvent();\n\n const env = isDevCommand\n ? 'development'\n : isBuildCommand || isStartCommand\n ? 'production'\n : undefined;\n\n if (!env) return configOptions;\n\n return {\n ...configOptions,\n env,\n };\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayerSync(nextConfig)\n * ```\n */\nexport const withIntlayerSync = <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T,\n configOptions?: WithIntlayerOptions\n): NextConfig & T => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const resolvedConfigOptions = resolveConfigOptions(configOptions);\n\n const intlayerConfig = getConfiguration(resolvedConfigOptions);\n\n logConfigDetails(resolvedConfigOptions);\n\n const appLogger = getAppLogger(intlayerConfig);\n\n const {\n nextVersion,\n isGteNext13,\n isGteNext15,\n isGteNext16,\n isTurbopackStable,\n isSwcPluginSupported,\n } = getNextVersionFlags(intlayerConfig);\n\n const isTurbopackEnabledFromCommand = isGteNext16\n ? // Next@16 enables turbopack by default; disable with --webpack\n !process.env['npm_lifecycle_script']?.includes('--webpack')\n : // Next@15 uses --turbopack, Next@14 uses --turbo\n process.env['npm_lifecycle_script']?.includes('--turbo');\n\n const isTurbopackEnabled =\n configOptions?.enableTurbopack ?? isTurbopackEnabledFromCommand;\n\n if (isTurbopackEnabled && typeof nextConfig.webpack !== 'undefined') {\n appLogger(\n 'Turbopack is enabled but a custom webpack config is present. It will be ignored.'\n );\n }\n\n const { isBuildCommand, isDevCommand } = getCommandsEvent();\n\n const extractorLoader = getExtractorLoader(\n intlayerConfig,\n isTurbopackEnabled ?? false,\n isDevCommand\n );\n\n // Watches on both bundlers: Turbopack cannot run a webpack plugin, and on\n // webpack this replaces `IntlayerPlugin`, whose watcher took no ownership\n // lock and so kept rebuilding alongside a parallel `intlayer watch`.\n if (isDevCommand) {\n startContentWatcher(intlayerConfig);\n }\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => `./${value}`, // prefix by './' to consider the path as relative to the project root. This is necessary for turbopack to work correctly.\n }),\n\n rules: {\n '*.node': {\n as: '*.node',\n loaders: ['node-loader'],\n },\n\n // Turbopack serialises loader options to JSON, so the loader reads the\n // Intlayer configuration itself and only the command mode is passed here.\n //\n // No `as`: it renames the module, and naming the extension the rule\n // already matches turns `Component.tsx` into `Component.tsx.tsx`, which\n // then fails to resolve. Left out, Turbopack keeps handling the loader\n // output as the TSX/JSX it still is.\n ...(extractorLoader\n ? Object.fromEntries(\n (isGteNext16\n ? EXTRACTOR_LOADER_EXTENSIONS\n : TURBOPACK_ALWAYS_SAFE_EXTENSIONS\n ).map((extension) => [\n `*.${extension}`,\n {\n loaders: [\n {\n loader: extractorLoader.loaderPath,\n options: { mode: extractorLoader.mode },\n },\n ],\n ...(isGteNext16\n ? { condition: TURBOPACK_PROJECT_FILES_CONDITION }\n : {}),\n },\n ])\n )\n : {}),\n },\n };\n\n const serverExternalPackages = [\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n 'recast',\n '@intlayer/engine',\n '@intlayer/webpack',\n ];\n\n let env: Record<string, string> = {};\n\n if (isBuildCommand) {\n const dictionaries = getDictionaries(intlayerConfig);\n\n if (Object.keys(dictionaries).length === 0) {\n appLogger('No dictionaries found. Please check your configuration.', {\n isVerbose: true,\n });\n }\n\n const unusedNodeTypes = getUnusedNodeTypes(dictionaries);\n\n if (unusedNodeTypes && unusedNodeTypes.length > 0) {\n appLogger(\n [\n 'Filtering out unused logic:',\n unusedNodeTypes\n .filter(\n (key) => !['reactNode', 'solidNode', 'preactNode'].includes(key)\n )\n .map((key) => colorize(key, ANSIColors.BLUE))\n .join(', '),\n ],\n {\n isVerbose: true,\n }\n );\n }\n\n env = {\n ...env,\n\n // Tree shacking based on unused node types\n ...formatNodeTypeToEnvVar(unusedNodeTypes),\n\n // Selects the local `nest()` resolver, which reads the nest targets\n // attached to each dictionary by the optimize transform instead of the\n // registry that transform empties.\n ...formatOptimizedNestingEnvVar(intlayerConfig.build.optimize !== false),\n\n // Tree shacking the dictionary selector logic\n // (collections / variants)\n ...formatDictionarySelectorEnvVar(getHasDictionarySelector(dictionaries)),\n\n // Tree shacking based on config\n ...getConfigEnvVars(intlayerConfig),\n };\n }\n\n const getNewConfig = (): Partial<NextConfig> => {\n let config: Partial<NextConfig> = {\n env,\n };\n\n if (isGteNext15) {\n config = {\n ...config,\n serverExternalPackages,\n };\n }\n\n if (isGteNext13 && !isGteNext15) {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n serverComponentsExternalPackages: serverExternalPackages,\n },\n };\n }\n\n if (isTurbopackEnabled) {\n if (isGteNext15 && isTurbopackStable) {\n config = {\n ...config,\n turbopack: turboConfig,\n };\n } else {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n // @ts-ignore exist in next@14\n turbo: turboConfig,\n },\n };\n }\n } else {\n config = {\n ...config,\n webpack: (config: WebpackParams['0'], options: WebpackParams[1]) => {\n // If the user has defined their own webpack config, call it\n if (typeof nextConfig.webpack === 'function') {\n config = nextConfig.webpack(config, options);\n }\n\n // Rspack set external as false by default\n // Overwrite it to allow pushing the desired externals\n if (config.externals === false) {\n config.externals = [];\n }\n\n // Mark server-only modules as externals (function form handles subpaths)\n const externalExact = new Set([\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n 'recast',\n ]);\n const externalPrefixes = ['@intlayer/engine', '@intlayer/webpack'];\n config.externals.push(\n (\n { request }: { request?: string },\n callback: (err: Error | null, result?: string) => void\n ) => {\n if (\n request &&\n (externalExact.has(request) ||\n externalPrefixes.some(\n (prefix) =>\n request === prefix || request.startsWith(`${prefix}/`)\n ))\n ) {\n return callback(null, `commonjs ${request}`);\n }\n callback(null);\n }\n );\n\n // Use `node-loader` for any `.node` files\n config.module.rules.push({\n test: /\\.node$/,\n loader: 'node-loader',\n });\n\n // `enforce: 'pre'` puts the extraction ahead of `next-swc-loader`,\n // so the loader reads the original JSX rather than its compiled\n // output. Declaring it here (instead of in a `babel.config.js`)\n // keeps Next.js on SWC, and with it the `@intlayer/swc` optimize\n // pass a Babel config would silently disable.\n if (extractorLoader) {\n config.module.rules.push({\n test: new RegExp(\n `\\\\.(${EXTRACTOR_LOADER_EXTENSIONS.join('|')})$`\n ),\n exclude: /node_modules/,\n enforce: 'pre',\n use: [\n {\n loader: extractorLoader.loaderPath,\n options: { mode: extractorLoader.mode },\n },\n ],\n });\n }\n\n // Always alias on the server (node/edge) for stability.\n // On the client, alias only when not using live sync.\n config.resolve.alias = {\n ...config.resolve.alias,\n ...getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n };\n\n return config;\n },\n };\n }\n\n return config;\n };\n\n const pruneConfig: Partial<NextConfig> = getPruneConfig({\n intlayerConfig,\n isBuildCommand,\n isTurbopackEnabled: isTurbopackEnabled ?? false,\n isDevCommand,\n isGteNext13,\n isSwcPluginSupported,\n nextVersion,\n compatCallers: configOptions?.compatCallers,\n fieldRenameMap: configOptions?.fieldRenameMap,\n });\n\n const intlayerNextConfig: Partial<NextConfig> = defu(\n getNewConfig(),\n pruneConfig\n );\n\n // Merge the new config with the user's config\n const result = defu(intlayerNextConfig, nextConfig) as NextConfig & T;\n\n return result;\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n *\n * > Node withIntlayer is a promise function. Use withIntlayerSync instead if you want to use it synchronously.\n * > Using the promise allows to prepare the intlayer dictionaries before the build starts.\n *\n */\nexport const withIntlayer = async <T extends NextConfig | Partial<NextConfig>>(\n nextConfig: T | Promise<T> = {} as T,\n configOptions?: WithIntlayerOptions\n): Promise<NextConfig & T> => {\n const { isBuildCommand, isDevCommand, isStartCommand } = getCommandsEvent();\n\n process.env.INTLAYER_IS_DEV_COMMAND = isDevCommand ? 'true' : 'false';\n\n const resolvedConfigOptions = resolveConfigOptions(configOptions);\n\n const intlayerConfig = getConfiguration(resolvedConfigOptions);\n\n const { mode } = intlayerConfig.build;\n\n // Only call prepareIntlayer during `dev` or `build` (not during `start`)\n // If prod: clean and rebuild once\n // If dev: rebuild only once if it's more than 1 hour since last rebuild\n if (!isStartCommand && (isDevCommand || isBuildCommand || mode === 'auto')) {\n // prepareIntlayer use runOnce to ensure to run only once because will run twice on client and server side otherwise\n await prepareIntlayer(intlayerConfig, {\n clean: isBuildCommand,\n cacheTimeoutMs: isBuildCommand\n ? 1000 * 30 // 30 seconds for build (to ensure to rebuild all dictionaries)\n : 1000 * 60 * 60, // 1 hour for dev (default cache timeout)\n env: isBuildCommand ? 'prod' : 'dev',\n });\n }\n\n // Remove unused content fields and rename the remaining ones to short\n // aliases, then hand the rename tables to `withIntlayerSync` so the SWC\n // plugin rewrites the matching source accesses. Only meaningful for a\n // production build — the optimize pipeline is off during `next dev`.\n //\n // `isSwcPluginUsable` gates the dictionary rewrite on the plugin actually\n // running: it is the only half that fixes up the source, so minifying without\n // it would leave the code reading field names the dictionaries no longer have.\n const { isSwcPluginSupported } = getNextVersionFlags(intlayerConfig);\n\n const fieldRenameMap = isBuildCommand\n ? await prepareSwcOptimization(intlayerConfig, {\n configOptions: resolvedConfigOptions,\n compatCallers: configOptions?.compatCallers,\n isSwcPluginUsable:\n isSwcPluginSupported && getIsSwcPluginAvailable(intlayerConfig),\n })\n : {};\n\n const nextConfigResolved = await nextConfig;\n\n return withIntlayerSync(nextConfigResolved, {\n ...resolvedConfigOptions,\n fieldRenameMap,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAM,uBAAuB,mBAAmC;CAC9D,IAAI,cAAcA,0BAAgB;CAElC,IAAI;EAIF,eAFE,eAAe,OAAO,eAAWC,0CAAkB,EAC1B,CAAC,mBACZ,CAAC,CAAC;CACpB,QAAQ,CAER;CAEA,OAAO;EACL;EACA,iBAAaC,wCAAgB,aAAa,KAAK,QAAQ;EACvD,iBAAaA,wCAAgB,aAAa,KAAK,QAAQ;EACvD,iBAAaA,wCAAgB,aAAa,KAAK,QAAQ;EACvD,uBAAmBA,wCAAgB,aAAa,KAAK,QAAQ;;;;;EAK7D,sBAAsBC,8DAAwB,WAAW;CAC3D;AACF;AAGA,MAAM,2BAA2B,mBAAmC;CAClE,IAAI;EAGF,CADE,eAAe,OAAO,eAAWF,0CAAkB,EACtC,CAAC,QAAQ,eAAe;EACvC,OAAO;CACT,SAAS,IAAI;EACX,OAAO;CACT;AACF;AAGA,MAAM,oCAAoC,mBAAmC;CAC3E,IAAI;EAGF,CADE,eAAe,OAAO,eAAWA,0CAAkB,EACtC,CAAC,QAAQ,iBAAiB;EACzC,OAAO;CACT,SAAS,IAAI;EACX,OAAO;CACT;AACF;AAEA,MAAM,qBACJ,YACA,gBACA,uBACW;CAEX,MAAM,sBADkB,eAAe,OAAO,eAAWA,0CAAkB,EACjC,EAAE,QAAQ,UAAU;CAE9D,IAAI,oBAEF,WAAOG,sCAAc,SA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MS,wCAAgB,gBAAgB;EACpC,OAAO;EACP,gBAAgB,iBACZ,MACA;EACJ,KAAK,iBAAiB,SAAS;CACjC,CAAC;CAWH,MAAM,EAAE,yBAAyB,oBAAoB,cAAc;CAEnE,MAAM,iBAAiB,iBACnB,MAAMC,6DAAuB,gBAAgB;EAC3C,eAAe;EACf,eAAe,eAAe;EAC9B,mBACE,wBAAwB,wBAAwB,cAAc;CAClE,CAAC,IACD,CAAC;CAEL,MAAM,qBAAqB,MAAM;CAEjC,OAAO,iBAAiB,oBAAoB;EAC1C,GAAG;EACH;CACF,CAAC;AACH"}
@@ -3,15 +3,15 @@ import { usePathname } from "../client/usePathname.mjs";
3
3
  import { useLocalePageRouter } from "../client/useLocalePageRouter.mjs";
4
4
  import { useRewriteURL } from "../client/useRewriteURL.mjs";
5
5
  import { generateStaticParams } from "../generateStaticParams.mjs";
6
- import { IntlayerProvider } from "../server/IntlayerProvider.mjs";
7
6
  import { t } from "../server/t.mjs";
8
- import { useDictionary } from "../server/useDictionary.mjs";
9
- import { useDictionaryAsync } from "../server/useDictionaryAsync.mjs";
10
- import { useDictionaryDynamic } from "../server/useDictionaryDynamic.mjs";
11
7
  import { useI18n } from "../server/useI18n.mjs";
12
- import { useIntl } from "../server/useIntl.mjs";
13
8
  import { useIntlayer } from "../server/useIntlayer.mjs";
9
+ import { useDictionaryAsync } from "../server/useDictionaryAsync.mjs";
14
10
  import { useLocale } from "../server/useLocale.mjs";
11
+ import { IntlayerProvider } from "../server/IntlayerProvider.mjs";
12
+ import { useIntl } from "../server/useIntl.mjs";
13
+ import { useDictionaryDynamic } from "../server/useDictionaryDynamic.mjs";
14
+ import { useDictionary } from "../server/useDictionary.mjs";
15
15
  import { IntlayerClientContext, getDictionary, getIntlayer, localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, useLocaleCookie, useLocaleStorage } from "react-intlayer";
16
16
  import { useLoadDynamic } from "react-intlayer/server";
17
17
 
@@ -1,15 +1,15 @@
1
- import { IntlayerProvider } from "./IntlayerProvider.mjs";
2
1
  import { getLocale } from "./getLocale.mjs";
3
2
  import { t } from "./t.mjs";
4
- import { useDictionary } from "./useDictionary.mjs";
5
- import { useDictionaryAsync } from "./useDictionaryAsync.mjs";
6
- import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
3
+ import { withIntlayer, withIntlayerSync } from "./withIntlayer.mjs";
7
4
  import { useI18n } from "./useI18n.mjs";
8
- import { useIntl } from "./useIntl.mjs";
9
5
  import { useIntlayer } from "./useIntlayer.mjs";
6
+ import { useDictionaryAsync } from "./useDictionaryAsync.mjs";
10
7
  import { useLocale } from "./useLocale.mjs";
11
- import { withIntlayer, withIntlayerSync } from "./withIntlayer.mjs";
8
+ import { IntlayerProvider } from "./IntlayerProvider.mjs";
9
+ import { useIntl } from "./useIntl.mjs";
10
+ import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
12
11
  import { IntlayerServerProvider } from "./IntlayerServerProvider.mjs";
12
+ import { useDictionary } from "./useDictionary.mjs";
13
13
  import { getServerContext, locale, setLocale, setVariant, useLoadDynamic } from "react-intlayer/server";
14
14
 
15
15
  export { IntlayerProvider, IntlayerServerProvider, getLocale, getServerContext, locale, setLocale, setVariant, t, useDictionary, useDictionaryAsync, useDictionaryDynamic, useI18n, useIntl, useIntlayer, useLoadDynamic, useLocale, withIntlayer, withIntlayerSync };
@@ -3,16 +3,28 @@ import { acquireContentWatcherLock, getCliContentWatcherLabel, getContentWatcher
3
3
 
4
4
  //#region src/server/startContentWatcher.ts
5
5
  /**
6
- * Release from which `withIntlayer` watches the content declarations on
7
- * Turbopack, making `intlayer watch --with` redundant on Next.js.
8
- */
9
- const SELF_WATCHING_RELEASE = "9.5.0";
10
- /**
11
6
  * How often a process that lost the ownership race checks whether the owner is
12
7
  * gone. Next.js's short-lived config processes release the lock when they exit,
13
8
  * so the long-lived dev server has to be able to pick it up afterwards.
14
9
  */
15
10
  const TAKEOVER_POLL_INTERVAL_MS = 5e3;
11
+ /**
12
+ * Next.js helper processes that evaluate `next.config.*` without being the dev
13
+ * server, matched on their entry script.
14
+ *
15
+ * `detached-flush` is the telemetry flusher Next spawns **detached**: it loads
16
+ * the config, outlives the dev server, and — left unchecked — wins the watcher
17
+ * lock and keeps watching after Ctrl-C, while the next `next dev` finds the
18
+ * lock taken and runs with no watcher at all.
19
+ */
20
+ const NEXT_HELPER_ENTRY_SCRIPTS = ["detached-flush"];
21
+ /**
22
+ * Whether this process is a Next.js helper rather than the dev server itself.
23
+ *
24
+ * Ownership of the watcher has to follow the process the user actually stops,
25
+ * so a helper must never take it.
26
+ */
27
+ const getIsNextHelperProcess = () => process.argv.some((argument) => NEXT_HELPER_ENTRY_SCRIPTS.some((script) => argument.includes(script)));
16
28
  /** Set once the watcher is running in this process. */
17
29
  let isWatching = false;
18
30
  /**
@@ -26,16 +38,11 @@ let isClaimInFlight = false;
26
38
  /** Reports a redundant `intlayer watch` running alongside this dev server. */
27
39
  const reportRedundantCliWatcher = (configuration, cliWatcherLabel) => reportRedundantContentWatcher(configuration, {
28
40
  cliLabel: cliWatcherLabel,
29
- bundlerLabel: "next-intlayer",
30
- since: SELF_WATCHING_RELEASE
41
+ bundlerLabel: "next-intlayer"
31
42
  });
32
43
  /**
33
- * Starts the content declaration watcher for a Turbopack dev server.
34
- *
35
- * On webpack this is done by `IntlayerPlugin`, which Turbopack cannot run — so
36
- * before {@link SELF_WATCHING_RELEASE} a Turbopack app had to be started
37
- * through `intlayer watch --with next dev` for `.content` edits to rebuild
38
- * `.intlayer`.
44
+ * Starts the content declaration watcher for a Next.js dev server, on webpack
45
+ * as well as on Turbopack.
39
46
  *
40
47
  * Stands down — with an explanation — when that CLI watcher is running anyway,
41
48
  * since two watchers would rebuild the same dictionaries at the same time.
@@ -49,8 +56,7 @@ const claimAndWatch = async (configuration) => {
49
56
  const appLogger = getAppLogger(configuration);
50
57
  if (!await acquireContentWatcherLock(configuration, {
51
58
  source: "bundler",
52
- label: "next-intlayer",
53
- since: SELF_WATCHING_RELEASE
59
+ label: "next-intlayer"
54
60
  })) {
55
61
  const owner = await getContentWatcherOwner(configuration);
56
62
  if (owner?.source === "cli") {
@@ -74,6 +80,7 @@ const claimAndWatch = async (configuration) => {
74
80
  const startContentWatcher = (configuration) => {
75
81
  if (isWatching || isClaimInFlight) return;
76
82
  if (!configuration.content.watch) return;
83
+ if (getIsNextHelperProcess()) return;
77
84
  const cliWatcherLabel = getCliContentWatcherLabel();
78
85
  if (cliWatcherLabel) {
79
86
  reportRedundantCliWatcher(configuration, cliWatcherLabel);
@@ -1 +1 @@
1
- {"version":3,"file":"startContentWatcher.mjs","names":[],"sources":["../../../src/server/startContentWatcher.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config/logger';\nimport {\n acquireContentWatcherLock,\n getCliContentWatcherLabel,\n getContentWatcherOwner,\n reportRedundantContentWatcher,\n} from '@intlayer/engine/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Release from which `withIntlayer` watches the content declarations on\n * Turbopack, making `intlayer watch --with` redundant on Next.js.\n */\nconst SELF_WATCHING_RELEASE = '9.5.0';\n\n/**\n * How often a process that lost the ownership race checks whether the owner is\n * gone. Next.js's short-lived config processes release the lock when they exit,\n * so the long-lived dev server has to be able to pick it up afterwards.\n */\nconst TAKEOVER_POLL_INTERVAL_MS = 5000;\n\n/** Set once the watcher is running in this process. */\nlet isWatching = false;\n\n/**\n * Set while an ownership attempt is in flight.\n *\n * Taking the lock is asynchronous, and `next.config.*` is evaluated several\n * times per command — without this, those evaluations would pile up concurrent\n * attempts, each awaiting the same lock.\n */\nlet isClaimInFlight = false;\n\n/** Reports a redundant `intlayer watch` running alongside this dev server. */\nconst reportRedundantCliWatcher = (\n configuration: IntlayerConfig,\n cliWatcherLabel: string\n): void =>\n reportRedundantContentWatcher(configuration, {\n cliLabel: cliWatcherLabel,\n bundlerLabel: 'next-intlayer',\n since: SELF_WATCHING_RELEASE,\n });\n\n/**\n * Starts the content declaration watcher for a Turbopack dev server.\n *\n * On webpack this is done by `IntlayerPlugin`, which Turbopack cannot run — so\n * before {@link SELF_WATCHING_RELEASE} a Turbopack app had to be started\n * through `intlayer watch --with next dev` for `.content` edits to rebuild\n * `.intlayer`.\n *\n * Stands down — with an explanation — when that CLI watcher is running anyway,\n * since two watchers would rebuild the same dictionaries at the same time.\n * Otherwise starting is idempotent: the first process to take the lock watches,\n * and the others retry in the background so a short-lived config process\n * handing the lock back does not leave the session unwatched.\n *\n * @param configuration - The resolved Intlayer configuration.\n */\nconst claimAndWatch = async (configuration: IntlayerConfig): Promise<void> => {\n const appLogger = getAppLogger(configuration);\n\n const hasAcquiredLock = await acquireContentWatcherLock(configuration, {\n source: 'bundler',\n label: 'next-intlayer',\n since: SELF_WATCHING_RELEASE,\n });\n\n if (!hasAcquiredLock) {\n // A CLI watcher started from another terminal is just as redundant as one\n // wrapping this command, and worth the same explanation.\n const owner = await getContentWatcherOwner(configuration);\n\n if (owner?.source === 'cli') {\n reportRedundantCliWatcher(configuration, owner.label);\n return;\n }\n\n const retryTimer = setTimeout(() => {\n startContentWatcher(configuration);\n }, TAKEOVER_POLL_INTERVAL_MS);\n\n // Unreferenced so a process whose only remaining work is this retry can\n // still exit.\n retryTimer.unref?.();\n\n return;\n }\n\n isWatching = true;\n\n try {\n // Imported lazily: `@intlayer/engine/watcher` pulls in `@parcel/watcher`, a\n // native module that has no business being loaded during a production\n // build. `withIntlayer` already awaited `prepareIntlayer`, so the watcher\n // only has to pick up the changes that follow.\n const { watch } = await import('@intlayer/engine/watcher');\n\n await watch({ configuration });\n } catch (error) {\n isWatching = false;\n\n appLogger(['Failed to watch Intlayer content declarations:', error], {\n level: 'error',\n });\n }\n};\n\nexport const startContentWatcher = (configuration: IntlayerConfig): void => {\n if (isWatching || isClaimInFlight) return;\n if (!configuration.content.watch) return;\n\n // Spawned by `intlayer watch --with`: the CLI watcher covers the project, and\n // this is known from the environment alone — no need to touch the lock.\n const cliWatcherLabel = getCliContentWatcherLabel();\n\n if (cliWatcherLabel) {\n reportRedundantCliWatcher(configuration, cliWatcherLabel);\n return;\n }\n\n isClaimInFlight = true;\n\n // Deliberately not awaited: `withIntlayerSync` is synchronous, and the dev\n // server must not wait on the watcher to start serving.\n claimAndWatch(configuration).finally(() => {\n isClaimInFlight = false;\n });\n};\n"],"mappings":";;;;;;;;AAaA,MAAM,wBAAwB;;;;;;AAO9B,MAAM,4BAA4B;;AAGlC,IAAI,aAAa;;;;;;;;AASjB,IAAI,kBAAkB;;AAGtB,MAAM,6BACJ,eACA,oBAEA,8BAA8B,eAAe;CAC3C,UAAU;CACV,cAAc;CACd,OAAO;AACT,CAAC;;;;;;;;;;;;;;;;;AAkBH,MAAM,gBAAgB,OAAO,kBAAiD;CAC5E,MAAM,YAAY,aAAa,aAAa;CAQ5C,IAAI,CAAC,MANyB,0BAA0B,eAAe;EACrE,QAAQ;EACR,OAAO;EACP,OAAO;CACT,CAAC,GAEqB;EAGpB,MAAM,QAAQ,MAAM,uBAAuB,aAAa;EAExD,IAAI,OAAO,WAAW,OAAO;GAC3B,0BAA0B,eAAe,MAAM,KAAK;GACpD;EACF;EAQA,AANmB,iBAAiB;GAClC,oBAAoB,aAAa;EACnC,GAAG,yBAIM,CAAC,CAAC,QAAQ;EAEnB;CACF;CAEA,aAAa;CAEb,IAAI;EAKF,MAAM,EAAE,UAAU,MAAM,OAAO;EAE/B,MAAM,MAAM,EAAE,cAAc,CAAC;CAC/B,SAAS,OAAO;EACd,aAAa;EAEb,UAAU,CAAC,kDAAkD,KAAK,GAAG,EACnE,OAAO,QACT,CAAC;CACH;AACF;AAEA,MAAa,uBAAuB,kBAAwC;CAC1E,IAAI,cAAc,iBAAiB;CACnC,IAAI,CAAC,cAAc,QAAQ,OAAO;CAIlC,MAAM,kBAAkB,0BAA0B;CAElD,IAAI,iBAAiB;EACnB,0BAA0B,eAAe,eAAe;EACxD;CACF;CAEA,kBAAkB;CAIlB,cAAc,aAAa,CAAC,CAAC,cAAc;EACzC,kBAAkB;CACpB,CAAC;AACH"}
1
+ {"version":3,"file":"startContentWatcher.mjs","names":[],"sources":["../../../src/server/startContentWatcher.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config/logger';\nimport {\n acquireContentWatcherLock,\n getCliContentWatcherLabel,\n getContentWatcherOwner,\n reportRedundantContentWatcher,\n} from '@intlayer/engine/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * How often a process that lost the ownership race checks whether the owner is\n * gone. Next.js's short-lived config processes release the lock when they exit,\n * so the long-lived dev server has to be able to pick it up afterwards.\n */\nconst TAKEOVER_POLL_INTERVAL_MS = 5000;\n\n/**\n * Next.js helper processes that evaluate `next.config.*` without being the dev\n * server, matched on their entry script.\n *\n * `detached-flush` is the telemetry flusher Next spawns **detached**: it loads\n * the config, outlives the dev server, and — left unchecked — wins the watcher\n * lock and keeps watching after Ctrl-C, while the next `next dev` finds the\n * lock taken and runs with no watcher at all.\n */\nconst NEXT_HELPER_ENTRY_SCRIPTS = ['detached-flush'];\n\n/**\n * Whether this process is a Next.js helper rather than the dev server itself.\n *\n * Ownership of the watcher has to follow the process the user actually stops,\n * so a helper must never take it.\n */\nconst getIsNextHelperProcess = (): boolean =>\n process.argv.some((argument) =>\n NEXT_HELPER_ENTRY_SCRIPTS.some((script) => argument.includes(script))\n );\n\n/** Set once the watcher is running in this process. */\nlet isWatching = false;\n\n/**\n * Set while an ownership attempt is in flight.\n *\n * Taking the lock is asynchronous, and `next.config.*` is evaluated several\n * times per command — without this, those evaluations would pile up concurrent\n * attempts, each awaiting the same lock.\n */\nlet isClaimInFlight = false;\n\n/** Reports a redundant `intlayer watch` running alongside this dev server. */\nconst reportRedundantCliWatcher = (\n configuration: IntlayerConfig,\n cliWatcherLabel: string\n): void =>\n reportRedundantContentWatcher(configuration, {\n cliLabel: cliWatcherLabel,\n bundlerLabel: 'next-intlayer',\n });\n\n/**\n * Starts the content declaration watcher for a Next.js dev server, on webpack\n * as well as on Turbopack.\n *\n * Stands down — with an explanation — when that CLI watcher is running anyway,\n * since two watchers would rebuild the same dictionaries at the same time.\n * Otherwise starting is idempotent: the first process to take the lock watches,\n * and the others retry in the background so a short-lived config process\n * handing the lock back does not leave the session unwatched.\n *\n * @param configuration - The resolved Intlayer configuration.\n */\nconst claimAndWatch = async (configuration: IntlayerConfig): Promise<void> => {\n const appLogger = getAppLogger(configuration);\n\n const hasAcquiredLock = await acquireContentWatcherLock(configuration, {\n source: 'bundler',\n label: 'next-intlayer',\n });\n\n if (!hasAcquiredLock) {\n // A CLI watcher started from another terminal is just as redundant as one\n // wrapping this command, and worth the same explanation.\n const owner = await getContentWatcherOwner(configuration);\n\n if (owner?.source === 'cli') {\n reportRedundantCliWatcher(configuration, owner.label);\n return;\n }\n\n const retryTimer = setTimeout(() => {\n startContentWatcher(configuration);\n }, TAKEOVER_POLL_INTERVAL_MS);\n\n // Unreferenced so a process whose only remaining work is this retry can\n // still exit.\n retryTimer.unref?.();\n\n return;\n }\n\n isWatching = true;\n\n try {\n // Imported lazily: `@intlayer/engine/watcher` pulls in `@parcel/watcher`, a\n // native module that has no business being loaded during a production\n // build. `withIntlayer` already awaited `prepareIntlayer`, so the watcher\n // only has to pick up the changes that follow.\n const { watch } = await import('@intlayer/engine/watcher');\n\n await watch({ configuration });\n } catch (error) {\n isWatching = false;\n\n appLogger(['Failed to watch Intlayer content declarations:', error], {\n level: 'error',\n });\n }\n};\n\nexport const startContentWatcher = (configuration: IntlayerConfig): void => {\n if (isWatching || isClaimInFlight) return;\n if (!configuration.content.watch) return;\n if (getIsNextHelperProcess()) return;\n\n // Spawned by `intlayer watch --with`: the CLI watcher covers the project, and\n // this is known from the environment alone — no need to touch the lock.\n const cliWatcherLabel = getCliContentWatcherLabel();\n\n if (cliWatcherLabel) {\n reportRedundantCliWatcher(configuration, cliWatcherLabel);\n return;\n }\n\n isClaimInFlight = true;\n\n // Deliberately not awaited: `withIntlayerSync` is synchronous, and the dev\n // server must not wait on the watcher to start serving.\n claimAndWatch(configuration).fin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@ import { resolveAmbientLocale } from "./ambientLocale.mjs";
2
2
  import { internationalization } from "@intlayer/config/built";
3
3
 
4
4
  //#region src/server/useLocale.ts
5
+ const { defaultLocale, locales: availableLocales } = internationalization ?? {};
5
6
  /**
6
7
  * On the server side, hook returning the current locale along with the default
7
8
  * and available ones.
@@ -12,7 +13,6 @@ import { internationalization } from "@intlayer/config/built";
12
13
  * render the provider did not reach.
13
14
  */
14
15
  const useLocale = () => {
15
- const { defaultLocale, locales: availableLocales } = internationalization ?? {};
16
16
  return {
17
17
  locale: resolveAmbientLocale() ?? defaultLocale,
18
18
  defaultLocale,
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/server/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { resolveAmbientLocale } from './ambientLocale';\n\nexport type UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n};\n\n/**\n * On the server side, hook returning the current locale along with the default\n * and available ones.\n *\n * Reimplemented rather than re-exported from `react-intlayer/server`: that one\n * takes no locale argument, so there is no way to hand it the ambient locale —\n * it would read the server context alone and report the default locale on any\n * render the provider did not reach.\n */\nexport const useLocale = (): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const locale = (resolveAmbientLocale() ?? defaultLocale) as DeclaredLocales;\n\n return { locale, defaultLocale, availableLocales };\n};\n"],"mappings":";;;;;;;;;;;;;AAmBA,MAAa,kBAAmC;CAC9C,MAAM,EAAE,eAAe,SAAS,qBAC9B,wBAAwB,CAAC;CAI3B,OAAO;EAAE,QAFO,qBAAqB,KAAK;EAEzB;EAAe;CAAiB;AACnD"}
1
+ {"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/server/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { resolveAmbientLocale } from './ambientLocale';\n\nexport type UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n};\n\nconst { defaultLocale, locales: availableLocales } = internationalization ?? {};\n\n/**\n * On the server side, hook returning the current locale along with the default\n * and available ones.\n *\n * Reimplemented rather than re-exported from `react-intlayer/server`: that one\n * takes no locale argument, so there is no way to hand it the ambient locale —\n * it would read the server context alone and report the default locale on any\n * render the provider did not reach.\n */\nexport const useLocale = (): UseLocaleResult => {\n const locale = (resolveAmbientLocale() ?? defaultLocale) as DeclaredLocales;\n\n return { locale, defaultLocale, availableLocales };\n};\n"],"mappings":";;;;AAUA,MAAM,EAAE,eAAe,SAAS,qBAAqB,wBAAwB,CAAC;;;;;;;;;;AAW9E,MAAa,kBAAmC;CAG9C,OAAO;EAAE,QAFO,qBAAqB,KAAK;EAEzB;EAAe;CAAiB;AACnD"}
@@ -14,7 +14,6 @@ import { getNestedDictionaryGraph } from "@intlayer/core/dictionaryManipulator";
14
14
  import { getDictionaries } from "@intlayer/dictionaries-entry";
15
15
  import { prepareIntlayer } from "@intlayer/engine/build";
16
16
  import { logConfigDetails } from "@intlayer/engine/cli";
17
- import { IntlayerPlugin } from "@intlayer/webpack";
18
17
  import { defu } from "defu";
19
18
  import nextPackageJSON from "next/package.json" with { type: "json" };
20
19
 
@@ -174,11 +173,7 @@ const getPruneConfig = ({ intlayerConfig, isBuildCommand, isTurbopackEnabled, is
174
173
  const dynamicDictionariesEntryPath = join(mainDir, "dynamic_dictionaries.mjs");
175
174
  const unmergedDictionariesEntryPath = join(mainDir, "unmerged_dictionaries.mjs");
176
175
  const fetchDictionariesEntryPath = join(mainDir, "fetch_dictionaries.mjs");
177
- const filesList = [
178
- ...buildComponentFilesList(intlayerConfig),
179
- dictionariesEntryPath,
180
- unmergedDictionariesEntryPath
181
- ];
176
+ const filesList = [...buildComponentFilesList(intlayerConfig), dictionariesEntryPath];
182
177
  const dictionaries = getDictionaries(intlayerConfig);
183
178
  const dictionaryModeMap = {};
184
179
  Object.values(dictionaries).forEach((dictionary) => {
@@ -265,7 +260,7 @@ const withIntlayerSync = (nextConfig = {}, configOptions) => {
265
260
  if (isTurbopackEnabled && typeof nextConfig.webpack !== "undefined") appLogger("Turbopack is enabled but a custom webpack config is present. It will be ignored.");
266
261
  const { isBuildCommand, isDevCommand } = getCommandsEvent();
267
262
  const extractorLoader = getExtractorLoader(intlayerConfig, isTurbopackEnabled ?? false, isDevCommand);
268
- if (isTurbopackEnabled && isDevCommand) startContentWatcher(intlayerConfig);
263
+ if (isDevCommand) startContentWatcher(intlayerConfig);
269
264
  const turboConfig = {
270
265
  resolveAlias: getAlias({
271
266
  configuration: intlayerConfig,
@@ -341,7 +336,6 @@ const withIntlayerSync = (nextConfig = {}, configOptions) => {
341
336
  } else config = {
342
337
  ...config,
343
338
  webpack: (config, options) => {
344
- const { isServer, nextRuntime } = options;
345
339
  if (typeof nextConfig.webpack === "function") config = nextConfig.webpack(config, options);
346
340
  if (config.externals === false) config.externals = [];
347
341
  const externalExact = /* @__PURE__ */ new Set([
@@ -377,7 +371,6 @@ const withIntlayerSync = (nextConfig = {}, configOptions) => {
377
371
  formatter: (value) => resolve(value)
378
372
  })
379
373
  };
380
- if (isDevCommand && isServer && nextRuntime === "nodejs") config.plugins.push(new IntlayerPlugin(intlayerConfig));
381
374
  return config;
382
375
  }
383
376
  };
@@ -1 +1 @@
1
- {"version":3,"file":"withIntlayer.mjs","names":[],"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { join, relative, resolve } from 'node:path';\nimport {\n type CallerDescriptor,\n toSwcExtraCallers,\n} from '@intlayer/config/callers';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { COMPILER_ENABLED, IMPORT_MODE } from '@intlayer/config/defaultValues';\nimport {\n formatDictionarySelectorEnvVar,\n formatNodeTypeToEnvVar,\n formatOptimizedNestingEnvVar,\n getConfigEnvVars,\n} from '@intlayer/config/envVars';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport {\n compareVersions,\n getAlias,\n getHasDictionarySelector,\n getProjectRequire,\n getUnusedNodeTypes,\n normalizePath,\n} from '@intlayer/config/utils';\nimport { getNestedDictionaryGraph } from '@intlayer/core/dictionaryManipulator';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { prepareIntlayer } from '@intlayer/engine/build';\nimport { logConfigDetails } from '@intlayer/engine/cli';\nimport { buildComponentFilesList, runOnce } from '@intlayer/engine/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { IntlayerPlugin } from '@intlayer/webpack';\nimport { defu } from 'defu';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport nextPackageJSON from 'next/package.json' with { type: 'json' };\nimport {\n type FieldRenameMapByDictionaryKey,\n getIsPurgePipelineAvailable,\n prepareSwcOptimization,\n resolveSwcLogLevel,\n} from './prepareSwcOptimization';\nimport { startContentWatcher } from './startContentWatcher';\nimport {\n getIsSwcPluginSupported,\n MINIMUM_SWC_PLUGIN_NEXT_VERSION,\n} from './swcPluginCompatibility';\n\nexport {\n getIsSwcPluginSupported,\n MINIMUM_SWC_PLUGIN_NEXT_VERSION,\n} from './swcPluginCompatibility';\n\n/**\n * Resolve the Next.js version from the *user's* project at runtime.\n * A static `import from 'next/package.json'` would resolve relative to\n * next-intlayer's own node_modules, which may differ in a monorepo.\n */\nconst getNextVersionFlags = (intlayerConfig: IntlayerConfig) => {\n let nextVersion = nextPackageJSON.version;\n\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n const pkg = requireFunction('next/package.json') as { version: string };\n nextVersion = pkg.version;\n } catch {\n // keep default\n }\n\n return {\n nextVersion,\n isGteNext13: compareVersions(nextVersion, '≥', '13.0.0'),\n isGteNext15: compareVersions(nextVersion, '≥', '15.0.0'),\n isGteNext16: compareVersions(nextVersion, '≥', '16.0.0'),\n isTurbopackStable: compareVersions(nextVersion, '≥', '15.3.0'),\n /**\n * Whether this Next.js release can load the `@intlayer/swc` Wasm plugin.\n * See {@link MINIMUM_SWC_PLUGIN_NEXT_VERSION}.\n */\n isSwcPluginSupported: getIsSwcPluginSupported(nextVersion),\n };\n};\n\n// Check if SWC plugin is available\nconst getIsSwcPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/swc');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\n// Check if Babel plugin is available\nconst getIsBabelExtractPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/babel');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\nconst resolvePluginPath = (\n pluginPath: string,\n intlayerConfig: IntlayerConfig,\n isTurbopackEnabled: boolean\n): string => {\n const requireFunction = intlayerConfig.build?.require ?? getProjectRequire();\n const pluginPathResolved = requireFunction?.resolve(pluginPath);\n\n if (isTurbopackEnabled)\n // Relative path for turbopack\n return normalizePath(`./${relative(process.cwd(), pluginPathResolved)}`);\n\n // Absolute path for webpack\n return pluginPathResolved;\n};\n\n/**\n * Extensions the extraction loader is registered for.\n *\n * The compiler reads its content out of JSX — element text and the\n * translatable attributes — so a file with no JSX in it has nothing to give,\n * and `*.ts` is left out. `*.js` is in because a plain-JavaScript Next.js app\n * writes its components there.\n */\nconst EXTRACTOR_LOADER_EXTENSIONS = ['tsx', 'jsx', 'js'] as const;\n\n/**\n * The subset safe to register as a Turbopack rule on any Next.js version.\n *\n * Turbopack rules match every module it processes, dependencies included, and\n * only Next.js 16 can express \"skip `node_modules`\" (see\n * {@link TURBOPACK_PROJECT_FILES_CONDITION}). Below that, `*.js` would hand\n * every dependency file to a Node loader worker, so it is left out rather than\n * made to cost a cold dev start.\n */\nconst TURBOPACK_ALWAYS_SAFE_EXTENSIONS = ['tsx', 'jsx'] as const;\n\n/**\n * Restricts a Turbopack rule to the project's own files. `foreign` is\n * Turbopack's builtin condition for a module inside `node_modules`.\n *\n * Only understood from Next.js 16 on — earlier releases carry no `condition`\n * field on a rule at all.\n */\nconst TURBOPACK_PROJECT_FILES_CONDITION = { not: 'foreign' } as const;\n\n/** Mode reported to the extraction loader, which cannot read the command. */\ntype ExtractorLoaderMode = 'dev' | 'build';\n\n/**\n * Whether the Intlayer compiler should extract content for this command.\n *\n * Mirrors `getExtractPluginOptions`, which the loader re-evaluates on its side:\n * this is only about not registering a loader that would do nothing.\n */\nconst getIsCompilerEnabled = (\n intlayerConfig: IntlayerConfig,\n isDevCommand: boolean\n): boolean => {\n const enabled = intlayerConfig.compiler?.enabled ?? COMPILER_ENABLED;\n\n if (enabled === 'build-only') return !isDevCommand;\n\n return enabled !== false;\n};\n\n/**\n * Describes the extraction loader for both bundlers, or `null` when the\n * compiler is off or `@intlayer/babel` is not installed.\n *\n * The loader replaces the `babel.config.js` the compiler used to need on\n * Next.js: Turbopack never reads a Babel config, and on webpack the mere\n * presence of one opts the whole project out of SWC — including the\n * `@intlayer/swc` optimize pass.\n */\nconst getExtractorLoader = (\n intlayerConfig: IntlayerConfig,\n isTurbopackEnabled: boolean,\n isDevCommand: boolean\n): { loaderPath: string; mode: ExtractorLoaderMode } | null => {\n if (!getIsCompilerEnabled(intlayerConfig, isDevCommand)) return null;\n if (!getIsBabelExtractPluginAvailable(intlayerConfig)) return null;\n\n try {\n return {\n loaderPath: resolvePluginPath(\n 'next-intlayer/extractor-loader',\n intlayerConfig,\n isTurbopackEnabled\n ),\n mode: isDevCommand ? 'dev' : 'build',\n };\n } catch {\n // An installed `next-intlayer` that cannot resolve its own subpath means a\n // version predating the loader — the Babel setup still applies there.\n return null;\n }\n};\n\ntype GetPruneConfigParams = {\n intlayerConfig: IntlayerConfig;\n isBuildCommand: boolean;\n isTurbopackEnabled: boolean;\n isDevCommand: boolean;\n isGteNext13: boolean;\n /** Whether the resolved Next.js version can load the Wasm plugin. */\n isSwcPluginSupported: boolean;\n /** Resolved Next.js version, reported when the plugin has to stand down. */\n nextVersion: string;\n compatCallers?: CallerDescriptor[];\n fieldRenameMap?: FieldRenameMapByDictionaryKey;\n};\n\nconst getPruneConfig = ({\n intlayerConfig,\n isBuildCommand,\n isTurbopackEnabled,\n isDevCommand,\n isGteNext13,\n isSwcPluginSupported,\n nextVersion,\n compatCallers,\n fieldRenameMap,\n}: GetPruneConfigParams): Partial<NextConfig> => {\n const { optimize, minify, purge } = intlayerConfig.build;\n const importMode =\n intlayerConfig.build.importMode ?? intlayerConfig.dictionary?.importMode;\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n } = intlayerConfig.system;\n const { baseDir } = intlayerConfig.system;\n const logger = getAppLogger(intlayerConfig);\n\n if (optimize === false) {\n return {};\n }\n if (optimize === undefined && !isBuildCommand) {\n return {};\n }\n\n if (!isGteNext13) return {};\n\n const isSwcPluginAvailable = getIsSwcPluginAvailable(intlayerConfig);\n\n runOnce(\n join(baseDir, '.intlayer', 'cache', 'intlayer-prune-plugin-enabled.lock'),\n () => {\n if (isSwcPluginAvailable && !isSwcPluginSupported) {\n logger(\n [\n `Build optimization ${colorize('disabled', ANSIColors.GREY_DARK)}:`,\n colorize('@intlayer/swc', ANSIColors.GREY_LIGHT),\n colorize(\n `cannot run on Next.js ${nextVersion} — its bundled SWC predates the`,\n ANSIColors.GREY\n ),\n colorize(\n 'stable Wasm plugin ABI. Upgrade to Next.js',\n ANSIColors.GREY\n ),\n colorize(MINIMUM_SWC_PLUGIN_NEXT_VERSION, ANSIColors.BLUE),\n colorize('or later to enable it.', ANSIColors.GREY),\n ],\n { level: 'warn' }\n );\n } else if (isSwcPluginAvailable) {\n logger([\n `Build optimization ${colorize('enabled', ANSIColors.GREEN)}`,\n colorize(`(import mode:`, ANSIColors.GREY_DARK),\n colorize(importMode ?? IMPORT_MODE, ANSIColors.BLUE),\n colorize(`)`, ANSIColors.GREY_DARK),\n ]);\n\n // The purge / minify pipeline stands down — with its own explanation —\n // when `@intlayer/babel` (which runs it) is not resolvable. The editor\n // only stands the field-rename step down, not the pipeline.\n const isPurgePipelineEnabled =\n getIsPurgePipelineAvailable(intlayerConfig);\n\n // The purge pipeline reports the field-rename step standing down when\n // the editor is enabled, so this line stays a plain one.\n if (isPurgePipelineEnabled && minify) {\n logger(\n `Dictionary minification ${colorize('enabled', ANSIColors.GREEN)}`\n );\n }\n\n if (isPurgePipelineEnabled && purge) {\n logger(\n `Dictionary purge unused keys ${colorize('enabled', ANSIColors.GREEN)}`\n );\n }\n } else {\n logger([\n colorize('Recommended: Install', ANSIColors.GREY),\n colorize('@intlayer/swc', ANSIColors.GREY_LIGHT),\n colorize(\n 'package to enable build optimization. See documentation:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://intlayer.org/docs/bundle-optimization',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n runOnce(\n join(\n baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-compiler-plugin-enabled.lock'\n ),\n () => {\n const isBabelExtractPluginAvailable =\n getIsBabelExtractPluginAvailable(intlayerConfig);\n\n if (isBabelExtractPluginAvailable) {\n let isEnabled = intlayerConfig.compiler?.enabled ?? true;\n\n if (isEnabled === 'build-only') {\n isEnabled = !isDevCommand;\n }\n\n // Only the enabled state is reported: disabling the compiler is an\n // explicit configuration choice, so announcing it on every build adds\n // noise without telling the user anything they did not ask for.\n if (isEnabled) {\n logger('Intlayer compiler enabled');\n }\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n // Registering the plugin on a host that cannot load it is not a degraded\n // build but a failed one: SWC aborts with `failed to invoke plugin`. Standing\n // down leaves the app running off the runtime dictionary registry, which the\n // transform would otherwise have emptied.\n if (!isSwcPluginAvailable || !isSwcPluginSupported) {\n return {};\n }\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n\n const unmergedDictionariesEntryPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n\n const fetchDictionariesEntryPath = join(mainDir, 'fetch_dictionaries.mjs');\n\n const filesListPattern = buildComponentFilesList(intlayerConfig);\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n unmergedDictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n ];\n\n const dictionaries = getDictionaries(intlayerConfig);\n\n const dictionaryModeMap: Record<string, 'static' | 'dynamic' | 'fetch'> = {};\n\n (Object.values(dictionaries) as Dictionary[]).forEach((dictionary) => {\n dictionaryModeMap[dictionary.key] =\n dictionary.importMode ?? importMode ?? IMPORT_MODE;\n });\n\n // Dictionaries holding `nest()` references: their static import is re-pointed\n // at the companion module carrying the nest targets.\n const nestingDictionaryKeys = [\n ...getNestedDictionaryGraph(Object.values(dictionaries)).keys(),\n ];\n\n return {\n experimental: {\n swcPlugins: [\n [\n resolvePluginPath(\n '@intlayer/swc',\n intlayerConfig,\n isTurbopackEnabled\n ),\n {\n dictionariesDir,\n dictionariesEntryPath,\n unmergedDictionariesEntryPath,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n fetchDictionariesDir,\n fetchDictionariesEntryPath,\n importMode,\n filesList,\n replaceDictionaryEntry: true,\n nestingDictionaryKeys,\n dictionaryModeMap,\n // Compat adapters reach the Wasm plugin as descriptors serialised\n // to its wire format; with none injected the option is empty and\n // the plugin runs the base intlayer rewrite alone.\n extraCallers: toSwcExtraCallers(compatCallers ?? []),\n // Rewrites `content.title` → `content.a` to match the compiled\n // dictionaries the `build.minify` pass already renamed.\n fieldRenameMap: fieldRenameMap ?? {},\n logLevel: resolveSwcLogLevel(intlayerConfig),\n },\n ],\n ],\n },\n };\n};\n\nconst getCommandsEvent = () => {\n const lifecycleEvent = process.env['npm_lifecycle_event'];\n const lifecycleScript = process.env['npm_lifecycle_script'] ?? '';\n\n const isDevCommand =\n lifecycleEvent === 'dev' ||\n process.argv.some((arg) => arg === 'dev') ||\n /(^|\\s)(next\\s+)?dev(\\s|$)/.test(lifecycleScript);\n\n const isBuildCommand =\n lifecycleEvent === 'build' ||\n process.argv.some((arg) => arg === 'build') ||\n /(^|\\s)(next\\s+)?build(\\s|$)/.test(lifecycleScript);\n\n const isStartCommand =\n lifecycleEvent === 'start' ||\n process.argv.some((arg) => arg === 'start') ||\n /(^|\\s)(next\\s+)?start(\\s|$)/.test(lifecycleScript);\n\n return {\n isDevCommand,\n isBuildCommand,\n isStartCommand,\n };\n};\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\ntype WithIntlayerOptions = GetConfigurationOptions & {\n enableTurbopack?: boolean;\n /**\n * Compat-adapter caller descriptors injected by a compat package's bundler\n * plugin (e.g. `@intlayer/next-intl/plugin`). They drive both the SWC\n * optimize rewrite and the Node-side usage analysis, so one registry slice\n * is all a compat plugin has to pass.\n */\n compatCallers?: CallerDescriptor[];\n\n /**\n * Field-rename tables produced by the purge / minify pipeline, forwarded to\n * the `@intlayer/swc` plugin so it rewrites source accesses to match the\n * renamed dictionaries.\n *\n * @internal Set by {@link withIntlayer}; `withIntlayerSync` on its own runs\n * no dictionary rewrite, so it leaves this unset and no rename is applied.\n */\n fieldRenameMap?: FieldRenameMapByDictionaryKey;\n};\n\n/**\n * Pin the env file used to resolve the Intlayer configuration to the Next.js\n * command being run (`dev` → `development`, `build`/`start` → `production`).\n *\n * Next.js loads the config file in several processes during a single command\n * (the main `build` process plus one or more Turbopack/webpack workers), and\n * `process.env.NODE_ENV` is not guaranteed to hold the same value in all of\n * them. Since `getConfiguration` falls back to `NODE_ENV` to pick its env file\n * (`.env.development.local` vs `.env.production.local`), those processes could\n * otherwise resolve *different* env values (e.g. `applicationURL`,\n * `INTLAYER_CLIENT_ID`). The resulting configuration would differ between\n * processes, defeating the `isCachedConfigurationUpToDate` check and forcing a\n * redundant full dictionary rebuild.\n *\n * Passing an explicit `env` keeps configuration resolution deterministic across\n * every process of the command. An `env` already set by the caller is\n * respected, and when the command cannot be determined we fall back to\n * `getConfiguration`'s own default (i.e. leave `env` unset).\n */\nconst resolveConfigOptions = (\n configOptions?: WithIntlayerOptions\n): WithIntlayerOptions | undefined => {\n // Respect an explicit override from the caller (idempotent on re-entry).\n if (configOptions?.env) return configOptions;\n\n const { isDevCommand, isBuildCommand, isStartCommand } = getCommandsEvent();\n\n const env = isDevCommand\n ? 'development'\n : isBuildCommand || isStartCommand\n ? 'production'\n : undefined;\n\n if (!env) return configOptions;\n\n return {\n ...configOptions,\n env,\n };\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayerSync(nextConfig)\n * ```\n */\nexport const withIntlayerSync = <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T,\n configOptions?: WithIntlayerOptions\n): NextConfig & T => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const resolvedConfigOptions = resolveConfigOptions(configOptions);\n\n const intlayerConfig = getConfiguration(resolvedConfigOptions);\n\n logConfigDetails(resolvedConfigOptions);\n\n const appLogger = getAppLogger(intlayerConfig);\n\n const {\n nextVersion,\n isGteNext13,\n isGteNext15,\n isGteNext16,\n isTurbopackStable,\n isSwcPluginSupported,\n } = getNextVersionFlags(intlayerConfig);\n\n const isTurbopackEnabledFromCommand = isGteNext16\n ? // Next@16 enables turbopack by default; disable with --webpack\n !process.env['npm_lifecycle_script']?.includes('--webpack')\n : // Next@15 uses --turbopack, Next@14 uses --turbo\n process.env['npm_lifecycle_script']?.includes('--turbo');\n\n const isTurbopackEnabled =\n configOptions?.enableTurbopack ?? isTurbopackEnabledFromCommand;\n\n if (isTurbopackEnabled && typeof nextConfig.webpack !== 'undefined') {\n appLogger(\n 'Turbopack is enabled but a custom webpack config is present. It will be ignored.'\n );\n }\n\n const { isBuildCommand, isDevCommand } = getCommandsEvent();\n\n const extractorLoader = getExtractorLoader(\n intlayerConfig,\n isTurbopackEnabled ?? false,\n isDevCommand\n );\n\n // Turbopack cannot run `IntlayerPlugin`, which is what starts the content\n // watcher on webpack. Without this the dev server had to be wrapped in\n // `intlayer watch --with next dev` for a `.content` edit to reach `.intlayer`.\n if (isTurbopackEnabled && isDevCommand) {\n startContentWatcher(intlayerConfig);\n }\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => `./${value}`, // prefix by './' to consider the path as relative to the project root. This is necessary for turbopack to work correctly.\n }),\n\n rules: {\n '*.node': {\n as: '*.node',\n loaders: ['node-loader'],\n },\n\n // Turbopack serialises loader options to JSON, so the loader reads the\n // Intlayer configuration itself and only the command mode is passed here.\n //\n // No `as`: it renames the module, and naming the extension the rule\n // already matches turns `Component.tsx` into `Component.tsx.tsx`, which\n // then fails to resolve. Left out, Turbopack keeps handling the loader\n // output as the TSX/JSX it still is.\n ...(extractorLoader\n ? Object.fromEntries(\n (isGteNext16\n ? EXTRACTOR_LOADER_EXTENSIONS\n : TURBOPACK_ALWAYS_SAFE_EXTENSIONS\n ).map((extension) => [\n `*.${extension}`,\n {\n loaders: [\n {\n loader: extractorLoader.loaderPath,\n options: { mode: extractorLoader.mode },\n },\n ],\n ...(isGteNext16\n ? { condition: TURBOPACK_PROJECT_FILES_CONDITION }\n : {}),\n },\n ])\n )\n : {}),\n },\n };\n\n const serverExternalPackages = [\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n 'recast',\n '@intlayer/engine',\n '@intlayer/webpack',\n ];\n\n let env: Record<string, string> = {};\n\n if (isBuildCommand) {\n const dictionaries = getDictionaries(intlayerConfig);\n\n if (Object.keys(dictionaries).length === 0) {\n appLogger('No dictionaries found. Please check your configuration.', {\n isVerbose: true,\n });\n }\n\n const unusedNodeTypes = getUnusedNodeTypes(dictionaries);\n\n if (unusedNodeTypes && unusedNodeTypes.length > 0) {\n appLogger(\n [\n 'Filtering out unused logic:',\n unusedNodeTypes\n .filter(\n (key) => !['reactNode', 'solidNode', 'preactNode'].includes(key)\n )\n .map((key) => colorize(key, ANSIColors.BLUE))\n .join(', '),\n ],\n {\n isVerbose: true,\n }\n );\n }\n\n env = {\n ...env,\n\n // Tree shacking based on unused node types\n ...formatNodeTypeToEnvVar(unusedNodeTypes),\n\n // Selects the local `nest()` resolver, which reads the nest targets\n // attached to each dictionary by the optimize transform instead of the\n // registry that transform empties.\n ...formatOptimizedNestingEnvVar(intlayerConfig.build.optimize !== false),\n\n // Tree shacking the dictionary selector logic\n // (collections / variants)\n ...formatDictionarySelectorEnvVar(getHasDictionarySelector(dictionaries)),\n\n // Tree shacking based on config\n ...getConfigEnvVars(intlayerConfig),\n };\n }\n\n const getNewConfig = (): Partial<NextConfig> => {\n let config: Partial<NextConfig> = {\n env,\n };\n\n if (isGteNext15) {\n config = {\n ...config,\n serverExternalPackages,\n };\n }\n\n if (isGteNext13 && !isGteNext15) {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n serverComponentsExternalPackages: serverExternalPackages,\n },\n };\n }\n\n if (isTurbopackEnabled) {\n if (isGteNext15 && isTurbopackStable) {\n config = {\n ...config,\n turbopack: turboConfig,\n };\n } else {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n // @ts-ignore exist in next@14\n turbo: turboConfig,\n },\n };\n }\n } else {\n config = {\n ...config,\n webpack: (config: WebpackParams['0'], options: WebpackParams[1]) => {\n // Only add Intlayer plugin on server side (node runtime)\n const { isServer, nextRuntime } = options;\n\n // If the user has defined their own webpack config, call it\n if (typeof nextConfig.webpack === 'function') {\n config = nextConfig.webpack(config, options);\n }\n\n // Rspack set external as false by default\n // Overwrite it to allow pushing the desired externals\n if (config.externals === false) {\n config.externals = [];\n }\n\n // Mark server-only modules as externals (function form handles subpaths)\n const externalExact = new Set([\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n 'recast',\n ]);\n const externalPrefixes = ['@intlayer/engine', '@intlayer/webpack'];\n config.externals.push(\n (\n { request }: { request?: string },\n callback: (err: Error | null, result?: string) => void\n ) => {\n if (\n request &&\n (externalExact.has(request) ||\n externalPrefixes.some(\n (prefix) =>\n request === prefix || request.startsWith(`${prefix}/`)\n ))\n ) {\n return callback(null, `commonjs ${request}`);\n }\n callback(null);\n }\n );\n\n // Use `node-loader` for any `.node` files\n config.module.rules.push({\n test: /\\.node$/,\n loader: 'node-loader',\n });\n\n // `enforce: 'pre'` puts the extraction ahead of `next-swc-loader`,\n // so the loader reads the original JSX rather than its compiled\n // output. Declaring it here (instead of in a `babel.config.js`)\n // keeps Next.js on SWC, and with it the `@intlayer/swc` optimize\n // pass a Babel config would silently disable.\n if (extractorLoader) {\n config.module.rules.push({\n test: new RegExp(\n `\\\\.(${EXTRACTOR_LOADER_EXTENSIONS.join('|')})$`\n ),\n exclude: /node_modules/,\n enforce: 'pre',\n use: [\n {\n loader: extractorLoader.loaderPath,\n options: { mode: extractorLoader.mode },\n },\n ],\n });\n }\n\n // Always alias on the server (node/edge) for stability.\n // On the client, alias only when not using live sync.\n config.resolve.alias = {\n ...config.resolve.alias,\n ...getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n };\n\n // Activate watch mode webpack plugin\n if (isDevCommand && isServer && nextRuntime === 'nodejs') {\n // Optional as rspack not support plugin yet\n config.plugins.push(new IntlayerPlugin(intlayerConfig));\n }\n\n return config;\n },\n };\n }\n\n return config;\n };\n\n const pruneConfig: Partial<NextConfig> = getPruneConfig({\n intlayerConfig,\n isBuildCommand,\n isTurbopackEnabled: isTurbopackEnabled ?? false,\n isDevCommand,\n isGteNext13,\n isSwcPluginSupported,\n nextVersion,\n compatCallers: configOptions?.compatCallers,\n fieldRenameMap: configOptions?.fieldRenameMap,\n });\n\n const intlayerNextConfig: Partial<NextConfig> = defu(\n getNewConfig(),\n pruneConfig\n );\n\n // Merge the new config with the user's config\n const result = defu(intlayerNextConfig, nextConfig) as NextConfig & T;\n\n return result;\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n *\n * > Node withIntlayer is a promise function. Use withIntlayerSync instead if you want to use it synchronously.\n * > Using the promise allows to prepare the intlayer dictionaries before the build starts.\n *\n */\nexport const withIntlayer = async <T extends NextConfig | Partial<NextConfig>>(\n nextConfig: T | Promise<T> = {} as T,\n configOptions?: WithIntlayerOptions\n): Promise<NextConfig & T> => {\n const { isBuildCommand, isDevCommand, isStartCommand } = getCommandsEvent();\n\n process.env.INTLAYER_IS_DEV_COMMAND = isDevCommand ? 'true' : 'false';\n\n const resolvedConfigOptions = resolveConfigOptions(configOptions);\n\n const intlayerConfig = getConfiguration(resolvedConfigOptions);\n\n const { mode } = intlayerConfig.build;\n\n // Only call prepareIntlayer during `dev` or `build` (not during `start`)\n // If prod: clean and rebuild once\n // If dev: rebuild only once if it's more than 1 hour since last rebuild\n if (!isStartCommand && (isDevCommand || isBuildCommand || mode === 'auto')) {\n // prepareIntlayer use runOnce to ensure to run only once because will run twice on client and server side otherwise\n await prepareIntlayer(intlayerConfig, {\n clean: isBuildCommand,\n cacheTimeoutMs: isBuildCommand\n ? 1000 * 30 // 30 seconds for build (to ensure to rebuild all dictionaries)\n : 1000 * 60 * 60, // 1 hour for dev (default cache timeout)\n env: isBuildCommand ? 'prod' : 'dev',\n });\n }\n\n // Remove unused content fields and rename the remaining ones to short\n // aliases, then hand the rename tables to `withIntlayerSync` so the SWC\n // plugin rewrites the matching source accesses. Only meaningful for a\n // production build — the optimize pipeline is off during `next dev`.\n //\n // `isSwcPluginUsable` gates the dictionary rewrite on the plugin actually\n // running: it is the only half that fixes up the source, so minifying without\n // it would leave the code reading field names the dictionaries no longer have.\n const { isSwcPluginSupported } = getNextVersionFlags(intlayerConfig);\n\n const fieldRenameMap = isBuildCommand\n ? await prepareSwcOptimization(intlayerConfig, {\n configOptions: resolvedConfigOptions,\n compatCallers: configOptions?.compatCallers,\n isSwcPluginUsable:\n isSwcPluginSupported && getIsSwcPluginAvailable(intlayerConfig),\n })\n : {};\n\n const nextConfigResolved = await nextConfig;\n\n return withIntlayerSync(nextConfigResolved, {\n ...resolvedConfigOptions,\n fieldRenameMap,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAM,uBAAuB,mBAAmC;CAC9D,IAAI,cAAc,gBAAgB;CAElC,IAAI;EAIF,eAFE,eAAe,OAAO,WAAW,kBAAkB,EAC1B,CAAC,mBACZ,CAAC,CAAC;CACpB,QAAQ,CAER;CAEA,OAAO;EACL;EACA,aAAa,gBAAgB,aAAa,KAAK,QAAQ;EACvD,aAAa,gBAAgB,aAAa,KAAK,QAAQ;EACvD,aAAa,gBAAgB,aAAa,KAAK,QAAQ;EACvD,mBAAmB,gBAAgB,aAAa,KAAK,QAAQ;;;;;EAK7D,sBAAsB,wBAAwB,WAAW;CAC3D;AACF;AAGA,MAAM,2BAA2B,mBAAmC;CAClE,IAAI;EAGF,CADE,eAAe,OAAO,WAAW,kBAAkB,EACtC,CAAC,QAAQ,eAAe;EACvC,OAAO;CACT,SAAS,IAAI;EACX,OAAO;CACT;AACF;AAGA,MAAM,oCAAoC,mBAAmC;CAC3E,IAAI;EAGF,CADE,eAAe,OAAO,WAAW,kBAAkB,EACtC,CAAC,QAAQ,iBAAiB;EACzC,OAAO;CACT,SAAS,IAAI;EACX,OAAO;CACT;AACF;AAEA,MAAM,qBACJ,YACA,gBACA,uBACW;CAEX,MAAM,sBADkB,eAAe,OAAO,WA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AAe;CAKhC,IAAI,CAAC,mBAAmB,gBAAgB,kBAAkB,SAAS,SAEjE,MAAM,gBAAgB,gBAAgB;EACpC,OAAO;EACP,gBAAgB,iBACZ,MACA;EACJ,KAAK,iBAAiB,SAAS;CACjC,CAAC;CAWH,MAAM,EAAE,yBAAyB,oBAAoB,cAAc;CAEnE,MAAM,iBAAiB,iBACnB,MAAM,uBAAuB,gBAAgB;EAC3C,eAAe;EACf,eAAe,eAAe;EAC9B,mBACE,wBAAwB,wBAAwB,cAAc;CAClE,CAAC,IACD,CAAC;CAEL,MAAM,qBAAqB,MAAM;CAEjC,OAAO,iBAAiB,oBAAoB;EAC1C,GAAG;EACH;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"withIntlayer.mjs","names":[],"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { join, relative, resolve } from 'node:path';\nimport {\n type CallerDescriptor,\n toSwcExtraCallers,\n} from '@intlayer/config/callers';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { COMPILER_ENABLED, IMPORT_MODE } from '@intlayer/config/defaultValues';\nimport {\n formatDictionarySelectorEnvVar,\n formatNodeTypeToEnvVar,\n formatOptimizedNestingEnvVar,\n getConfigEnvVars,\n} from '@intlayer/config/envVars';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport {\n compareVersions,\n getAlias,\n getHasDictionarySelector,\n getProjectRequire,\n getUnusedNodeTypes,\n normalizePath,\n} from '@intlayer/config/utils';\nimport { getNestedDictionaryGraph } from '@intlayer/core/dictionaryManipulator';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { prepareIntlayer } from '@intlayer/engine/build';\nimport { logConfigDetails } from '@intlayer/engine/cli';\nimport { buildComponentFilesList, runOnce } from '@intlayer/engine/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { defu } from 'defu';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport nextPackageJSON from 'next/package.json' with { type: 'json' };\nimport {\n type FieldRenameMapByDictionaryKey,\n getIsPurgePipelineAvailable,\n prepareSwcOptimization,\n resolveSwcLogLevel,\n} from './prepareSwcOptimization';\nimport { startContentWatcher } from './startContentWatcher';\nimport {\n getIsSwcPluginSupported,\n MINIMUM_SWC_PLUGIN_NEXT_VERSION,\n} from './swcPluginCompatibility';\n\nexport {\n getIsSwcPluginSupported,\n MINIMUM_SWC_PLUGIN_NEXT_VERSION,\n} from './swcPluginCompatibility';\n\n/**\n * Resolve the Next.js version from the *user's* project at runtime.\n * A static `import from 'next/package.json'` would resolve relative to\n * next-intlayer's own node_modules, which may differ in a monorepo.\n */\nconst getNextVersionFlags = (intlayerConfig: IntlayerConfig) => {\n let nextVersion = nextPackageJSON.version;\n\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n const pkg = requireFunction('next/package.json') as { version: string };\n nextVersion = pkg.version;\n } catch {\n // keep default\n }\n\n return {\n nextVersion,\n isGteNext13: compareVersions(nextVersion, '≥', '13.0.0'),\n isGteNext15: compareVersions(nextVersion, '≥', '15.0.0'),\n isGteNext16: compareVersions(nextVersion, '≥', '16.0.0'),\n isTurbopackStable: compareVersions(nextVersion, '≥', '15.3.0'),\n /**\n * Whether this Next.js release can load the `@intlayer/swc` Wasm plugin.\n * See {@link MINIMUM_SWC_PLUGIN_NEXT_VERSION}.\n */\n isSwcPluginSupported: getIsSwcPluginSupported(nextVersion),\n };\n};\n\n// Check if SWC plugin is available\nconst getIsSwcPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/swc');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\n// Check if Babel plugin is available\nconst getIsBabelExtractPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/babel');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\nconst resolvePluginPath = (\n pluginPath: string,\n intlayerConfig: IntlayerConfig,\n isTurbopackEnabled: boolean\n): string => {\n const requireFunction = intlayerConfig.build?.require ?? getProjectRequire();\n const pluginPathResolved = requireFunction?.resolve(pluginPath);\n\n if (isTurbopackEnabled)\n // Relative path for turbopack\n return normalizePath(`./${relative(process.cwd(), pluginPathResolved)}`);\n\n // Absolute path for webpack\n return pluginPathResolved;\n};\n\n/**\n * Extensions the extraction loader is registered for.\n *\n * The compiler reads its content out of JSX — element text and the\n * translatable attributes — so a file with no JSX in it has nothing to give,\n * and `*.ts` is left out. `*.js` is in because a plain-JavaScript Next.js app\n * writes its components there.\n */\nconst EXTRACTOR_LOADER_EXTENSIONS = ['tsx', 'jsx', 'js'] as const;\n\n/**\n * The subset safe to register as a Turbopack rule on any Next.js version.\n *\n * Turbopack rules match every module it processes, dependencies included, and\n * only Next.js 16 can express \"skip `node_modules`\" (see\n * {@link TURBOPACK_PROJECT_FILES_CONDITION}). Below that, `*.js` would hand\n * every dependency file to a Node loader worker, so it is left out rather than\n * made to cost a cold dev start.\n */\nconst TURBOPACK_ALWAYS_SAFE_EXTENSIONS = ['tsx', 'jsx'] as const;\n\n/**\n * Restricts a Turbopack rule to the project's own files. `foreign` is\n * Turbopack's builtin condition for a module inside `node_modules`.\n *\n * Only understood from Next.js 16 on — earlier releases carry no `condition`\n * field on a rule at all.\n */\nconst TURBOPACK_PROJECT_FILES_CONDITION = { not: 'foreign' } as const;\n\n/** Mode reported to the extraction loader, which cannot read the command. */\ntype ExtractorLoaderMode = 'dev' | 'build';\n\n/**\n * Whether the Intlayer compiler should extract content for this command.\n *\n * Mirrors `getExtractPluginOptions`, which the loader re-evaluates on its side:\n * this is only about not registering a loader that would do nothing.\n */\nconst getIsCompilerEnabled = (\n intlayerConfig: IntlayerConfig,\n isDevCommand: boolean\n): boolean => {\n const enabled = intlayerConfig.compiler?.enabled ?? COMPILER_ENABLED;\n\n if (enabled === 'build-only') return !isDevCommand;\n\n return enabled !== false;\n};\n\n/**\n * Describes the extraction loader for both bundlers, or `null` when the\n * compiler is off or `@intlayer/babel` is not installed.\n *\n * The loader replaces the `babel.config.js` the compiler used to need on\n * Next.js: Turbopack never reads a Babel config, and on webpack the mere\n * presence of one opts the whole project out of SWC — including the\n * `@intlayer/swc` optimize pass.\n */\nconst getExtractorLoader = (\n intlayerConfig: IntlayerConfig,\n isTurbopackEnabled: boolean,\n isDevCommand: boolean\n): { loaderPath: string; mode: ExtractorLoaderMode } | null => {\n if (!getIsCompilerEnabled(intlayerConfig, isDevCommand)) return null;\n if (!getIsBabelExtractPluginAvailable(intlayerConfig)) return null;\n\n try {\n return {\n loaderPath: resolvePluginPath(\n 'next-intlayer/extractor-loader',\n intlayerConfig,\n isTurbopackEnabled\n ),\n mode: isDevCommand ? 'dev' : 'build',\n };\n } catch {\n // An installed `next-intlayer` that cannot resolve its own subpath means a\n // version predating the loader — the Babel setup still applies there.\n return null;\n }\n};\n\ntype GetPruneConfigParams = {\n intlayerConfig: IntlayerConfig;\n isBuildCommand: boolean;\n isTurbopackEnabled: boolean;\n isDevCommand: boolean;\n isGteNext13: boolean;\n /** Whether the resolved Next.js version can load the Wasm plugin. */\n isSwcPluginSupported: boolean;\n /** Resolved Next.js version, reported when the plugin has to stand down. */\n nextVersion: string;\n compatCallers?: CallerDescriptor[];\n fieldRenameMap?: FieldRenameMapByDictionaryKey;\n};\n\nconst getPruneConfig = ({\n intlayerConfig,\n isBuildCommand,\n isTurbopackEnabled,\n isDevCommand,\n isGteNext13,\n isSwcPluginSupported,\n nextVersion,\n compatCallers,\n fieldRenameMap,\n}: GetPruneConfigParams): Partial<NextConfig> => {\n const { optimize, minify, purge } = intlayerConfig.build;\n const importMode =\n intlayerConfig.build.importMode ?? intlayerConfig.dictionary?.importMode;\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n } = intlayerConfig.system;\n const { baseDir } = intlayerConfig.system;\n const logger = getAppLogger(intlayerConfig);\n\n if (optimize === false) {\n return {};\n }\n if (optimize === undefined && !isBuildCommand) {\n return {};\n }\n\n if (!isGteNext13) return {};\n\n const isSwcPluginAvailable = getIsSwcPluginAvailable(intlayerConfig);\n\n runOnce(\n join(baseDir, '.intlayer', 'cache', 'intlayer-prune-plugin-enabled.lock'),\n () => {\n if (isSwcPluginAvailable && !isSwcPluginSupported) {\n logger(\n [\n `Build optimization ${colorize('disabled', ANSIColors.GREY_DARK)}:`,\n colorize('@intlayer/swc', ANSIColors.GREY_LIGHT),\n colorize(\n `cannot run on Next.js ${nextVersion} — its bundled SWC predates the`,\n ANSIColors.GREY\n ),\n colorize(\n 'stable Wasm plugin ABI. Upgrade to Next.js',\n ANSIColors.GREY\n ),\n colorize(MINIMUM_SWC_PLUGIN_NEXT_VERSION, ANSIColors.BLUE),\n colorize('or later to enable it.', ANSIColors.GREY),\n ],\n { level: 'warn' }\n );\n } else if (isSwcPluginAvailable) {\n logger([\n `Build optimization ${colorize('enabled', ANSIColors.GREEN)}`,\n colorize(`(import mode:`, ANSIColors.GREY_DARK),\n colorize(importMode ?? IMPORT_MODE, ANSIColors.BLUE),\n colorize(`)`, ANSIColors.GREY_DARK),\n ]);\n\n // The purge / minify pipeline stands down — with its own explanation —\n // when `@intlayer/babel` (which runs it) is not resolvable. The editor\n // only stands the field-rename step down, not the pipeline.\n const isPurgePipelineEnabled =\n getIsPurgePipelineAvailable(intlayerConfig);\n\n // The purge pipeline reports the field-rename step standing down when\n // the editor is enabled, so this line stays a plain one.\n if (isPurgePipelineEnabled && minify) {\n logger(\n `Dictionary minification ${colorize('enabled', ANSIColors.GREEN)}`\n );\n }\n\n if (isPurgePipelineEnabled && purge) {\n logger(\n `Dictionary purge unused keys ${colorize('enabled', ANSIColors.GREEN)}`\n );\n }\n } else {\n logger([\n colorize('Recommended: Install', ANSIColors.GREY),\n colorize('@intlayer/swc', ANSIColors.GREY_LIGHT),\n colorize(\n 'package to enable build optimization. See documentation:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://intlayer.org/docs/bundle-optimization',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n runOnce(\n join(\n baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-compiler-plugin-enabled.lock'\n ),\n () => {\n const isBabelExtractPluginAvailable =\n getIsBabelExtractPluginAvailable(intlayerConfig);\n\n if (isBabelExtractPluginAvailable) {\n let isEnabled = intlayerConfig.compiler?.enabled ?? true;\n\n if (isEnabled === 'build-only') {\n isEnabled = !isDevCommand;\n }\n\n // Only the enabled state is reported: disabling the compiler is an\n // explicit configuration choice, so announcing it on every build adds\n // noise without telling the user anything they did not ask for.\n if (isEnabled) {\n logger('Intlayer compiler enabled');\n }\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n // Registering the plugin on a host that cannot load it is not a degraded\n // build but a failed one: SWC aborts with `failed to invoke plugin`. Standing\n // down leaves the app running off the runtime dictionary registry, which the\n // transform would otherwise have emptied.\n if (!isSwcPluginAvailable || !isSwcPluginSupported) {\n return {};\n }\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n\n const unmergedDictionariesEntryPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n\n const fetchDictionariesEntryPath = join(mainDir, 'fetch_dictionaries.mjs');\n\n const filesListPattern = buildComponentFilesList(intlayerConfig);\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n ];\n\n const dictionaries = getDictionaries(intlayerConfig);\n\n const dictionaryModeMap: Record<string, 'static' | 'dynamic' | 'fetch'> = {};\n\n (Object.values(dictionaries) as Dictionary[]).forEach((dictionary) => {\n dictionaryModeMap[dictionary.key] =\n dictionary.importMode ?? importMode ?? IMPORT_MODE;\n });\n\n // Dictionaries holding `nest()` references: their static import is re-pointed\n // at the companion module carrying the nest targets.\n const nestingDictionaryKeys = [\n ...getNestedDictionaryGraph(Object.values(dictionaries)).keys(),\n ];\n\n return {\n experimental: {\n swcPlugins: [\n [\n resolvePluginPath(\n '@intlayer/swc',\n intlayerConfig,\n isTurbopackEnabled\n ),\n {\n dictionariesDir,\n dictionariesEntryPath,\n unmergedDictionariesEntryPath,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n fetchDictionariesDir,\n fetchDictionariesEntryPath,\n importMode,\n filesList,\n replaceDictionaryEntry: true,\n nestingDictionaryKeys,\n dictionaryModeMap,\n // Compat adapters reach the Wasm plugin as descriptors serialised\n // to its wire format; with none injected the option is empty and\n // the plugin runs the base intlayer rewrite alone.\n extraCallers: toSwcExtraCallers(compatCallers ?? []),\n // Rewrites `content.title` → `content.a` to match the compiled\n // dictionaries the `build.minify` pass already renamed.\n fieldRenameMap: fieldRenameMap ?? {},\n logLevel: resolveSwcLogLevel(intlayerConfig),\n },\n ],\n ],\n },\n };\n};\n\nconst getCommandsEvent = () => {\n const lifecycleEvent = process.env['npm_lifecycle_event'];\n const lifecycleScript = process.env['npm_lifecycle_script'] ?? '';\n\n const isDevCommand =\n lifecycleEvent === 'dev' ||\n process.argv.some((arg) => arg === 'dev') ||\n /(^|\\s)(next\\s+)?dev(\\s|$)/.test(lifecycleScript);\n\n const isBuildCommand =\n lifecycleEvent === 'build' ||\n process.argv.some((arg) => arg === 'build') ||\n /(^|\\s)(next\\s+)?build(\\s|$)/.test(lifecycleScript);\n\n const isStartCommand =\n lifecycleEvent === 'start' ||\n process.argv.some((arg) => arg === 'start') ||\n /(^|\\s)(next\\s+)?start(\\s|$)/.test(lifecycleScript);\n\n return {\n isDevCommand,\n isBuildCommand,\n isStartCommand,\n };\n};\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\ntype WithIntlayerOptions = GetConfigurationOptions & {\n enableTurbopack?: boolean;\n /**\n * Compat-adapter caller descriptors injected by a compat package's bundler\n * plugin (e.g. `@intlayer/next-intl/plugin`). They drive both the SWC\n * optimize rewrite and the Node-side usage analysis, so one registry slice\n * is all a compat plugin has to pass.\n */\n compatCallers?: CallerDescriptor[];\n\n /**\n * Field-rename tables produced by the purge / minify pipeline, forwarded to\n * the `@intlayer/swc` plugin so it rewrites source accesses to match the\n * renamed dictionaries.\n *\n * @internal Set by {@link withIntlayer}; `withIntlayerSync` on its own runs\n * no dictionary rewrite, so it leaves this unset and no rename is applied.\n */\n fieldRenameMap?: FieldRenameMapByDictionaryKey;\n};\n\n/**\n * Pin the env file used to resolve the Intlayer configuration to the Next.js\n * command being run (`dev` → `development`, `build`/`start` → `production`).\n *\n * Next.js loads the config file in several processes during a single command\n * (the main `build` process plus one or more Turbopack/webpack workers), and\n * `process.env.NODE_ENV` is not guaranteed to hold the same value in all of\n * them. Since `getConfiguration` falls back to `NODE_ENV` to pick its env file\n * (`.env.development.local` vs `.env.production.local`), those processes could\n * otherwise resolve *different* env values (e.g. `applicationURL`,\n * `INTLAYER_CLIENT_ID`). The resulting configuration would differ between\n * processes, defeating the `isCachedConfigurationUpToDate` check and forcing a\n * redundant full dictionary rebuild.\n *\n * Passing an explicit `env` keeps configuration resolution deterministic across\n * every process of the command. An `env` already set by the caller is\n * respected, and when the command cannot be determined we fall back to\n * `getConfiguration`'s own default (i.e. leave `env` unset).\n */\nconst resolveConfigOptions = (\n configOptions?: WithIntlayerOptions\n): WithIntlayerOptions | undefined => {\n // Respect an explicit override from the caller (idempotent on re-entry).\n if (configOptions?.env) return configOptions;\n\n const { isDevCommand, isBuildCommand, isStartCommand } = getCommandsEvent();\n\n const env = isDevCommand\n ? 'development'\n : isBuildCommand || isStartCommand\n ? 'production'\n : undefined;\n\n if (!env) return configOptions;\n\n return {\n ...configOptions,\n env,\n };\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayerSync(nextConfig)\n * ```\n */\nexport const withIntlayerSync = <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T,\n configOptions?: WithIntlayerOptions\n): NextConfig & T => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const resolvedConfigOptions = resolveConfigOptions(configOptions);\n\n const intlayerConfig = getConfiguration(resolvedConfigOptions);\n\n logConfigDetails(resolvedConfigOptions);\n\n const appLogger = getAppLogger(intlayerConfig);\n\n const {\n nextVersion,\n isGteNext13,\n isGteNext15,\n isGteNext16,\n isTurbopackStable,\n isSwcPluginSupported,\n } = getNextVersionFlags(intlayerConfig);\n\n const isTurbopackEnabledFromCommand = isGteNext16\n ? // Next@16 enables turbopack by default; disable with --webpack\n !process.env['npm_lifecycle_script']?.includes('--webpack')\n : // Next@15 uses --turbopack, Next@14 uses --turbo\n process.env['npm_lifecycle_script']?.includes('--turbo');\n\n const isTurbopackEnabled =\n configOptions?.enableTurbopack ?? isTurbopackEnabledFromCommand;\n\n if (isTurbopackEnabled && typeof nextConfig.webpack !== 'undefined') {\n appLogger(\n 'Turbopack is enabled but a custom webpack config is present. It will be ignored.'\n );\n }\n\n const { isBuildCommand, isDevCommand } = getCommandsEvent();\n\n const extractorLoader = getExtractorLoader(\n intlayerConfig,\n isTurbopackEnabled ?? false,\n isDevCommand\n );\n\n // Watches on both bundlers: Turbopack cannot run a webpack plugin, and on\n // webpack this replaces `IntlayerPlugin`, whose watcher took no ownership\n // lock and so kept rebuilding alongside a parallel `intlayer watch`.\n if (isDevCommand) {\n startContentWatcher(intlayerConfig);\n }\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => `./${value}`, // prefix by './' to consider the path as relative to the project root. This is necessary for turbopack to work correctly.\n }),\n\n rules: {\n '*.node': {\n as: '*.node',\n loaders: ['node-loader'],\n },\n\n // Turbopack serialises loader options to JSON, so the loader reads the\n // Intlayer configuration itself and only the command mode is passed here.\n //\n // No `as`: it renames the module, and naming the extension the rule\n // already matches turns `Component.tsx` into `Component.tsx.tsx`, which\n // then fails to resolve. Left out, Turbopack keeps handling the loader\n // output as the TSX/JSX it still is.\n ...(extractorLoader\n ? Object.fromEntries(\n (isGteNext16\n ? EXTRACTOR_LOADER_EXTENSIONS\n : TURBOPACK_ALWAYS_SAFE_EXTENSIONS\n ).map((extension) => [\n `*.${extension}`,\n {\n loaders: [\n {\n loader: extractorLoader.loaderPath,\n options: { mode: extractorLoader.mode },\n },\n ],\n ...(isGteNext16\n ? { condition: TURBOPACK_PROJECT_FILES_CONDITION }\n : {}),\n },\n ])\n )\n : {}),\n },\n };\n\n const serverExternalPackages = [\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n 'recast',\n '@intlayer/engine',\n '@intlayer/webpack',\n ];\n\n let env: Record<string, string> = {};\n\n if (isBuildCommand) {\n const dictionaries = getDictionaries(intlayerConfig);\n\n if (Object.keys(dictionaries).length === 0) {\n appLogger('No dictionaries found. Please check your configuration.', {\n isVerbose: true,\n });\n }\n\n const unusedNodeTypes = getUnusedNodeTypes(dictionaries);\n\n if (unusedNodeTypes && unusedNodeTypes.length > 0) {\n appLogger(\n [\n 'Filtering out unused logic:',\n unusedNodeTypes\n .filter(\n (key) => !['reactNode', 'solidNode', 'preactNode'].includes(key)\n )\n .map((key) => colorize(key, ANSIColors.BLUE))\n .join(', '),\n ],\n {\n isVerbose: true,\n }\n );\n }\n\n env = {\n ...env,\n\n // Tree shacking based on unused node types\n ...formatNodeTypeToEnvVar(unusedNodeTypes),\n\n // Selects the local `nest()` resolver, which reads the nest targets\n // attached to each dictionary by the optimize transform instead of the\n // registry that transform empties.\n ...formatOptimizedNestingEnvVar(intlayerConfig.build.optimize !== false),\n\n // Tree shacking the dictionary selector logic\n // (collections / variants)\n ...formatDictionarySelectorEnvVar(getHasDictionarySelector(dictionaries)),\n\n // Tree shacking based on config\n ...getConfigEnvVars(intlayerConfig),\n };\n }\n\n const getNewConfig = (): Partial<NextConfig> => {\n let config: Partial<NextConfig> = {\n env,\n };\n\n if (isGteNext15) {\n config = {\n ...config,\n serverExternalPackages,\n };\n }\n\n if (isGteNext13 && !isGteNext15) {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n serverComponentsExternalPackages: serverExternalPackages,\n },\n };\n }\n\n if (isTurbopackEnabled) {\n if (isGteNext15 && isTurbopackStable) {\n config = {\n ...config,\n turbopack: turboConfig,\n };\n } else {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n // @ts-ignore exist in next@14\n turbo: turboConfig,\n },\n };\n }\n } else {\n config = {\n ...config,\n webpack: (config: WebpackParams['0'], options: WebpackParams[1]) => {\n // If the user has defined their own webpack config, call it\n if (typeof nextConfig.webpack === 'function') {\n config = nextConfig.webpack(config, options);\n }\n\n // Rspack set external as false by default\n // Overwrite it to allow pushing the desired externals\n if (config.externals === false) {\n config.externals = [];\n }\n\n // Mark server-only modules as externals (function form handles subpaths)\n const externalExact = new Set([\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n 'recast',\n ]);\n const externalPrefixes = ['@intlayer/engine', '@intlayer/webpack'];\n config.externals.push(\n (\n { request }: { request?: string },\n callback: (err: Error | null, result?: string) => void\n ) => {\n if (\n request &&\n (externalExact.has(request) ||\n externalPrefixes.some(\n (prefix) =>\n request === prefix || request.startsWith(`${prefix}/`)\n ))\n ) {\n return callback(null, `commonjs ${request}`);\n }\n callback(null);\n }\n );\n\n // Use `node-loader` for any `.node` files\n config.module.rules.push({\n test: /\\.node$/,\n loader: 'node-loader',\n });\n\n // `enforce: 'pre'` puts the extraction ahead of `next-swc-loader`,\n // so the loader reads the original JSX rather than its compiled\n // output. Declaring it here (instead of in a `babel.config.js`)\n // keeps Next.js on SWC, and with it the `@intlayer/swc` optimize\n // pass a Babel config would silently disable.\n if (extractorLoader) {\n config.module.rules.push({\n test: new RegExp(\n `\\\\.(${EXTRACTOR_LOADER_EXTENSIONS.join('|')})$`\n ),\n exclude: /node_modules/,\n enforce: 'pre',\n use: [\n {\n loader: extractorLoader.loaderPath,\n options: { mode: extractorLoader.mode },\n },\n ],\n });\n }\n\n // Always alias on the server (node/edge) for stability.\n // On the client, alias only when not using live sync.\n config.resolve.alias = {\n ...config.resolve.alias,\n ...getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n };\n\n return config;\n },\n };\n }\n\n return config;\n };\n\n const pruneConfig: Partial<NextConfig> = getPruneConfig({\n intlayerConfig,\n isBuildCommand,\n isTurbopackEnabled: isTurbopackEnabled ?? false,\n isDevCommand,\n isGteNext13,\n isSwcPluginSupported,\n nextVersion,\n compatCallers: configOptions?.compatCallers,\n fieldRenameMap: configOptions?.fieldRenameMap,\n });\n\n const intlayerNextConfig: Partial<NextConfig> = defu(\n getNewConfig(),\n pruneConfig\n );\n\n // Merge the new config with the user's config\n const result = defu(intlayerNextConfig, nextConfig) as NextConfig & T;\n\n return result;\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n *\n * > Node withIntlayer is a promise function. Use withIntlayerSync instead if you want to use it synchronously.\n * > Using the promise allows to prepare the intlayer dictionaries before the build starts.\n *\n */\nexport const withIntlayer = async <T extends NextConfig | Partial<NextConfig>>(\n nextConfig: T | Promise<T> = {} as T,\n configOptions?: WithIntlayerOptions\n): Promise<NextConfig & T> => {\n const { isBuildCommand, isDevCommand, isStartCommand } = getCommandsEvent();\n\n process.env.INTLAYER_IS_DEV_COMMAND = isDevCommand ? 'true' : 'false';\n\n const resolvedConfigOptions = resolveConfigOptions(configOptions);\n\n const intlayerConfig = getConfiguration(resolvedConfigOptions);\n\n const { mode } = intlayerConfig.build;\n\n // Only call prepareIntlayer during `dev` or `build` (not during `start`)\n // If prod: clean and rebuild once\n // If dev: rebuild only once if it's more than 1 hour since last rebuild\n if (!isStartCommand && (isDevCommand || isBuildCommand || mode === 'auto')) {\n // prepareIntlayer use runOnce to ensure to run only once because will run twice on client and server side otherwise\n await prepareIntlayer(intlayerConfig, {\n clean: isBuildCommand,\n cacheTimeoutMs: isBuildCommand\n ? 1000 * 30 // 30 seconds for build (to ensure to rebuild all dictionaries)\n : 1000 * 60 * 60, // 1 hour for dev (default cache timeout)\n env: isBuildCommand ? 'prod' : 'dev',\n });\n }\n\n // Remove unused content fields and rename the remaining ones to short\n // aliases, then hand the rename tables to `withIntlayerSync` so the SWC\n // plugin rewrites the matching source accesses. Only meaningful for a\n // production build — the optimize pipeline is off during `next dev`.\n //\n // `isSwcPluginUsable` gates the dictionary rewrite on the plugin actually\n // running: it is the only half that fixes up the source, so minifying without\n // it would leave the code reading field names the dictionaries no longer have.\n const { isSwcPluginSupported } = getNextVersionFlags(intlayerConfig);\n\n const fieldRenameMap = isBuildCommand\n ? await prepareSwcOptimization(intlayerConfig, {\n configOptions: resolvedConfigOptions,\n compatCallers: configOptions?.compatCallers,\n isSwcPluginUsable:\n isSwcPluginSupported && getIsSwcPluginAvailable(intlayerConfig),\n })\n : {};\n\n const nextConfigResolved = await nextConfig;\n\n return withIntlayerSync(nextConfigResolved, {\n ...resolvedConfigOptions,\n fieldRenameMap,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAM,uBAAuB,mBAAmC;CAC9D,IAAI,cAAc,gBAAgB;CAElC,IAAI;EAIF,eAFE,eAAe,OAAO,WAAW,kBAAkB,EAC1B,CAAC,mBACZ,CAAC,CAAC;CACpB,QAAQ,CAER;CAEA,OAAO;EACL;EACA,aAAa,gBAAgB,aAAa,KAAK,QAAQ;EACvD,aAAa,gBAAgB,aAAa,KAAK,QAAQ;EACvD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AgB,eAAe;CACjC,CAAC;CAED,MAAM,qBAA0C,KAC9C,aAAa,GACb,WACF;CAKA,OAFe,KAAK,oBAAoB,UAE5B;AACd;;;;;;;;;;;;;;;;AAiBA,MAAa,eAAe,OAC1B,aAA6B,CAAC,GAC9B,kBAC4B;CAC5B,MAAM,EAAE,gBAAgB,cAAc,mBAAmB,iBAAiB;CAE1E,QAAQ,IAAI,0BAA0B,eAAe,SAAS;CAE9D,MAAM,wBAAwB,qBAAqB,aAAa;CAEhE,MAAM,iBAAiB,iBAAiB,qBAAqB;CAE7D,MAAM,EAAE,SAAS,eAAe;CAKhC,IAAI,CAAC,mBAAmB,gBAAgB,kBAAkB,SAAS,SAEjE,MAAM,gBAAgB,gBAAgB;EACpC,OAAO;EACP,gBAAgB,iBACZ,MACA;EACJ,KAAK,iBAAiB,SAAS;CACjC,CAAC;CAWH,MAAM,EAAE,yBAAyB,oBAAoB,cAAc;CAEnE,MAAM,iBAAiB,iBACnB,MAAM,uBAAuB,gBAAgB;EAC3C,eAAe;EACf,eAAe,eAAe;EAC9B,mBACE,wBAAwB,wBAAwB,cAAc;CAClE,CAAC,IACD,CAAC;CAEL,MAAM,qBAAqB,MAAM;CAEjC,OAAO,iBAAiB,oBAAoB;EAC1C,GAAG;EACH;CACF,CAAC;AACH"}
@@ -1,5 +1,5 @@
1
+ import { IntlayerConfig } from "@intlayer/types/config";
1
2
  import { Locale } from "@intlayer/types/allLocales";
2
3
  import "/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/@babel+core@8.0.1/node_modules/@babel/core/lib/index.js";
3
4
  import "/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/@babel+types@8.0.4/node_modules/@babel/types/lib/index.js";
4
- import { IntlayerConfig } from "@intlayer/types/config";
5
5
  import "@intlayer/types/filePathPattern";
@@ -1,6 +1,6 @@
1
1
  import "./pruneContext.js";
2
2
  import "./babel-plugin-intlayer-usage-analyzer.js";
3
+ import { IntlayerConfig } from "@intlayer/types/config";
3
4
  import "@intlayer/core/dictionaryManipulator";
4
5
  import "/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/@babel+core@8.0.1/node_modules/@babel/core/lib/index.js";
5
- import "/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/@babel+types@8.0.4/node_modules/@babel/types/lib/index.js";
6
- import { IntlayerConfig } from "@intlayer/types/config";
6
+ import "/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/@babel+types@8.0.4/node_modules/@babel/types/lib/index.js";
@@ -1,2 +1,2 @@
1
- import { Dictionary } from "@intlayer/types/dictionary";
2
- import { IntlayerConfig } from "@intlayer/types/config";
1
+ import { IntlayerConfig } from "@intlayer/types/config";
2
+ import { Dictionary } from "@intlayer/types/dictionary";
@@ -1,3 +1,3 @@
1
1
  import "./utils/index.js";
2
- import { GetConfigurationOptions } from "@intlayer/config/node";
3
- import { IntlayerConfig } from "@intlayer/types/config";
2
+ import { IntlayerConfig } from "@intlayer/types/config";
3
+ import { GetConfigurationOptions } from "@intlayer/config/node";
@@ -1,3 +1,3 @@
1
- import { Locale } from "@intlayer/types/allLocales";
2
1
  import { IntlayerConfig } from "@intlayer/types/config";
2
+ import { Locale } from "@intlayer/types/allLocales";
3
3
  import "@intlayer/types/filePathPattern";
@@ -1,3 +1,4 @@
1
+ import { Locale } from "./intlayer/dist/types/index.js";
1
2
  //#region src/generateStaticParams.d.ts
2
3
  /**
3
4
  * Generates static parameters for Next.js's dynamic routes based on the configured locales.
@@ -17,6 +18,8 @@
17
18
  * }
18
19
  * ```
19
20
  */
20
- export declare const generateStaticParams: () => any;
21
+ export declare const generateStaticParams: () => {
22
+ locale: Locale;
23
+ }[];
21
24
  //#endregion
22
25
  //# sourceMappingURL=generateStaticParams.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generateStaticParams.d.ts","names":[],"sources":["../../src/generateStaticParams.ts"],"mappings":";;;;;;;;;;;;;;;;;;;qBAsBa"}
1
+ {"version":3,"file":"generateStaticParams.d.ts","names":[],"sources":["../../src/generateStaticParams.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;qBAsBa;UAAA"}
@@ -0,0 +1,14 @@
1
+ import { DeclaredLocales } from "@intlayer/types/module_augmentation";
2
+ import { IntlayerConfig } from "@intlayer/types/config";
3
+ import { Dictionary } from "@intlayer/types/dictionary";
4
+ import { Locale as Locale$1 } from "@intlayer/types/allLocales";
5
+ import "@intlayer/types/locales";
6
+ import "@intlayer/config/built";
7
+ import "@intlayer/core/file";
8
+ import "@intlayer/core/formatters";
9
+ import "@intlayer/core/interpreter";
10
+ import "@intlayer/core/localization";
11
+ import "@intlayer/core/markdown";
12
+ import "@intlayer/core/transpiler";
13
+ import "@intlayer/core/utils";
14
+ export type { Locale$1 as Locale };
@@ -1,9 +1,9 @@
1
1
  import { SerializedFieldRenameMap } from "../@intlayer/babel/dist/types/babel-plugin-intlayer-field-rename.js";
2
2
  import "../@intlayer/babel/dist/types/index.js";
3
+ import { IntlayerConfig } from "@intlayer/types/config";
3
4
  import { Dictionary } from "@intlayer/types/dictionary";
4
5
  import { CallerDescriptor } from "@intlayer/config/callers";
5
6
  import { GetConfigurationOptions } from "@intlayer/config/node";
6
- import { IntlayerConfig } from "@intlayer/types/config";
7
7
  //#region src/server/prepareSwcOptimization.d.ts
8
8
  /**
9
9
  * Field-rename tables keyed by dictionary key, forwarded to the
@@ -1 +1 @@
1
- {"version":3,"file":"startContentWatcher.d.ts","names":[],"sources":["../../../src/server/startContentWatcher.ts"],"mappings":";;qBA8Ga,sBAAmB,eAAmB"}
1
+ {"version":3,"file":"startContentWatcher.d.ts","names":[],"sources":["../../../src/server/startContentWatcher.ts"],"mappings":";;qBAwHa,sBAAmB,eAAmB"}
@@ -1,6 +1,6 @@
1
1
  import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
2
- import { useDictionary as useDictionary$1 } from "react-intlayer/server";
3
2
  import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup } from "@intlayer/types/dictionary";
3
+ import { useDictionary as useDictionary$1 } from "react-intlayer/server";
4
4
  //#region src/server/useDictionary.d.ts
5
5
  /**
6
6
  * On the server side, hook that transforms a dictionary (or qualified
@@ -1,6 +1,6 @@
1
1
  import { DeclaredLocales, LocalesValues, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
2
- import { useDictionaryAsync as useDictionaryAsync$1 } from "react-intlayer/server";
3
2
  import { Dictionary } from "@intlayer/types/dictionary";
3
+ import { useDictionaryAsync as useDictionaryAsync$1 } from "react-intlayer/server";
4
4
  //#region src/server/useDictionaryAsync.d.ts
5
5
  /**
6
6
  * On the server side, hook that transforms a dictionary and returns the content
@@ -1,6 +1,6 @@
1
1
  import { DeclaredLocales, LocalesValues, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
2
- import { useDictionaryDynamic as useDictionaryDynamic$1 } from "react-intlayer/server";
3
2
  import { Dictionary, DictionarySelector } from "@intlayer/types/dictionary";
3
+ import { useDictionaryDynamic as useDictionaryDynamic$1 } from "react-intlayer/server";
4
4
  import { QualifiedDynamicLoaderMap } from "@intlayer/core/dictionaryManipulator";
5
5
  //#region src/server/useDictionaryDynamic.d.ts
6
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../../src/server/useLocale.ts"],"mappings":";;YAIY;EACV,QAAQ;EACR,eAAe;EACf,kBAAkB;;;;;;;;;;;qBAYP,iBAAgB"}
1
+ {"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../../src/server/useLocale.ts"],"mappings":";;YAIY;EACV,QAAQ;EACR,eAAe;EACf,kBAAkB;;;;;;;;;;;qBAcP,iBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"file":"withIntlayer.d.ts","names":[],"sources":["../../../src/server/withIntlayer.ts"],"mappings":";;;;;;KAodK,sBAAsB;EACzB;;;;;;;EAOA,gBAAgB;;;;;;;;;EAUhB,iBAAiB;;;;;;;;;;;;;qBAuDN,mBAAoB,UAAU,QAAQ,aAAW,aAChD,GAAC,gBACG,wBACf,aAAa;;;;;;;;;;;;;;;;qBA2UH,eAAsB,UAAU,aAAa,QAAQ,aAAW,aAC/D,IAAI,QAAQ,IAAE,gBACV,wBACf,QAAQ,aAAa"}
1
+ {"version":3,"file":"withIntlayer.d.ts","names":[],"sources":["../../../src/server/withIntlayer.ts"],"mappings":";;;;;;KAkdK,sBAAsB;EACzB;;;;;;;EAOA,gBAAgB;;;;;;;;;EAUhB,iBAAiB;;;;;;;;;;;;;qBAuDN,mBAAoB,UAAU,QAAQ,aAAW,aAChD,GAAC,gBACG,wBACf,aAAa;;;;;;;;;;;;;;;;qBAkUH,eAAsB,UAAU,aAAa,QAAQ,aAAW,aAC/D,IAAI,QAAQ,IAAE,gBACV,wBACf,QAAQ,aAAa"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intlayer",
3
- "version": "9.5.0",
3
+ "version": "9.5.2",
4
4
  "private": false,
5
5
  "description": "Simplify internationalization i18n in Next.js with context providers, hooks, locale detection, and multilingual content integration.",
6
6
  "keywords": [
@@ -146,18 +146,17 @@
146
146
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
147
147
  },
148
148
  "dependencies": {
149
- "@intlayer/config": "9.5.0",
150
- "@intlayer/core": "9.5.0",
151
- "@intlayer/dictionaries-entry": "9.5.0",
152
- "@intlayer/engine": "9.5.0",
153
- "@intlayer/types": "9.5.0",
154
- "@intlayer/webpack": "9.5.0",
149
+ "@intlayer/config": "9.5.2",
150
+ "@intlayer/core": "9.5.2",
151
+ "@intlayer/dictionaries-entry": "9.5.2",
152
+ "@intlayer/engine": "9.5.2",
153
+ "@intlayer/types": "9.5.2",
155
154
  "defu": "6.1.7",
156
155
  "node-loader": "2.1.0",
157
- "react-intlayer": "9.5.0"
156
+ "react-intlayer": "9.5.2"
158
157
  },
159
158
  "devDependencies": {
160
- "@types/node": "26.5.0",
159
+ "@types/node": "^22",
161
160
  "@types/react": ">=16.0.0",
162
161
  "@types/react-dom": ">=16.0.0",
163
162
  "@utils/ts-config": "1.0.4",