next-intl 3.18.1 → 3.19.0-canary.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.
@@ -10,6 +10,9 @@ var path__default = /*#__PURE__*/_interopDefault(path);
10
10
 
11
11
  /* eslint-env node */
12
12
 
13
+ function withExtensions(localPath) {
14
+ return ["".concat(localPath, ".ts"), "".concat(localPath, ".tsx"), "".concat(localPath, ".js"), "".concat(localPath, ".jsx")];
15
+ }
13
16
  function resolveI18nPath(providedPath, cwd) {
14
17
  function resolvePath(pathname) {
15
18
  const parts = [];
@@ -26,12 +29,12 @@ function resolveI18nPath(providedPath, cwd) {
26
29
  }
27
30
  return providedPath;
28
31
  } else {
29
- for (const candidate of ['./i18n.tsx', './i18n.ts', './i18n.js', './i18n.jsx', './src/i18n.tsx', './src/i18n.ts', './src/i18n.js', './src/i18n.jsx']) {
32
+ for (const candidate of [...withExtensions('./i18n'), ...withExtensions('./src/i18n'), ...withExtensions('./i18n/request'), ...withExtensions('./src/i18n/request')]) {
30
33
  if (pathExists(candidate)) {
31
34
  return candidate;
32
35
  }
33
36
  }
34
- throw new Error("\n\nCould not locate i18n config. Create one at `./(src/)i18n.{js,jsx,ts,tsx}` or specify a custom location:\n\nconst withNextIntl = require('next-intl/plugin')(\n './path/to/i18n.tsx'\n);\n\nmodule.exports = withNextIntl({\n // Other Next.js configuration ...\n});\n");
37
+ throw new Error("\n\nCould not locate i18n request config for next-intl.\n\nThese paths are supported by default:\n- ./(src/)i18n/request.{js,jsx,ts,tsx}\n- ./(src/)i18n.{js,jsx,ts,tsx}\n\nAlternatively, you can specify a custom location in your Next.js config:\n\nconst withNextIntl = createNextIntlPlugin(\n './path/to/i18n/request.tsx'\n);\n");
35
38
  }
36
39
  }
37
40
  function initPlugin(i18nPath, nextConfig) {
@@ -39,16 +39,8 @@ async function receiveRuntimeConfigImpl(getConfig, localeOverride) {
39
39
  if (result instanceof Promise) {
40
40
  result = await result;
41
41
  }
42
- {
43
- if (hasReadLocale) {
44
- if (result.locale) {
45
- console.error("\nYou've read the `locale` param that was passed to `getRequestConfig` but have also returned one from the function. This is likely an error, please ensure that you're consistently using a setup with or without i18n routing: https://next-intl-docs.vercel.app/docs/getting-started/app-router\n");
46
- }
47
- } else {
48
- if (!result.locale) {
49
- console.error("\nYou haven't read the `locale` param that was passed to `getRequestConfig` and also haven't returned one from the function. This is likely an error, please ensure that you're consistently using a setup with or without i18n routing: https://next-intl-docs.vercel.app/docs/getting-started/app-router\n");
50
- }
51
- }
42
+ if (result.locale && hasReadLocale) {
43
+ console.error("\nYou've read the `locale` param that was passed to `getRequestConfig` but have also returned one from the function. This is likely an error, please ensure that you're consistently using a setup with or without i18n routing: https://next-intl-docs.vercel.app/docs/getting-started/app-router\n");
52
44
  }
53
45
  return {
54
46
  ...result,
@@ -1 +1 @@
1
- import n from"fs";import e from"path";function t(t,o){function r(t){return n.existsSync(function(n){const t=[];return o&&t.push(o),t.push(n),e.resolve(...t)}(t))}if(t){if(!r(t))throw new Error("Could not find i18n config at ".concat(t,", please provide a valid path."));return t}for(const n of["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"])if(r(n))return n;throw new Error("\n\nCould not locate i18n config. Create one at `./(src/)i18n.{js,jsx,ts,tsx}` or specify a custom location:\n\nconst withNextIntl = require('next-intl/plugin')(\n './path/to/i18n.tsx'\n);\n\nmodule.exports = withNextIntl({\n // Other Next.js configuration ...\n});\n")}module.exports=function(n){return function(o){return function(n,o){null!=(null==o?void 0:o.i18n)&&console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://next-intl-docs.vercel.app/examples#app-router-migration\n");const r={};if(null!=process.env.TURBOPACK){var i,s;if(n&&n.startsWith("/"))throw new Error("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: "+n+"\n");r.experimental={...null==o?void 0:o.experimental,turbo:{...null==o||null===(i=o.experimental)||void 0===i?void 0:i.turbo,resolveAlias:{...null==o||null===(s=o.experimental)||void 0===s||null===(s=s.turbo)||void 0===s?void 0:s.resolveAlias,"next-intl/config":t(n)}}}}else r.webpack=function(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];let[l,u]=i;return l.resolve.alias["next-intl/config"]=e.resolve(l.context,t(n,l.context)),"function"==typeof(null==o?void 0:o.webpack)?o.webpack(l,u):l};return r.env={...null==o?void 0:o.env,_next_intl_trailing_slash:null!=o&&o.trailingSlash?"true":void 0},Object.assign({},o,r)}(n,o)}};
1
+ import n from"fs";import e from"path";function t(n){return["".concat(n,".ts"),"".concat(n,".tsx"),"".concat(n,".js"),"".concat(n,".jsx")]}function o(o,r){function i(t){return n.existsSync(function(n){const t=[];return r&&t.push(r),t.push(n),e.resolve(...t)}(t))}if(o){if(!i(o))throw new Error("Could not find i18n config at ".concat(o,", please provide a valid path."));return o}for(const n of[...t("./i18n"),...t("./src/i18n"),...t("./i18n/request"),...t("./src/i18n/request")])if(i(n))return n;throw new Error("\n\nCould not locate i18n request config for next-intl.\n\nThese paths are supported by default:\n- ./(src/)i18n/request.{js,jsx,ts,tsx}\n- ./(src/)i18n.{js,jsx,ts,tsx}\n\nAlternatively, you can specify a custom location in your Next.js config:\n\nconst withNextIntl = createNextIntlPlugin(\n './path/to/i18n/request.tsx'\n);\n")}module.exports=function(n){return function(t){return function(n,t){null!=(null==t?void 0:t.i18n)&&console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://next-intl-docs.vercel.app/examples#app-router-migration\n");const r={};if(null!=process.env.TURBOPACK){var i,s;if(n&&n.startsWith("/"))throw new Error("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: "+n+"\n");r.experimental={...null==t?void 0:t.experimental,turbo:{...null==t||null===(i=t.experimental)||void 0===i?void 0:i.turbo,resolveAlias:{...null==t||null===(s=t.experimental)||void 0===s||null===(s=s.turbo)||void 0===s?void 0:s.resolveAlias,"next-intl/config":o(n)}}}}else r.webpack=function(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];let[l,u]=i;return l.resolve.alias["next-intl/config"]=e.resolve(l.context,o(n,l.context)),"function"==typeof(null==t?void 0:t.webpack)?t.webpack(l,u):l};return r.env={...null==t?void 0:t.env,_next_intl_trailing_slash:null!=t&&t.trailingSlash?"true":void 0},Object.assign({},t,r)}(n,t)}};
@@ -1 +1 @@
1
- import{cache as t}from"react";import{_createIntlFormatters as e,_createCache as o,initializeConfig as n}from"use-intl/core";import{getRequestLocale as r}from"./RequestLocale.js";import a from"next-intl/config";const s=t((function(){return new Date}));const i=t((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const l=t((async function(t,e){let o=!1;const n={get locale(){return o=!0,e||r()}};let a=t(n);return a instanceof Promise&&(a=await a),o?a.locale&&console.error("\nYou've read the `locale` param that was passed to `getRequestConfig` but have also returned one from the function. This is likely an error, please ensure that you're consistently using a setup with or without i18n routing: https://next-intl-docs.vercel.app/docs/getting-started/app-router\n"):a.locale||console.error("\nYou haven't read the `locale` param that was passed to `getRequestConfig` and also haven't returned one from the function. This is likely an error, please ensure that you're consistently using a setup with or without i18n routing: https://next-intl-docs.vercel.app/docs/getting-started/app-router\n"),{...a,locale:a.locale||n.locale,now:a.now||s(),timeZone:a.timeZone||i()}})),c=t(e),u=t(o);const p=t((async function(t){const e=await l(a,t);return{...n(e),_formatters:c(u())}}));export{p as default};
1
+ import{cache as t}from"react";import{_createIntlFormatters as e,_createCache as o,initializeConfig as n}from"use-intl/core";import{getRequestLocale as r}from"./RequestLocale.js";import a from"next-intl/config";const s=t((function(){return new Date}));const i=t((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const c=t((async function(t,e){let o=!1;const n={get locale(){return o=!0,e||r()}};let a=t(n);return a instanceof Promise&&(a=await a),a.locale&&o&&console.error("\nYou've read the `locale` param that was passed to `getRequestConfig` but have also returned one from the function. This is likely an error, please ensure that you're consistently using a setup with or without i18n routing: https://next-intl-docs.vercel.app/docs/getting-started/app-router\n"),{...a,locale:a.locale||n.locale,now:a.now||s(),timeZone:a.timeZone||i()}})),l=t(e),u=t(o);const m=t((async function(t){const e=await c(a,t);return{...n(e),_formatters:l(u())}}));export{m as default};
@@ -1 +1 @@
1
- "use strict";var n=require("fs"),e=require("path");function t(n){return n&&n.__esModule?n:{default:n}}var o=t(n),r=t(e);function i(n,e){function t(n){return o.default.existsSync(function(n){const t=[];return e&&t.push(e),t.push(n),r.default.resolve(...t)}(n))}if(n){if(!t(n))throw new Error("Could not find i18n config at ".concat(n,", please provide a valid path."));return n}for(const n of["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"])if(t(n))return n;throw new Error("\n\nCould not locate i18n config. Create one at `./(src/)i18n.{js,jsx,ts,tsx}` or specify a custom location:\n\nconst withNextIntl = require('next-intl/plugin')(\n './path/to/i18n.tsx'\n);\n\nmodule.exports = withNextIntl({\n // Other Next.js configuration ...\n});\n")}module.exports=function(n){return function(e){return function(n,e){null!=(null==e?void 0:e.i18n)&&console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://next-intl-docs.vercel.app/examples#app-router-migration\n");const t={};if(null!=process.env.TURBOPACK){var o,l;if(n&&n.startsWith("/"))throw new Error("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: "+n+"\n");t.experimental={...null==e?void 0:e.experimental,turbo:{...null==e||null===(o=e.experimental)||void 0===o?void 0:o.turbo,resolveAlias:{...null==e||null===(l=e.experimental)||void 0===l||null===(l=l.turbo)||void 0===l?void 0:l.resolveAlias,"next-intl/config":i(n)}}}}else t.webpack=function(){for(var t=arguments.length,o=new Array(t),l=0;l<t;l++)o[l]=arguments[l];let[s,u]=o;return s.resolve.alias["next-intl/config"]=r.default.resolve(s.context,i(n,s.context)),"function"==typeof(null==e?void 0:e.webpack)?e.webpack(s,u):s};return t.env={...null==e?void 0:e.env,_next_intl_trailing_slash:null!=e&&e.trailingSlash?"true":void 0},Object.assign({},e,t)}(n,e)}};
1
+ "use strict";var n=require("fs"),e=require("path");function t(n){return n&&n.__esModule?n:{default:n}}var r=t(n),o=t(e);function i(n){return["".concat(n,".ts"),"".concat(n,".tsx"),"".concat(n,".js"),"".concat(n,".jsx")]}function s(n,e){function t(n){return r.default.existsSync(function(n){const t=[];return e&&t.push(e),t.push(n),o.default.resolve(...t)}(n))}if(n){if(!t(n))throw new Error("Could not find i18n config at ".concat(n,", please provide a valid path."));return n}for(const n of[...i("./i18n"),...i("./src/i18n"),...i("./i18n/request"),...i("./src/i18n/request")])if(t(n))return n;throw new Error("\n\nCould not locate i18n request config for next-intl.\n\nThese paths are supported by default:\n- ./(src/)i18n/request.{js,jsx,ts,tsx}\n- ./(src/)i18n.{js,jsx,ts,tsx}\n\nAlternatively, you can specify a custom location in your Next.js config:\n\nconst withNextIntl = createNextIntlPlugin(\n './path/to/i18n/request.tsx'\n);\n")}module.exports=function(n){return function(e){return function(n,e){null!=(null==e?void 0:e.i18n)&&console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://next-intl-docs.vercel.app/examples#app-router-migration\n");const t={};if(null!=process.env.TURBOPACK){var r,i;if(n&&n.startsWith("/"))throw new Error("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: "+n+"\n");t.experimental={...null==e?void 0:e.experimental,turbo:{...null==e||null===(r=e.experimental)||void 0===r?void 0:r.turbo,resolveAlias:{...null==e||null===(i=e.experimental)||void 0===i||null===(i=i.turbo)||void 0===i?void 0:i.resolveAlias,"next-intl/config":s(n)}}}}else t.webpack=function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];let[l,u]=r;return l.resolve.alias["next-intl/config"]=o.default.resolve(l.context,s(n,l.context)),"function"==typeof(null==e?void 0:e.webpack)?e.webpack(l,u):l};return t.env={...null==e?void 0:e.env,_next_intl_trailing_slash:null!=e&&e.trailingSlash?"true":void 0},Object.assign({},e,t)}(n,e)}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("use-intl/core"),n=require("./RequestLocale.js");function c(e){return e&&e.__esModule?e:{default:e}}var r=c(require("next-intl/config"));const o=e.cache((function(){return new Date}));const a=e.cache((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const i=e.cache((async function(e,t){const c={get locale(){return t||n.getRequestLocale()}};let r=e(c);return r instanceof Promise&&(r=await r),{...r,locale:r.locale||c.locale,now:r.now||o(),timeZone:r.timeZone||a()}})),u=e.cache(t._createIntlFormatters),s=e.cache(t._createCache);const l=e.cache((async function(e){const n=await i(r.default,e);return{...t.initializeConfig(n),_formatters:u(s())}}));exports.default=l;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("use-intl/core"),n=require("./RequestLocale.js");function o(e){return e&&e.__esModule?e:{default:e}}var r=o(require("next-intl/config"));const a=e.cache((function(){return new Date}));const c=e.cache((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const s=e.cache((async function(e,t){let o=!1;const r={get locale(){return o=!0,t||n.getRequestLocale()}};let s=e(r);return s instanceof Promise&&(s=await s),s.locale&&o&&console.error("\nYou've read the `locale` param that was passed to `getRequestConfig` but have also returned one from the function. This is likely an error, please ensure that you're consistently using a setup with or without i18n routing: https://next-intl-docs.vercel.app/docs/getting-started/app-router\n"),{...s,locale:s.locale||r.locale,now:s.now||a(),timeZone:s.timeZone||c()}})),i=e.cache(t._createIntlFormatters),u=e.cache(t._createCache);const l=e.cache((async function(e){const n=await s(r.default,e);return{...t.initializeConfig(n),_formatters:i(u())}}));exports.default=l;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intl",
3
- "version": "3.18.1",
3
+ "version": "3.19.0-canary.0",
4
4
  "sideEffects": false,
5
5
  "author": "Jan Amann <jan@amann.work>",
6
6
  "funding": [
@@ -87,11 +87,11 @@
87
87
  "dependencies": {
88
88
  "@formatjs/intl-localematcher": "^0.5.4",
89
89
  "negotiator": "^0.6.3",
90
- "use-intl": "^3.18.1"
90
+ "use-intl": "^3.19.0-canary.0"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
94
94
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
95
95
  },
96
- "gitHead": "80ec17a8fb7873fa1f7c5416c74a535573f58d97"
96
+ "gitHead": "e7c16f3891f962555f4a78afe6f2db9a61592729"
97
97
  }