next-intlayer 5.4.2 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,7 @@ __export(server_exports, {
24
24
  t: () => import_server.t,
25
25
  useDictionary: () => import_server.useDictionary,
26
26
  useIntlayer: () => import_server.useIntlayer,
27
+ useLocale: () => import_server.useLocale,
27
28
  withIntlayer: () => import_withIntlayer.withIntlayer
28
29
  });
29
30
  module.exports = __toCommonJS(server_exports);
@@ -37,6 +38,7 @@ var import_withIntlayer = require('./withIntlayer.cjs');
37
38
  t,
38
39
  useDictionary,
39
40
  useIntlayer,
41
+ useLocale,
40
42
  withIntlayer
41
43
  });
42
44
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\n useDictionary,\n IntlayerServer,\n IntlayerServerProvider,\n locale,\n useIntlayer,\n t,\n} from 'react-intlayer/server';\nexport { withIntlayer } from './withIntlayer';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAOO;AACP,0BAA6B;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\n IntlayerServer,\n IntlayerServerProvider,\n locale,\n t,\n useDictionary,\n useIntlayer,\n useLocale,\n} from 'react-intlayer/server';\nexport { withIntlayer } from './withIntlayer';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAQO;AACP,0BAA6B;","names":[]}
@@ -50,12 +50,18 @@ const withIntlayer = (nextConfig = {}) => {
50
50
  const { mainDir, configDir, baseDir } = intlayerConfig.content;
51
51
  const dictionariesPath = (0, import_path.join)(mainDir, "dictionaries.mjs");
52
52
  const relativeDictionariesPath = (0, import_path.relative)(baseDir, dictionariesPath);
53
+ const unmergedDictionariesPath = (0, import_path.join)(mainDir, "unmerged_dictionaries.mjs");
54
+ const relativeUnmergedDictionariesPath = (0, import_path.relative)(
55
+ baseDir,
56
+ unmergedDictionariesPath
57
+ );
53
58
  const configurationPath = (0, import_path.join)(configDir, "configuration.json");
54
59
  const relativeConfigurationPath = (0, import_path.relative)(baseDir, configurationPath);
55
60
  const turboConfig = {
56
61
  resolveAlias: {
57
62
  // "prefix by './' to consider the path as relative to the project root. This is necessary for turbo to work correctly."
58
63
  "@intlayer/dictionaries-entry": `./${relativeDictionariesPath}`,
64
+ "@intlayer/unmerged-dictionaries-entry": `./${relativeUnmergedDictionariesPath}`,
59
65
  "@intlayer/config/built": `./${relativeConfigurationPath}`
60
66
  },
61
67
  rules: {
@@ -101,6 +107,9 @@ const withIntlayer = (nextConfig = {}) => {
101
107
  config.resolve.alias = {
102
108
  ...config.resolve.alias,
103
109
  "@intlayer/dictionaries-entry": (0, import_path.resolve)(relativeDictionariesPath),
110
+ "@intlayer/unmerged-dictionaries-entry": (0, import_path.resolve)(
111
+ relativeUnmergedDictionariesPath
112
+ ),
104
113
  "@intlayer/config/built": (0, import_path.resolve)(relativeConfigurationPath)
105
114
  };
106
115
  config.externals.push({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { IntlayerPlugin } from '@intlayer/webpack';\nimport merge from 'deepmerge';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport { join, relative, resolve } from 'path';\nimport { compareVersions } from './compareVersion';\nimport { getNextVersion } from './getNextVertion';\n\n// Extract from the start script if --turbo or --turbopack flag is used\nconst isTurbopackEnabled =\n process.env.npm_lifecycle_script?.includes('--turbo');\nconst nextVersion = getNextVersion();\nconst isGteNext13 = compareVersions(nextVersion, '≥', '13.0.0');\nconst isGteNext15 = compareVersions(nextVersion, '≥', '15.0.0');\nconst isTurbopackStable = compareVersions(nextVersion, '≥', '15.3.0');\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variablesi\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n */\nexport const withIntlayer = <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T\n): NextConfig & T => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const intlayerConfig = getConfiguration();\n\n // Format all configuration values as environment variables\n const { mainDir, configDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n const configurationPath = join(configDir, 'configuration.json');\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: {\n // \"prefix by './' to consider the path as relative to the project root. This is necessary for turbo to work correctly.\"\n '@intlayer/dictionaries-entry': `./${relativeDictionariesPath}`,\n '@intlayer/config/built': `./${relativeConfigurationPath}`,\n },\n rules: {\n '*.node': {\n as: '*.node',\n loaders: ['node-loader'],\n },\n },\n };\n\n const serverExternalPackages = [\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n ];\n\n const newConfig: Partial<NextConfig> = {\n // Only add `serverExternalPackages` if Next.js is v15+\n ...(isGteNext15\n ? {\n // only for Next ≥15\n serverExternalPackages,\n }\n : {\n // only for Next ≥13 and <15.3\n ...(isGteNext13 && {\n serverComponentsExternalPackages: serverExternalPackages,\n }),\n }),\n\n ...(isTurbopackEnabled && {\n ...(isGteNext15 && isTurbopackStable\n ? {\n // only for Next ≥15.3\n turbopack: turboConfig,\n }\n : {\n experimental: {\n // only for Next ≥13 and <15.3\n turbo: turboConfig,\n },\n }),\n }),\n\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 // Alias the dictionary entry for all builds\n config.resolve.alias = {\n ...config.resolve.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n '@intlayer/config/built': resolve(relativeConfigurationPath),\n };\n\n // Mark these modules as externals\n config.externals.push({\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n chokidar: 'chokidar',\n fsevents: 'fsevents',\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 // Only add Intlayer plugin on server side (node runtime)\n const { isServer, nextRuntime } = options;\n\n if (isServer && nextRuntime === 'nodejs') {\n config.plugins.push(new IntlayerPlugin());\n }\n\n return config;\n },\n };\n\n // Merge the new config with the user's config\n return merge(nextConfig, newConfig) as NextConfig & T;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,qBAA+B;AAC/B,uBAAkB;AAGlB,kBAAwC;AACxC,4BAAgC;AAChC,4BAA+B;AAG/B,MAAM,qBACJ,QAAQ,IAAI,sBAAsB,SAAS,SAAS;AACtD,MAAM,kBAAc,sCAAe;AACnC,MAAM,kBAAc,uCAAgB,aAAa,UAAK,QAAQ;AAC9D,MAAM,kBAAc,uCAAgB,aAAa,UAAK,QAAQ;AAC9D,MAAM,wBAAoB,uCAAgB,aAAa,UAAK,QAAQ;AAe7D,MAAM,eAAe,CAC1B,aAAgB,CAAC,MACE;AACnB,MAAI,OAAO,eAAe,UAAU;AAClC,iBAAa,CAAC;AAAA,EAChB;AAEA,QAAM,qBAAiB,gCAAiB;AAGxC,QAAM,EAAE,SAAS,WAAW,QAAQ,IAAI,eAAe;AAEvD,QAAM,uBAAmB,kBAAK,SAAS,kBAAkB;AACzD,QAAM,+BAA2B,sBAAS,SAAS,gBAAgB;AAEnE,QAAM,wBAAoB,kBAAK,W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IAAI;AAElC,UAAI,YAAY,gBAAgB,UAAU;AACxC,eAAO,QAAQ,KAAK,IAAI,8BAAe,CAAC;AAAA,MAC1C;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAGA,aAAO,iBAAAA,SAAM,YAAY,SAAS;AACpC;","names":["merge"]}
1
+ {"version":3,"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { IntlayerPlugin } from '@intlayer/webpack';\nimport merge from 'deepmerge';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport { join, relative, resolve } from 'path';\nimport { compareVersions } from './compareVersion';\nimport { getNextVersion } from './getNextVertion';\n\n// Extract from the start script if --turbo or --turbopack flag is used\nconst isTurbopackEnabled =\n process.env.npm_lifecycle_script?.includes('--turbo');\nconst nextVersion = getNextVersion();\nconst isGteNext13 = compareVersions(nextVersion, '≥', '13.0.0');\nconst isGteNext15 = compareVersions(nextVersion, '≥', '15.0.0');\nconst isTurbopackStable = compareVersions(nextVersion, '≥', '15.3.0');\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variablesi\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n */\nexport const withIntlayer = <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T\n): NextConfig & T => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const intlayerConfig = getConfiguration();\n\n // Format all configuration values as environment variables\n const { mainDir, configDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n const unmergedDictionariesPath = join(mainDir, 'unmerged_dictionaries.mjs');\n const relativeUnmergedDictionariesPath = relative(\n baseDir,\n unmergedDictionariesPath\n );\n\n const configurationPath = join(configDir, 'configuration.json');\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: {\n // \"prefix by './' to consider the path as relative to the project root. This is necessary for turbo to work correctly.\"\n '@intlayer/dictionaries-entry': `./${relativeDictionariesPath}`,\n '@intlayer/unmerged-dictionaries-entry': `./${relativeUnmergedDictionariesPath}`,\n '@intlayer/config/built': `./${relativeConfigurationPath}`,\n },\n rules: {\n '*.node': {\n as: '*.node',\n loaders: ['node-loader'],\n },\n },\n };\n\n const serverExternalPackages = [\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n ];\n\n const newConfig: Partial<NextConfig> = {\n // Only add `serverExternalPackages` if Next.js is v15+\n ...(isGteNext15\n ? {\n // only for Next ≥15\n serverExternalPackages,\n }\n : {\n // only for Next ≥13 and <15.3\n ...(isGteNext13 && {\n serverComponentsExternalPackages: serverExternalPackages,\n }),\n }),\n\n ...(isTurbopackEnabled && {\n ...(isGteNext15 && isTurbopackStable\n ? {\n // only for Next ≥15.3\n turbopack: turboConfig,\n }\n : {\n experimental: {\n // only for Next ≥13 and <15.3\n turbo: turboConfig,\n },\n }),\n }),\n\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 // Alias the dictionary entry for all builds\n config.resolve.alias = {\n ...config.resolve.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n '@intlayer/unmerged-dictionaries-entry': resolve(\n relativeUnmergedDictionariesPath\n ),\n '@intlayer/config/built': resolve(relativeConfigurationPath),\n };\n\n // Mark these modules as externals\n config.externals.push({\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n chokidar: 'chokidar',\n fsevents: 'fsevents',\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 // Only add Intlayer plugin on server side (node runtime)\n const { isServer, nextRuntime } = options;\n\n if (isServer && nextRuntime === 'nodejs') {\n config.plugins.push(new IntlayerPlugin());\n }\n\n return config;\n },\n };\n\n // Merge the new config with the user's config\n return merge(nextConfig, newConfig) as NextConfig & T;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,qBAA+B;AAC/B,uBAAkB;AAGlB,kBAAwC;AACxC,4BAAgC;AAChC,4BAA+B;AAG/B,MAAM,qBACJ,QAAQ,IAAI,sBAAsB,SAAS,SAAS;AACtD,MAAM,kBAAc,sCAAe;AACnC,MAAM,kBAAc,uCAAgB,aAAa,UAAK,QAAQ;AAC9D,MAAM,kBAAc,uCAAgB,aAAa,UAAK,QAAQ;AAC9D,MAAM,wBAAoB,uCAAgB,aAAa,UAAK,QAAQ;AAe7D,MAAM,eAAe,CAC1B,aAAgB,CAAC,MACE;AACnB,MAAI,OAAO,eAAe,UAAU;AAClC,iBAAa,CAAC;AAAA,EAChB;AAEA,QAAM,qBAAiB,gCAAiB;AAGxC,QAAM,EAAE,SAAS,WAAW,QAAQ,IAAI,eAAe;AAEvD,QAAM,uBAAmB,kBAAK,SAAS,kBAAkB;AACzD,QAAM,+BAA2B,sBAAS,SAAS,gBAAgB;AAEnE,QAAM,+BAA2B,kBAAK,SAAS,2BAA2B;AAC1E,QAAM,uCAAmC;AAAA,IACvC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,wBAAoB,kBAAK,WAAW,oBAAoB;AAC9D,QAAM,gCAA4B,sBAAS,SAAS,iBAAiB;AAGrE,QAAM,cAAc;AAAA,IAClB,cAAc;AAAA;AAAA,MAEZ,gCAAgC,KAAK,wBAAwB;AAAA,MAC7D,yCAAyC,KAAK,gCAAgC;AAAA,MAC9E,0BAA0B,KAAK,yBAAyB;AAAA,IAC1D;AAAA,IACA,OAAO;AAAA,MACL,UAAU;AAAA,QACR,IAAI;AAAA,QACJ,SAAS,C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{
2
- useDictionary,
3
2
  IntlayerServer,
4
3
  IntlayerServerProvider,
5
4
  locale,
5
+ t,
6
+ useDictionary,
6
7
  useIntlayer,
7
- t
8
+ useLocale
8
9
  } from "react-intlayer/server";
9
10
  import { withIntlayer } from "./withIntlayer.mjs";
10
11
  export {
@@ -14,6 +15,7 @@ export {
14
15
  t,
15
16
  useDictionary,
16
17
  useIntlayer,
18
+ useLocale,
17
19
  withIntlayer
18
20
  };
19
21
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\n useDictionary,\n IntlayerServer,\n IntlayerServerProvider,\n locale,\n useIntlayer,\n t,\n} from 'react-intlayer/server';\nexport { withIntlayer } from './withIntlayer';\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\n IntlayerServer,\n IntlayerServerProvider,\n locale,\n t,\n useDictionary,\n useIntlayer,\n useLocale,\n} from 'react-intlayer/server';\nexport { withIntlayer } from './withIntlayer';\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;","names":[]}
@@ -17,12 +17,18 @@ const withIntlayer = (nextConfig = {}) => {
17
17
  const { mainDir, configDir, baseDir } = intlayerConfig.content;
18
18
  const dictionariesPath = join(mainDir, "dictionaries.mjs");
19
19
  const relativeDictionariesPath = relative(baseDir, dictionariesPath);
20
+ const unmergedDictionariesPath = join(mainDir, "unmerged_dictionaries.mjs");
21
+ const relativeUnmergedDictionariesPath = relative(
22
+ baseDir,
23
+ unmergedDictionariesPath
24
+ );
20
25
  const configurationPath = join(configDir, "configuration.json");
21
26
  const relativeConfigurationPath = relative(baseDir, configurationPath);
22
27
  const turboConfig = {
23
28
  resolveAlias: {
24
29
  // "prefix by './' to consider the path as relative to the project root. This is necessary for turbo to work correctly."
25
30
  "@intlayer/dictionaries-entry": `./${relativeDictionariesPath}`,
31
+ "@intlayer/unmerged-dictionaries-entry": `./${relativeUnmergedDictionariesPath}`,
26
32
  "@intlayer/config/built": `./${relativeConfigurationPath}`
27
33
  },
28
34
  rules: {
@@ -68,6 +74,9 @@ const withIntlayer = (nextConfig = {}) => {
68
74
  config.resolve.alias = {
69
75
  ...config.resolve.alias,
70
76
  "@intlayer/dictionaries-entry": resolve(relativeDictionariesPath),
77
+ "@intlayer/unmerged-dictionaries-entry": resolve(
78
+ relativeUnmergedDictionariesPath
79
+ ),
71
80
  "@intlayer/config/built": resolve(relativeConfigurationPath)
72
81
  };
73
82
  config.externals.push({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { IntlayerPlugin } from '@intlayer/webpack';\nimport merge from 'deepmerge';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport { join, relative, resolve } from 'path';\nimport { compareVersions } from './compareVersion';\nimport { getNextVersion } from './getNextVertion';\n\n// Extract from the start script if --turbo or --turbopack flag is used\nconst isTurbopackEnabled =\n process.env.npm_lifecycle_script?.includes('--turbo');\nconst nextVersion = getNextVersion();\nconst isGteNext13 = compareVersions(nextVersion, '≥', '13.0.0');\nconst isGteNext15 = compareVersions(nextVersion, '≥', '15.0.0');\nconst isTurbopackStable = compareVersions(nextVersion, '≥', '15.3.0');\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variablesi\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n */\nexport const withIntlayer = <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T\n): NextConfig & T => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const intlayerConfig = getConfiguration();\n\n // Format all configuration values as environment variables\n const { mainDir, configDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n const configurationPath = join(configDir, 'configuration.json');\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: {\n // \"prefix by './' to consider the path as relative to the project root. This is necessary for turbo to work correctly.\"\n '@intlayer/dictionaries-entry': `./${relativeDictionariesPath}`,\n '@intlayer/config/built': `./${relativeConfigurationPath}`,\n },\n rules: {\n '*.node': {\n as: '*.node',\n loaders: ['node-loader'],\n },\n },\n };\n\n const serverExternalPackages = [\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n ];\n\n const newConfig: Partial<NextConfig> = {\n // Only add `serverExternalPackages` if Next.js is v15+\n ...(isGteNext15\n ? {\n // only for Next ≥15\n serverExternalPackages,\n }\n : {\n // only for Next ≥13 and <15.3\n ...(isGteNext13 && {\n serverComponentsExternalPackages: serverExternalPackages,\n }),\n }),\n\n ...(isTurbopackEnabled && {\n ...(isGteNext15 && isTurbopackStable\n ? {\n // only for Next ≥15.3\n turbopack: turboConfig,\n }\n : {\n experimental: {\n // only for Next ≥13 and <15.3\n turbo: turboConfig,\n },\n }),\n }),\n\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 // Alias the dictionary entry for all builds\n config.resolve.alias = {\n ...config.resolve.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n '@intlayer/config/built': resolve(relativeConfigurationPath),\n };\n\n // Mark these modules as externals\n config.externals.push({\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n chokidar: 'chokidar',\n fsevents: 'fsevents',\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 // Only add Intlayer plugin on server side (node runtime)\n const { isServer, nextRuntime } = options;\n\n if (isServer && nextRuntime === 'nodejs') {\n config.plugins.push(new IntlayerPlugin());\n }\n\n return config;\n },\n };\n\n // Merge the new config with the user's config\n return merge(nextConfig, newConfig) as NextConfig & T;\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,OAAO,WAAW;AAGlB,SAAS,MAAM,UAAU,eAAe;AACxC,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAG/B,MAAM,qBACJ,QAAQ,IAAI,sBAAsB,SAAS,SAAS;AACtD,MAAM,cAAc,eAAe;AACnC,MAAM,cAAc,gBAAgB,aAAa,UAAK,QAAQ;AAC9D,MAAM,cAAc,gBAAgB,aAAa,UAAK,QAAQ;AAC9D,MAAM,oBAAoB,gBAAgB,aAAa,UAAK,QAAQ;AAe7D,MAAM,eAAe,CAC1B,aAAgB,CAAC,MACE;AACnB,MAAI,OAAO,eAAe,UAAU;AAClC,iBAAa,CAAC;AAAA,EAChB;AAEA,QAAM,iBAAiB,iBAAiB;AAGxC,QAAM,EAAE,SAAS,WAAW,QAAQ,IAAI,eAAe;AAEvD,QAAM,mBAAmB,KAAK,SAAS,kBAAkB;AACzD,QAAM,2BAA2B,SAAS,SAAS,gBAAgB;AAEnE,QAAM,oBAAoB,KAAK,WAAW,oBAAoB;AAC9D,QAAM,4BAA4B,SAAS,SAAS,iBAAiB;AAGrE,QAAM,cAAc;AAAA,IAClB,cAAc;AAAA;AAAA,MAEZ,gCAAgC,KAAK,wBAAwB;AAAA,MAC7D,0BAA0B,KAAK,yBAAyB;AAAA,IAC1D;AAAA,IACA,OAAO;AAAA,MACL,UAAU;AAAA,QACR,IAAI;AAAA,QACJ,SAAS,CAAC,aAAa;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AAEA,QAAM,yBAAyB;AAAA,IAC7B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,YAAiC;AAAA;AAAA,IAErC,GAAI,cACA;AAAA;AAAA,MAEE;AAAA,IACF,IACA;AAAA;AAAA,MAEE,GAAI,eAAe;AAAA,QACjB,kCAAkC;AAAA,MACpC;AAAA,IACF;AAAA,IAEJ,GAAI,sBAAsB;AAAA,MACxB,GAAI,eAAe,oBACf;AAAA;AAAA,QAEE,WAAW;AAAA,MACb,IACA;AAAA,QACE,cAAc;AAAA;AAAA,UAEZ,OAAO;AAAA,QACT;AAAA,MACF;AAAA,IACN;AAAA,IAEA,SAAS,CAAC,QAA4B,YAA8B;AAElE,UAAI,OAAO,WAAW,YAAY,YAAY;AAC5C,iBAAS,WAAW,QAAQ,QAAQ,OAAO;AAAA,MAC7C;AAGA,aAAO,QAAQ,QAAQ;AAAA,QACrB,GAAG,OAAO,QAAQ;AAAA,QAClB,gCAAgC,QAAQ,wBAAwB;AAAA,QAChE,0BAA0B,QAAQ,yBAAyB;AAAA,MAC7D;AAGA,aAAO,UAAU,KAAK;AAAA,QACpB,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,IAAI;AAAA,QACJ,UAAU;AAAA,QACV,UAAU;AAAA,MACZ,CAAC;AAGD,aAAO,OAAO,MAAM,KAAK;AAAA,QACvB,MAAM;AAAA,QACN,QAAQ;AAAA,MACV,CAAC;AAGD,YAAM,EAAE,UAAU,YAAY,IAAI;AAElC,UAAI,YAAY,gBAAgB,UAAU;AACxC,eAAO,QAAQ,KAAK,IAAI,eAAe,CAAC;AAAA,MAC1C;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAGA,SAAO,MAAM,YAAY,SAAS;AACpC;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { IntlayerPlugin } from '@intlayer/webpack';\nimport merge from 'deepmerge';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport { join, relative, resolve } from 'path';\nimport { compareVersions } from './compareVersion';\nimport { getNextVersion } from './getNextVertion';\n\n// Extract from the start script if --turbo or --turbopack flag is used\nconst isTurbopackEnabled =\n process.env.npm_lifecycle_script?.includes('--turbo');\nconst nextVersion = getNextVersion();\nconst isGteNext13 = compareVersions(nextVersion, '≥', '13.0.0');\nconst isGteNext15 = compareVersions(nextVersion, '≥', '15.0.0');\nconst isTurbopackStable = compareVersions(nextVersion, '≥', '15.3.0');\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variablesi\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n */\nexport const withIntlayer = <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T\n): NextConfig & T => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const intlayerConfig = getConfiguration();\n\n // Format all configuration values as environment variables\n const { mainDir, configDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n const unmergedDictionariesPath = join(mainDir, 'unmerged_dictionaries.mjs');\n const relativeUnmergedDictionariesPath = relative(\n baseDir,\n unmergedDictionariesPath\n );\n\n const configurationPath = join(configDir, 'configuration.json');\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: {\n // \"prefix by './' to consider the path as relative to the project root. This is necessary for turbo to work correctly.\"\n '@intlayer/dictionaries-entry': `./${relativeDictionariesPath}`,\n '@intlayer/unmerged-dictionaries-entry': `./${relativeUnmergedDictionariesPath}`,\n '@intlayer/config/built': `./${relativeConfigurationPath}`,\n },\n rules: {\n '*.node': {\n as: '*.node',\n loaders: ['node-loader'],\n },\n },\n };\n\n const serverExternalPackages = [\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n ];\n\n const newConfig: Partial<NextConfig> = {\n // Only add `serverExternalPackages` if Next.js is v15+\n ...(isGteNext15\n ? {\n // only for Next ≥15\n serverExternalPackages,\n }\n : {\n // only for Next ≥13 and <15.3\n ...(isGteNext13 && {\n serverComponentsExternalPackages: serverExternalPackages,\n }),\n }),\n\n ...(isTurbopackEnabled && {\n ...(isGteNext15 && isTurbopackStable\n ? {\n // only for Next ≥15.3\n turbopack: turboConfig,\n }\n : {\n experimental: {\n // only for Next ≥13 and <15.3\n turbo: turboConfig,\n },\n }),\n }),\n\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 // Alias the dictionary entry for all builds\n config.resolve.alias = {\n ...config.resolve.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n '@intlayer/unmerged-dictionaries-entry': resolve(\n relativeUnmergedDictionariesPath\n ),\n '@intlayer/config/built': resolve(relativeConfigurationPath),\n };\n\n // Mark these modules as externals\n config.externals.push({\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n chokidar: 'chokidar',\n fsevents: 'fsevents',\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 // Only add Intlayer plugin on server side (node runtime)\n const { isServer, nextRuntime } = options;\n\n if (isServer && nextRuntime === 'nodejs') {\n config.plugins.push(new IntlayerPlugin());\n }\n\n return config;\n },\n };\n\n // Merge the new config with the user's config\n return merge(nextConfig, newConfig) as NextConfig & T;\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,OAAO,WAAW;AAGlB,SAAS,MAAM,UAAU,eAAe;AACxC,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAG/B,MAAM,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ACf;AAAA;AAAA,QAEE,WAAW;AAAA,MACb,IACA;AAAA,QACE,cAAc;AAAA;AAAA,UAEZ,OAAO;AAAA,QACT;AAAA,MACF;AAAA,IACN;AAAA,IAEA,SAAS,CAAC,QAA4B,YAA8B;AAElE,UAAI,OAAO,WAAW,YAAY,YAAY;AAC5C,iBAAS,WAAW,QAAQ,QAAQ,OAAO;AAAA,MAC7C;AAGA,aAAO,QAAQ,QAAQ;AAAA,QACrB,GAAG,OAAO,QAAQ;AAAA,QAClB,gCAAgC,QAAQ,wBAAwB;AAAA,QAChE,yCAAyC;AAAA,UACvC;AAAA,QACF;AAAA,QACA,0BAA0B,QAAQ,yBAAyB;AAAA,MAC7D;AAGA,aAAO,UAAU,KAAK;AAAA,QACpB,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,IAAI;AAAA,QACJ,UAAU;AAAA,QACV,UAAU;AAAA,MACZ,CAAC;AAGD,aAAO,OAAO,MAAM,KAAK;AAAA,QACvB,MAAM;AAAA,QACN,QAAQ;AAAA,MACV,CAAC;AAGD,YAAM,EAAE,UAAU,YAAY,IAAI;AAElC,UAAI,YAAY,gBAAgB,UAAU;AACxC,eAAO,QAAQ,KAAK,IAAI,eAAe,CAAC;AAAA,MAC1C;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAGA,SAAO,MAAM,YAAY,SAAS;AACpC;","names":[]}
@@ -1,3 +1,3 @@
1
- export { useDictionary, IntlayerServer, IntlayerServerProvider, locale, useIntlayer, t, } from 'react-intlayer/server';
1
+ export { IntlayerServer, IntlayerServerProvider, locale, t, useDictionary, useIntlayer, useLocale, } from 'react-intlayer/server';
2
2
  export { withIntlayer } from './withIntlayer';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,MAAM,EACN,WAAW,EACX,CAAC,GACF,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,MAAM,EACN,CAAC,EACD,aAAa,EACb,WAAW,EACX,SAAS,GACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"withIntlayer.d.ts","sourceRoot":"","sources":["../../../src/server/withIntlayer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAgBvC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,OAAO,CAAC,UAAU,CAAC,EACxD,aAAY,CAAW,KACtB,UAAU,GAAG,CA4Gf,CAAC"}
1
+ {"version":3,"file":"withIntlayer.d.ts","sourceRoot":"","sources":["../../../src/server/withIntlayer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAgBvC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,OAAO,CAAC,UAAU,CAAC,EACxD,aAAY,CAAW,KACtB,UAAU,GAAG,CAsHf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intlayer",
3
- "version": "5.4.2",
3
+ "version": "5.5.0",
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": [
@@ -69,12 +69,12 @@
69
69
  "dependencies": {
70
70
  "deepmerge": "^4.3.1",
71
71
  "node-loader": "^2.1.0",
72
- "@intlayer/chokidar": "5.4.2",
73
- "@intlayer/config": "5.4.2",
74
- "@intlayer/core": "5.4.2",
75
- "react-intlayer": "5.4.2",
76
- "@intlayer/dictionaries-entry": "5.4.2",
77
- "@intlayer/webpack": "5.4.2"
72
+ "@intlayer/chokidar": "5.5.0",
73
+ "react-intlayer": "5.5.0",
74
+ "@intlayer/core": "5.5.0",
75
+ "@intlayer/dictionaries-entry": "5.5.0",
76
+ "@intlayer/webpack": "5.5.0",
77
+ "@intlayer/config": "5.5.0"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@types/node": "^22.13.10",
@@ -88,22 +88,22 @@
88
88
  "tsc-alias": "^1.8.11",
89
89
  "tsup": "^8.4.0",
90
90
  "typescript": "^5.8.2",
91
- "@utils/ts-config": "1.0.4",
92
91
  "@utils/eslint-config": "1.0.4",
93
- "@utils/ts-config-types": "1.0.4",
92
+ "@utils/ts-config": "1.0.4",
94
93
  "@utils/tsup-config": "1.0.4",
95
- "intlayer": "5.4.2"
94
+ "intlayer": "5.5.0",
95
+ "@utils/ts-config-types": "1.0.4"
96
96
  },
97
97
  "peerDependencies": {
98
98
  "next": ">=14.0.0",
99
99
  "react": ">=16.0.0",
100
100
  "react-dom": ">=16.0.0",
101
- "@intlayer/config": "5.4.2",
102
- "@intlayer/dictionaries-entry": "5.4.2",
103
- "@intlayer/core": "5.4.2",
104
- "@intlayer/webpack": "5.4.2",
105
- "react-intlayer": "5.4.2",
106
- "intlayer": "5.4.2"
101
+ "@intlayer/core": "5.5.0",
102
+ "@intlayer/dictionaries-entry": "5.5.0",
103
+ "@intlayer/webpack": "5.5.0",
104
+ "react-intlayer": "5.5.0",
105
+ "@intlayer/config": "5.5.0",
106
+ "intlayer": "5.5.0"
107
107
  },
108
108
  "engines": {
109
109
  "node": ">=14.18"