next-intl 4.8.1 → 4.8.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.
- package/dist/cjs/development/{JSONCodec-CRJyWlb_.cjs → JSONCodec-rhejs716.cjs} +1 -1
- package/dist/cjs/development/{POCodec-CUEyCCAr.cjs → POCodec-Cv3VdXQG.cjs} +1 -1
- package/dist/cjs/development/{plugin-BqIqNtDr.cjs → plugin-YzBhQjAo.cjs} +28 -16
- package/dist/cjs/development/plugin.cjs +1 -1
- package/dist/esm/development/plugin/config.js +10 -0
- package/dist/esm/development/plugin/extractor/initExtractionCompiler.js +2 -4
- package/dist/esm/development/plugin/getNextConfig.js +14 -7
- package/dist/esm/production/plugin/config.js +1 -0
- package/dist/esm/production/plugin/extractor/initExtractionCompiler.js +1 -1
- package/dist/esm/production/plugin/getNextConfig.js +1 -1
- package/dist/types/plugin/config.d.ts +3 -0
- package/package.json +5 -5
|
@@ -122,11 +122,11 @@ export default messages;`;
|
|
|
122
122
|
|
|
123
123
|
const formats = {
|
|
124
124
|
json: {
|
|
125
|
-
codec: () => Promise.resolve().then(function () { return require('./JSONCodec-
|
|
125
|
+
codec: () => Promise.resolve().then(function () { return require('./JSONCodec-rhejs716.cjs'); }),
|
|
126
126
|
extension: '.json'
|
|
127
127
|
},
|
|
128
128
|
po: {
|
|
129
|
-
codec: () => Promise.resolve().then(function () { return require('./POCodec-
|
|
129
|
+
codec: () => Promise.resolve().then(function () { return require('./POCodec-Cv3VdXQG.cjs'); }),
|
|
130
130
|
extension: '.po'
|
|
131
131
|
}
|
|
132
132
|
};
|
|
@@ -990,7 +990,7 @@ class LRUCache {
|
|
|
990
990
|
}
|
|
991
991
|
}
|
|
992
992
|
|
|
993
|
-
const require$2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('plugin-
|
|
993
|
+
const require$2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('plugin-YzBhQjAo.cjs', document.baseURI).href)));
|
|
994
994
|
class MessageExtractor {
|
|
995
995
|
compileCache = new LRUCache(750);
|
|
996
996
|
constructor(opts) {
|
|
@@ -1083,6 +1083,15 @@ class ExtractionCompiler {
|
|
|
1083
1083
|
}
|
|
1084
1084
|
}
|
|
1085
1085
|
|
|
1086
|
+
// Avoid rollup's `replace` plugin to compile this away
|
|
1087
|
+
const nodeEnvKey = 'NODE_ENV'.trim();
|
|
1088
|
+
|
|
1089
|
+
// We avoid reading `argv.includes('dev')` related to
|
|
1090
|
+
// https://github.com/amannn/next-intl/issues/2006
|
|
1091
|
+
const isDevelopment = process.env[nodeEnvKey] === 'development';
|
|
1092
|
+
const isNextBuild = process.argv.includes('build');
|
|
1093
|
+
const isDevelopmentOrNextBuild = isDevelopment || isNextBuild;
|
|
1094
|
+
|
|
1086
1095
|
// Single compiler instance, initialized once per process
|
|
1087
1096
|
let compiler;
|
|
1088
1097
|
const runOnce = once('_NEXT_INTL_EXTRACT');
|
|
@@ -1092,9 +1101,6 @@ function initExtractionCompiler(pluginConfig) {
|
|
|
1092
1101
|
return;
|
|
1093
1102
|
}
|
|
1094
1103
|
|
|
1095
|
-
// Avoid rollup's `replace` plugin to compile this away
|
|
1096
|
-
const isDevelopment = process.env['NODE_ENV'.trim()] === 'development';
|
|
1097
|
-
|
|
1098
1104
|
// Avoid running for:
|
|
1099
1105
|
// - info
|
|
1100
1106
|
// - start
|
|
@@ -1107,7 +1113,7 @@ function initExtractionCompiler(pluginConfig) {
|
|
|
1107
1113
|
// What remains are:
|
|
1108
1114
|
// - dev (NODE_ENV=development)
|
|
1109
1115
|
// - build (NODE_ENV=production)
|
|
1110
|
-
const shouldRun = isDevelopment ||
|
|
1116
|
+
const shouldRun = isDevelopment || isNextBuild;
|
|
1111
1117
|
if (!shouldRun) return;
|
|
1112
1118
|
runOnce(() => {
|
|
1113
1119
|
const extractorConfig = {
|
|
@@ -1142,7 +1148,7 @@ function initExtractionCompiler(pluginConfig) {
|
|
|
1142
1148
|
|
|
1143
1149
|
function getCurrentVersion() {
|
|
1144
1150
|
try {
|
|
1145
|
-
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-
|
|
1151
|
+
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-YzBhQjAo.cjs', document.baseURI).href)));
|
|
1146
1152
|
const pkg = require$1('next/package.json');
|
|
1147
1153
|
return pkg.version;
|
|
1148
1154
|
} catch (error) {
|
|
@@ -1169,7 +1175,7 @@ function isNextJs16OrHigher() {
|
|
|
1169
1175
|
return compareVersions(getCurrentVersion(), '16.0.0') >= 0;
|
|
1170
1176
|
}
|
|
1171
1177
|
|
|
1172
|
-
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-
|
|
1178
|
+
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-YzBhQjAo.cjs', document.baseURI).href)));
|
|
1173
1179
|
function withExtensions(localPath) {
|
|
1174
1180
|
return [`${localPath}.ts`, `${localPath}.tsx`, `${localPath}.js`, `${localPath}.jsx`];
|
|
1175
1181
|
}
|
|
@@ -1189,7 +1195,10 @@ function resolveI18nPath(providedPath, cwd) {
|
|
|
1189
1195
|
return fs__default.default.existsSync(resolvePath(pathname));
|
|
1190
1196
|
}
|
|
1191
1197
|
if (providedPath) {
|
|
1192
|
-
|
|
1198
|
+
// We use the `isNextDevOrBuild` condition to avoid throwing errors
|
|
1199
|
+
// if `next.config.ts` is read by a non-Next.js process.
|
|
1200
|
+
// https://github.com/amannn/next-intl/discussions/2209#discussioncomment-15650927
|
|
1201
|
+
if (isDevelopmentOrNextBuild && !pathExists(providedPath)) {
|
|
1193
1202
|
throwError(`Could not find i18n config at ${providedPath}, please provide a valid path.`);
|
|
1194
1203
|
}
|
|
1195
1204
|
return providedPath;
|
|
@@ -1199,13 +1208,16 @@ function resolveI18nPath(providedPath, cwd) {
|
|
|
1199
1208
|
return candidate;
|
|
1200
1209
|
}
|
|
1201
1210
|
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1211
|
+
if (isDevelopmentOrNextBuild) {
|
|
1212
|
+
throwError(`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 './path/to/i18n/request.tsx'\n);`);
|
|
1213
|
+
}
|
|
1205
1214
|
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1215
|
+
// Default as fallback
|
|
1216
|
+
if (pathExists('./src')) {
|
|
1217
|
+
return './src/i18n/request.ts';
|
|
1218
|
+
} else {
|
|
1219
|
+
return './i18n/request.ts';
|
|
1220
|
+
}
|
|
1209
1221
|
}
|
|
1210
1222
|
}
|
|
1211
1223
|
function getNextConfig(pluginConfig, nextConfig) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Avoid rollup's `replace` plugin to compile this away
|
|
2
|
+
const nodeEnvKey = 'NODE_ENV'.trim();
|
|
3
|
+
|
|
4
|
+
// We avoid reading `argv.includes('dev')` related to
|
|
5
|
+
// https://github.com/amannn/next-intl/issues/2006
|
|
6
|
+
const isDevelopment = process.env[nodeEnvKey] === 'development';
|
|
7
|
+
const isNextBuild = process.argv.includes('build');
|
|
8
|
+
const isDevelopmentOrNextBuild = isDevelopment || isNextBuild;
|
|
9
|
+
|
|
10
|
+
export { isDevelopment, isDevelopmentOrNextBuild, isNextBuild };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ExtractionCompiler from '../../extractor/ExtractionCompiler.js';
|
|
2
|
+
import { isDevelopment, isNextBuild } from '../config.js';
|
|
2
3
|
import { once } from '../utils.js';
|
|
3
4
|
|
|
4
5
|
// Single compiler instance, initialized once per process
|
|
@@ -10,9 +11,6 @@ function initExtractionCompiler(pluginConfig) {
|
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
// Avoid rollup's `replace` plugin to compile this away
|
|
14
|
-
const isDevelopment = process.env['NODE_ENV'.trim()] === 'development';
|
|
15
|
-
|
|
16
14
|
// Avoid running for:
|
|
17
15
|
// - info
|
|
18
16
|
// - start
|
|
@@ -25,7 +23,7 @@ function initExtractionCompiler(pluginConfig) {
|
|
|
25
23
|
// What remains are:
|
|
26
24
|
// - dev (NODE_ENV=development)
|
|
27
25
|
// - build (NODE_ENV=production)
|
|
28
|
-
const shouldRun = isDevelopment ||
|
|
26
|
+
const shouldRun = isDevelopment || isNextBuild;
|
|
29
27
|
if (!shouldRun) return;
|
|
30
28
|
runOnce(() => {
|
|
31
29
|
const extractorConfig = {
|
|
@@ -3,6 +3,7 @@ import { createRequire } from 'module';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { getFormatExtension } from '../extractor/format/index.js';
|
|
5
5
|
import SourceFileFilter from '../extractor/source/SourceFileFilter.js';
|
|
6
|
+
import { isDevelopmentOrNextBuild } from './config.js';
|
|
6
7
|
import { isNextJs16OrHigher, hasStableTurboConfig } from './nextFlags.js';
|
|
7
8
|
import { throwError } from './utils.js';
|
|
8
9
|
|
|
@@ -26,7 +27,10 @@ function resolveI18nPath(providedPath, cwd) {
|
|
|
26
27
|
return fs.existsSync(resolvePath(pathname));
|
|
27
28
|
}
|
|
28
29
|
if (providedPath) {
|
|
29
|
-
|
|
30
|
+
// We use the `isNextDevOrBuild` condition to avoid throwing errors
|
|
31
|
+
// if `next.config.ts` is read by a non-Next.js process.
|
|
32
|
+
// https://github.com/amannn/next-intl/discussions/2209#discussioncomment-15650927
|
|
33
|
+
if (isDevelopmentOrNextBuild && !pathExists(providedPath)) {
|
|
30
34
|
throwError(`Could not find i18n config at ${providedPath}, please provide a valid path.`);
|
|
31
35
|
}
|
|
32
36
|
return providedPath;
|
|
@@ -36,13 +40,16 @@ function resolveI18nPath(providedPath, cwd) {
|
|
|
36
40
|
return candidate;
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
if (isDevelopmentOrNextBuild) {
|
|
44
|
+
throwError(`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 './path/to/i18n/request.tsx'\n);`);
|
|
45
|
+
}
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
// Default as fallback
|
|
48
|
+
if (pathExists('./src')) {
|
|
49
|
+
return './src/i18n/request.ts';
|
|
50
|
+
} else {
|
|
51
|
+
return './i18n/request.ts';
|
|
52
|
+
}
|
|
46
53
|
}
|
|
47
54
|
}
|
|
48
55
|
function getNextConfig(pluginConfig, nextConfig) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e="NODE_ENV".trim(),s="development"===process.env[e],o=process.argv.includes("build"),r=s||o;export{s as isDevelopment,r as isDevelopmentOrNextBuild,o as isNextBuild};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from"../../extractor/ExtractionCompiler.js";import{isDevelopment as e,isNextBuild as t}from"../config.js";import{once as s}from"../utils.js";let r;const c=s("_NEXT_INTL_EXTRACT");function n(s){const n=s.experimental;if(!n?.extract)return;(e||t)&&c((()=>{const t={srcPath:n.srcPath,sourceLocale:n.extract.sourceLocale,messages:n.messages};function s(){r&&(r[Symbol.dispose](),r=void 0)}r=new o(t,{isDevelopment:e,projectRoot:process.cwd()}),r.extractAll(),process.on("exit",s),process.on("SIGINT",s),process.on("SIGTERM",s)}))}export{n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"fs";import{createRequire as t}from"module";import s from"path";import{getFormatExtension as r}from"../extractor/format/index.js";import
|
|
1
|
+
import e from"fs";import{createRequire as t}from"module";import s from"path";import{getFormatExtension as r}from"../extractor/format/index.js";import o from"../extractor/source/SourceFileFilter.js";import{isDevelopmentOrNextBuild as n}from"./config.js";import{isNextJs16OrHigher as a,hasStableTurboConfig as i}from"./nextFlags.js";import{throwError as l}from"./utils.js";const u=t(import.meta.url);function c(e){return[`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.jsx`]}function m(t,r){function o(t){return e.existsSync(function(e){const t=[];return r&&t.push(r),t.push(e),s.resolve(...t)}(t))}if(t)return n&&!o(t)&&l(`Could not find i18n config at ${t}, please provide a valid path.`),t;for(const e of[...c("./i18n/request"),...c("./src/i18n/request")])if(o(e))return e;return n&&l("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 './path/to/i18n/request.tsx'\n);"),o("./src")?"./src/i18n/request.ts":"./i18n/request.ts"}function p(e,t){const n=null!=process.env.TURBOPACK,c=n||a(),p={};function x(){const t=e.experimental;return t.srcPath&&e.experimental?.messages||l("`srcPath` and `messages` are required when using `extractor`."),{loader:"next-intl/extractor/extractionLoader",options:{srcPath:t.srcPath,sourceLocale:t.extract.sourceLocale,messages:e.experimental.messages}}}function f(){return{loader:"next-intl/extractor/catalogLoader",options:{messages:e.experimental.messages}}}function g(){return t?.turbopack?.rules||t?.experimental?.turbo?.rules||{}}function d(e,t,s){e[t]?Array.isArray(e[t])?e[t].push(s):e[t]=[e[t],s]:e[t]=s}if(e.experimental?.messages){const t=e.experimental.messages;t.format||l("`format` is required when using `messages`."),t.path||l("`path` is required when using `messages`.")}if(c){e.requestConfig&&s.isAbsolute(e.requestConfig)&&l("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: "+e.requestConfig);const n={"next-intl/config":m(e.requestConfig)};if(e.experimental?.messages?.precompile){let e=s.relative(process.cwd(),u.resolve("use-intl/format-message/format-only"));e.startsWith(".")||(e=`./${e}`),n["use-intl/format-message"]=e.replace(/\\/g,"/")}let c;if(e.experimental?.extract){a()||l("Message extraction requires Next.js 16 or higher."),c??=g();const t=(Array.isArray(e.experimental.srcPath)?e.experimental.srcPath:[e.experimental.srcPath]).map((e=>e.endsWith("/")?e.slice(0,-1):e));d(c,`*.{${o.EXTENSIONS.join(",")}}`,{loaders:[x()],condition:{path:`{${t.join(",")}}/**/*`,content:/(useExtracted|getExtracted)/}})}if(e.experimental?.messages){a()||l("Message catalog loading requires Next.js 16 or higher."),c??=g();d(c,`*${r(e.experimental.messages.format)}`,{loaders:[f()],condition:{path:`${e.experimental.messages.path}/**/*`},as:"*.js"})}i()&&!t?.experimental?.turbo?p.turbopack={...t?.turbopack,...c&&{rules:c},resolveAlias:{...t?.turbopack?.resolveAlias,...n}}:p.experimental={...t?.experimental,turbo:{...t?.experimental?.turbo,...c&&{rules:c},resolveAlias:{...t?.experimental?.turbo?.resolveAlias,...n}}}}return n||(p.webpack=function(n,a){if(n.resolve||(n.resolve={}),n.resolve.alias||(n.resolve.alias={}),n.resolve.alias["next-intl/config"]=s.resolve(n.context,m(e.requestConfig,n.context)),e.experimental?.messages?.precompile&&(n.resolve.alias["use-intl/format-message"]=u.resolve("use-intl/format-message/format-only")),e.experimental?.extract){n.module||(n.module={}),n.module.rules||(n.module.rules=[]);const t=e.experimental.srcPath;n.module.rules.push({test:new RegExp(`\\.(${o.EXTENSIONS.join("|")})$`),include:Array.isArray(t)?t.map((e=>s.resolve(n.context,e))):s.resolve(n.context,t||""),use:[x()]})}if(e.experimental?.messages){n.module||(n.module={}),n.module.rules||(n.module.rules=[]);const t=r(e.experimental.messages.format);n.module.rules.push({test:new RegExp(`${t.replace(/\./g,"\\.")}$`),include:s.resolve(n.context,e.experimental.messages.path),use:[f()],type:"javascript/auto"})}return"function"==typeof t?.webpack?t.webpack(n,a):n}),t?.trailingSlash&&(p.env={...t.env,_next_intl_trailing_slash:"true"}),Object.assign({},t,p)}export{p as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.2",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -127,11 +127,11 @@
|
|
|
127
127
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
128
128
|
"@parcel/watcher": "^2.4.1",
|
|
129
129
|
"@swc/core": "^1.15.2",
|
|
130
|
-
"icu-minify": "^4.8.
|
|
130
|
+
"icu-minify": "^4.8.2",
|
|
131
131
|
"negotiator": "^1.0.0",
|
|
132
|
-
"next-intl-swc-plugin-extractor": "^4.8.
|
|
132
|
+
"next-intl-swc-plugin-extractor": "^4.8.2",
|
|
133
133
|
"po-parser": "^2.1.1",
|
|
134
|
-
"use-intl": "^4.8.
|
|
134
|
+
"use-intl": "^4.8.2"
|
|
135
135
|
},
|
|
136
136
|
"peerDependencies": {
|
|
137
137
|
"next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
@@ -143,5 +143,5 @@
|
|
|
143
143
|
"optional": true
|
|
144
144
|
}
|
|
145
145
|
},
|
|
146
|
-
"gitHead": "
|
|
146
|
+
"gitHead": "de4baeb465185133923b69c8da36457c9418d781"
|
|
147
147
|
}
|