next-intl 3.0.3 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/plugin.js +55 -21
- package/dist/esm/plugin.js +1 -1
- package/dist/production/plugin.js +1 -1
- package/package.json +4 -4
|
@@ -10,38 +10,72 @@ var path__default = /*#__PURE__*/_interopDefault(path);
|
|
|
10
10
|
|
|
11
11
|
/* eslint-env node */
|
|
12
12
|
|
|
13
|
-
function resolveI18nPath(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
function resolveI18nPath(providedPath, cwd) {
|
|
14
|
+
function resolvePath(pathname) {
|
|
15
|
+
const parts = [];
|
|
16
|
+
if (cwd) parts.push(cwd);
|
|
17
|
+
parts.push(pathname);
|
|
18
|
+
return path__default.default.resolve(...parts);
|
|
19
|
+
}
|
|
20
|
+
function pathExists(pathname) {
|
|
21
|
+
return fs__default.default.existsSync(resolvePath(pathname));
|
|
22
|
+
}
|
|
23
|
+
if (providedPath) {
|
|
24
|
+
if (!pathExists(providedPath)) {
|
|
25
|
+
throw new Error("Could not find i18n config at ".concat(providedPath, ", please provide a valid path."));
|
|
19
26
|
}
|
|
27
|
+
return providedPath;
|
|
20
28
|
} else {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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']) {
|
|
30
|
+
if (pathExists(candidate)) {
|
|
31
|
+
return candidate;
|
|
32
|
+
}
|
|
24
33
|
}
|
|
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");
|
|
25
35
|
}
|
|
26
|
-
return i18nPath;
|
|
27
36
|
}
|
|
28
37
|
function initPlugin(i18nPath, nextConfig) {
|
|
29
38
|
if ((nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.i18n) != null) {
|
|
30
39
|
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://github.com/amannn/next-intl/tree/main/packages/example-app-router-migration\n");
|
|
31
40
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
const useTurbo = process.env.TURBOPACK != null;
|
|
42
|
+
let nextIntlConfig;
|
|
43
|
+
if (useTurbo) {
|
|
44
|
+
var _nextConfig$experimen, _nextConfig$experimen2;
|
|
45
|
+
if (i18nPath && i18nPath.startsWith('/')) {
|
|
46
|
+
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: " + i18nPath + '\n');
|
|
47
|
+
}
|
|
48
|
+
nextIntlConfig = {
|
|
49
|
+
experimental: {
|
|
50
|
+
...(nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.experimental),
|
|
51
|
+
turbo: {
|
|
52
|
+
...(nextConfig === null || nextConfig === void 0 || (_nextConfig$experimen = nextConfig.experimental) === null || _nextConfig$experimen === void 0 ? void 0 : _nextConfig$experimen.turbo),
|
|
53
|
+
resolveAlias: {
|
|
54
|
+
...(nextConfig === null || nextConfig === void 0 || (_nextConfig$experimen2 = nextConfig.experimental) === null || _nextConfig$experimen2 === void 0 || (_nextConfig$experimen2 = _nextConfig$experimen2.turbo) === null || _nextConfig$experimen2 === void 0 ? void 0 : _nextConfig$experimen2.resolveAlias),
|
|
55
|
+
// Turbo aliases don't work with absolute
|
|
56
|
+
// paths (see error handling above)
|
|
57
|
+
'next-intl/config': resolveI18nPath(i18nPath)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
36
60
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
61
|
+
};
|
|
62
|
+
} else {
|
|
63
|
+
nextIntlConfig = {
|
|
64
|
+
webpack() {
|
|
65
|
+
for (var _len = arguments.length, _ref = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
66
|
+
_ref[_key] = arguments[_key];
|
|
67
|
+
}
|
|
68
|
+
let [config, options] = _ref;
|
|
69
|
+
// Webpack requires absolute paths
|
|
70
|
+
config.resolve.alias['next-intl/config'] = path__default.default.resolve(config.context, resolveI18nPath(i18nPath, config.context));
|
|
71
|
+
if (typeof (nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.webpack) === 'function') {
|
|
72
|
+
return nextConfig.webpack(config, options);
|
|
73
|
+
}
|
|
74
|
+
return config;
|
|
41
75
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return Object.assign({}, nextConfig, nextIntlConfig);
|
|
45
79
|
}
|
|
46
80
|
module.exports = function withNextIntl(i18nPath) {
|
|
47
81
|
return nextConfig => initPlugin(i18nPath, nextConfig);
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import n from"fs";import e from"path";function t(t,o){
|
|
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 o=>function(n,o){let r;if(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://github.com/amannn/next-intl/tree/main/packages/example-app-router-migration\n"),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(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];let[l,a]=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,a):l}};return Object.assign({},o,r)}(n,o)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var n=require("fs"),e=require("path");function t(n){return n&&n.__esModule?n:{default:n}}var
|
|
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 e=>function(n,e){let t;if(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://github.com/amannn/next-intl/tree/main/packages/example-app-router-migration\n"),null!=process.env.TURBOPACK){var o,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");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===(s=e.experimental)||void 0===s||null===(s=s.turbo)||void 0===s?void 0:s.resolveAlias,"next-intl/config":i(n)}}}}}else t={webpack(){for(var t=arguments.length,o=new Array(t),s=0;s<t;s++)o[s]=arguments[s];let[l,u]=o;return l.resolve.alias["next-intl/config"]=r.default.resolve(l.context,i(n,l.context)),"function"==typeof(null==e?void 0:e.webpack)?e.webpack(l,u):l}};return Object.assign({},e,t)}(n,e)};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"description": "A minimal, but complete solution for internationalization in Next.js apps.",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@formatjs/intl-localematcher": "^0.2.32",
|
|
75
75
|
"negotiator": "^0.6.3",
|
|
76
|
-
"use-intl": "^3.
|
|
76
|
+
"use-intl": "^3.1.1"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"eslint": "^8.46.0",
|
|
90
90
|
"eslint-config-molindo": "^7.0.0",
|
|
91
91
|
"eslint-plugin-deprecation": "^1.4.1",
|
|
92
|
-
"next": "14.0.
|
|
92
|
+
"next": "14.0.3",
|
|
93
93
|
"path-to-regexp": "^6.2.1",
|
|
94
94
|
"react": "^18.2.0",
|
|
95
95
|
"react-dom": "^18.2.0",
|
|
@@ -125,5 +125,5 @@
|
|
|
125
125
|
"limit": "5.7 KB"
|
|
126
126
|
}
|
|
127
127
|
],
|
|
128
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "5be3fb85ce5f42d7866d52eca6acc384f8bb1c08"
|
|
129
129
|
}
|