next-intl 4.0.2 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/development/plugin.cjs +47 -18
- package/dist/esm/development/plugin/getNextConfig.js +30 -18
- package/dist/esm/development/plugin/hasStableTurboConfig.js +19 -0
- package/dist/esm/production/plugin/getNextConfig.js +1 -1
- package/dist/esm/production/plugin/hasStableTurboConfig.js +1 -0
- package/dist/types/navigation/react-client/createNavigation.d.ts +3 -0
- package/dist/types/navigation/react-server/createNavigation.d.ts +3 -0
- package/dist/types/navigation/shared/createSharedNavigationFns.d.ts +3 -0
- package/dist/types/plugin/hasStableTurboConfig.d.ts +2 -0
- package/package.json +3 -3
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var fs = require('fs');
|
|
4
4
|
var path = require('path');
|
|
5
|
+
var module$1 = require('module');
|
|
5
6
|
|
|
7
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
6
8
|
function formatMessage(message) {
|
|
7
9
|
return `\n[next-intl] ${message}\n`;
|
|
8
10
|
}
|
|
@@ -84,6 +86,22 @@ export default messages;`;
|
|
|
84
86
|
fs.writeFileSync(declarationPath, createDeclaration(content));
|
|
85
87
|
}
|
|
86
88
|
|
|
89
|
+
// eslint-disable-next-line import/order
|
|
90
|
+
const require$1 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('plugin.cjs', document.baseURI).href)));
|
|
91
|
+
const pkg = require$1('next/package.json');
|
|
92
|
+
function compareVersions(version1, version2) {
|
|
93
|
+
const v1Parts = version1.split('.').map(Number);
|
|
94
|
+
const v2Parts = version2.split('.').map(Number);
|
|
95
|
+
for (let i = 0; i < 3; i++) {
|
|
96
|
+
const v1 = v1Parts[i] || 0;
|
|
97
|
+
const v2 = v2Parts[i] || 0;
|
|
98
|
+
if (v1 > v2) return 1;
|
|
99
|
+
if (v1 < v2) return -1;
|
|
100
|
+
}
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
const hasStableTurboConfig = compareVersions(pkg.version, '15.3.0') >= 0;
|
|
104
|
+
|
|
87
105
|
function withExtensions(localPath) {
|
|
88
106
|
return [`${localPath}.ts`, `${localPath}.tsx`, `${localPath}.js`, `${localPath}.jsx`];
|
|
89
107
|
}
|
|
@@ -126,22 +144,31 @@ function getNextConfig(pluginConfig, nextConfig) {
|
|
|
126
144
|
if (pluginConfig.requestConfig?.startsWith('/')) {
|
|
127
145
|
throwError("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: " + pluginConfig.requestConfig);
|
|
128
146
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
...nextConfig?.
|
|
147
|
+
const resolveAlias = {
|
|
148
|
+
// Turbo aliases don't work with absolute
|
|
149
|
+
// paths (see error handling above)
|
|
150
|
+
'next-intl/config': resolveI18nPath(pluginConfig.requestConfig)
|
|
151
|
+
};
|
|
152
|
+
if (hasStableTurboConfig && !nextConfig?.experimental?.turbo) {
|
|
153
|
+
nextIntlConfig.turbopack = {
|
|
154
|
+
...nextConfig?.turbopack,
|
|
137
155
|
resolveAlias: {
|
|
138
|
-
...nextConfig?.
|
|
139
|
-
|
|
140
|
-
// paths (see error handling above)
|
|
141
|
-
'next-intl/config': resolveI18nPath(pluginConfig.requestConfig)
|
|
156
|
+
...nextConfig?.turbopack?.resolveAlias,
|
|
157
|
+
...resolveAlias
|
|
142
158
|
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
159
|
+
};
|
|
160
|
+
} else {
|
|
161
|
+
nextIntlConfig.experimental = {
|
|
162
|
+
...nextConfig?.experimental,
|
|
163
|
+
turbo: {
|
|
164
|
+
...nextConfig?.experimental?.turbo,
|
|
165
|
+
resolveAlias: {
|
|
166
|
+
...nextConfig?.experimental?.turbo?.resolveAlias,
|
|
167
|
+
...resolveAlias
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
145
172
|
} else {
|
|
146
173
|
nextIntlConfig.webpack = function webpack(...[config, options]) {
|
|
147
174
|
// Webpack requires absolute paths
|
|
@@ -154,10 +181,12 @@ function getNextConfig(pluginConfig, nextConfig) {
|
|
|
154
181
|
}
|
|
155
182
|
|
|
156
183
|
// Forward config
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
184
|
+
if (nextConfig?.trailingSlash) {
|
|
185
|
+
nextIntlConfig.env = {
|
|
186
|
+
...nextConfig.env,
|
|
187
|
+
_next_intl_trailing_slash: 'true'
|
|
188
|
+
};
|
|
189
|
+
}
|
|
161
190
|
return Object.assign({}, nextConfig, nextIntlConfig);
|
|
162
191
|
}
|
|
163
192
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import hasStableTurboConfig from './hasStableTurboConfig.js';
|
|
3
4
|
import { throwError } from './utils.js';
|
|
4
5
|
|
|
5
6
|
function withExtensions(localPath) {
|
|
@@ -44,22 +45,31 @@ function getNextConfig(pluginConfig, nextConfig) {
|
|
|
44
45
|
if (pluginConfig.requestConfig?.startsWith('/')) {
|
|
45
46
|
throwError("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: " + pluginConfig.requestConfig);
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
...nextConfig?.
|
|
48
|
+
const resolveAlias = {
|
|
49
|
+
// Turbo aliases don't work with absolute
|
|
50
|
+
// paths (see error handling above)
|
|
51
|
+
'next-intl/config': resolveI18nPath(pluginConfig.requestConfig)
|
|
52
|
+
};
|
|
53
|
+
if (hasStableTurboConfig && !nextConfig?.experimental?.turbo) {
|
|
54
|
+
nextIntlConfig.turbopack = {
|
|
55
|
+
...nextConfig?.turbopack,
|
|
55
56
|
resolveAlias: {
|
|
56
|
-
...nextConfig?.
|
|
57
|
-
|
|
58
|
-
// paths (see error handling above)
|
|
59
|
-
'next-intl/config': resolveI18nPath(pluginConfig.requestConfig)
|
|
57
|
+
...nextConfig?.turbopack?.resolveAlias,
|
|
58
|
+
...resolveAlias
|
|
60
59
|
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
60
|
+
};
|
|
61
|
+
} else {
|
|
62
|
+
nextIntlConfig.experimental = {
|
|
63
|
+
...nextConfig?.experimental,
|
|
64
|
+
turbo: {
|
|
65
|
+
...nextConfig?.experimental?.turbo,
|
|
66
|
+
resolveAlias: {
|
|
67
|
+
...nextConfig?.experimental?.turbo?.resolveAlias,
|
|
68
|
+
...resolveAlias
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
63
73
|
} else {
|
|
64
74
|
nextIntlConfig.webpack = function webpack(...[config, options]) {
|
|
65
75
|
// Webpack requires absolute paths
|
|
@@ -72,10 +82,12 @@ function getNextConfig(pluginConfig, nextConfig) {
|
|
|
72
82
|
}
|
|
73
83
|
|
|
74
84
|
// Forward config
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
if (nextConfig?.trailingSlash) {
|
|
86
|
+
nextIntlConfig.env = {
|
|
87
|
+
...nextConfig.env,
|
|
88
|
+
_next_intl_trailing_slash: 'true'
|
|
89
|
+
};
|
|
90
|
+
}
|
|
79
91
|
return Object.assign({}, nextConfig, nextIntlConfig);
|
|
80
92
|
}
|
|
81
93
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line import/order
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
const pkg = require('next/package.json');
|
|
6
|
+
function compareVersions(version1, version2) {
|
|
7
|
+
const v1Parts = version1.split('.').map(Number);
|
|
8
|
+
const v2Parts = version2.split('.').map(Number);
|
|
9
|
+
for (let i = 0; i < 3; i++) {
|
|
10
|
+
const v1 = v1Parts[i] || 0;
|
|
11
|
+
const v2 = v2Parts[i] || 0;
|
|
12
|
+
if (v1 > v2) return 1;
|
|
13
|
+
if (v1 < v2) return -1;
|
|
14
|
+
}
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
const hasStableTurboConfig = compareVersions(pkg.version, '15.3.0') >= 0;
|
|
18
|
+
|
|
19
|
+
export { hasStableTurboConfig as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"fs";import
|
|
1
|
+
import t from"fs";import e from"path";import n from"./hasStableTurboConfig.js";import{throwError as o}from"./utils.js";function r(t){return[`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.jsx`]}function s(n,s){function i(n){return t.existsSync(function(t){const n=[];return s&&n.push(s),n.push(t),e.resolve(...n)}(n))}if(n)return i(n)||o(`Could not find i18n config at ${n}, please provide a valid path.`),n;for(const t of[...r("./i18n/request"),...r("./src/i18n/request")])if(i(t))return t;o("Could not locate request configuration module.\n\nThis path is supported by default: ./(src/)i18n/request.{js,jsx,ts,tsx}\n\nAlternatively, you can specify a custom location in your Next.js config:\n\nconst withNextIntl = createNextIntlPlugin(\n\nAlternatively, you can specify a custom location in your Next.js config:\n\nconst withNextIntl = createNextIntlPlugin(\n './path/to/i18n/request.tsx'\n);")}function i(t,r){const i={};if(null!=process.env.TURBOPACK){t.requestConfig?.startsWith("/")&&o("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: "+t.requestConfig);const e={"next-intl/config":s(t.requestConfig)};n&&!r?.experimental?.turbo?i.turbopack={...r?.turbopack,resolveAlias:{...r?.turbopack?.resolveAlias,...e}}:i.experimental={...r?.experimental,turbo:{...r?.experimental?.turbo,resolveAlias:{...r?.experimental?.turbo?.resolveAlias,...e}}}}else i.webpack=function(...[n,o]){return n.resolve.alias["next-intl/config"]=e.resolve(n.context,s(t.requestConfig,n.context)),"function"==typeof r?.webpack?r.webpack(n,o):n};return r?.trailingSlash&&(i.env={...r.env,_next_intl_trailing_slash:"true"}),Object.assign({},r,i)}export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as t}from"module";const r=function(t,r){const e=t.split(".").map(Number),o=r.split(".").map(Number);for(let t=0;t<3;t++){const r=e[t]||0,n=o[t]||0;if(r>n)return 1;if(r<n)return-1}return 0}(t(import.meta.url)("next/package.json").version,"15.3.0")>=0;export{r as default};
|
|
@@ -22,6 +22,9 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
22
22
|
onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
23
23
|
onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
24
24
|
onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
25
|
+
onNavigate?: ((event: {
|
|
26
|
+
preventDefault: () => void;
|
|
27
|
+
}) => void) | undefined;
|
|
25
28
|
download?: any;
|
|
26
29
|
hrefLang?: string | undefined | undefined;
|
|
27
30
|
media?: string | undefined | undefined;
|
|
@@ -23,6 +23,9 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
23
23
|
onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
24
24
|
onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
25
25
|
onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
26
|
+
onNavigate?: ((event: {
|
|
27
|
+
preventDefault: () => void;
|
|
28
|
+
}) => void) | undefined;
|
|
26
29
|
download?: any;
|
|
27
30
|
hrefLang?: string | undefined | undefined;
|
|
28
31
|
media?: string | undefined | undefined;
|
|
@@ -41,6 +41,9 @@ export default function createSharedNavigationFns<const AppLocales extends Local
|
|
|
41
41
|
onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
42
42
|
onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
43
43
|
onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
44
|
+
onNavigate?: ((event: {
|
|
45
|
+
preventDefault: () => void;
|
|
46
|
+
}) => void) | undefined;
|
|
44
47
|
download?: any;
|
|
45
48
|
hrefLang?: string | undefined | undefined;
|
|
46
49
|
media?: string | undefined | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"dependencies": {
|
|
113
113
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
114
114
|
"negotiator": "^1.0.0",
|
|
115
|
-
"use-intl": "^4.0.
|
|
115
|
+
"use-intl": "^4.0.3"
|
|
116
116
|
},
|
|
117
117
|
"peerDependencies": {
|
|
118
118
|
"next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"optional": true
|
|
125
125
|
}
|
|
126
126
|
},
|
|
127
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "19c27a23384fdf746fde30bf3919c2fd8c0fd568"
|
|
128
128
|
}
|