next-intlayer 5.3.11 → 5.3.12
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/client/useLocalePageRouter.cjs +4 -4
- package/dist/cjs/client/useLocalePageRouter.cjs.map +1 -1
- package/dist/cjs/server/compareVersion.cjs +57 -0
- package/dist/cjs/server/compareVersion.cjs.map +1 -0
- package/dist/cjs/server/getNextVertion.cjs +39 -0
- package/dist/cjs/server/getNextVertion.cjs.map +1 -0
- package/dist/cjs/server/withIntlayer.cjs +57 -41
- package/dist/cjs/server/withIntlayer.cjs.map +1 -1
- package/dist/esm/client/useLocalePageRouter.mjs +2 -2
- package/dist/esm/client/useLocalePageRouter.mjs.map +1 -1
- package/dist/esm/server/compareVersion.mjs +33 -0
- package/dist/esm/server/compareVersion.mjs.map +1 -0
- package/dist/esm/server/getNextVertion.mjs +15 -0
- package/dist/esm/server/getNextVertion.mjs.map +1 -0
- package/dist/esm/server/withIntlayer.mjs +48 -45
- package/dist/esm/server/withIntlayer.mjs.map +1 -1
- package/dist/types/client/useLocalePageRouter.d.ts +3 -3
- package/dist/types/client/useLocalePageRouter.d.ts.map +1 -1
- package/dist/types/server/compareVersion.d.ts +10 -0
- package/dist/types/server/compareVersion.d.ts.map +1 -0
- package/dist/types/server/getNextVertion.d.ts +2 -0
- package/dist/types/server/getNextVertion.d.ts.map +1 -0
- package/dist/types/server/withIntlayer.d.ts +1 -1
- package/dist/types/server/withIntlayer.d.ts.map +1 -1
- package/package.json +17 -16
|
@@ -22,23 +22,23 @@ __export(useLocalePageRouter_exports, {
|
|
|
22
22
|
useLocalePageRouter: () => useLocalePageRouter
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(useLocalePageRouter_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_core = require("@intlayer/core");
|
|
26
26
|
var import_router = require("next/router.js");
|
|
27
27
|
var import_react = require("react");
|
|
28
28
|
var import_react_intlayer = require("react-intlayer");
|
|
29
29
|
const useLocalePageRouter = () => {
|
|
30
30
|
const { push, pathname, reload } = (0, import_router.useRouter)();
|
|
31
31
|
const pathWithoutLocale = (0, import_react.useMemo)(
|
|
32
|
-
() => (0,
|
|
32
|
+
() => (0, import_core.getPathWithoutLocale)(pathname),
|
|
33
33
|
[pathname]
|
|
34
34
|
);
|
|
35
35
|
const redirectionFunction = (0, import_react.useCallback)(
|
|
36
36
|
(locale) => {
|
|
37
|
-
const pathWithLocale = (0,
|
|
37
|
+
const pathWithLocale = (0, import_core.getLocalizedUrl)(pathWithoutLocale, locale);
|
|
38
38
|
push(pathWithLocale);
|
|
39
39
|
return reload();
|
|
40
40
|
},
|
|
41
|
-
[
|
|
41
|
+
[pathWithoutLocale]
|
|
42
42
|
);
|
|
43
43
|
const reactLocaleHook = (0, import_react_intlayer.useLocale)({
|
|
44
44
|
onLocaleChange: redirectionFunction
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useLocalePageRouter.ts"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useLocalePageRouter.ts"],"sourcesContent":["'use client';\n\nimport { LocalesValues } from '@intlayer/config/client';\nimport { getLocalizedUrl, getPathWithoutLocale } from '@intlayer/core';\nimport { useRouter } from 'next/router.js';\nimport { useCallback, useMemo } from 'react';\nimport { useLocale as useLocaleReact } from 'react-intlayer';\n\nexport const useLocalePageRouter = () => {\n const { push, pathname, reload } = useRouter();\n const pathWithoutLocale = useMemo(\n () => getPathWithoutLocale(pathname),\n [pathname]\n );\n\n const redirectionFunction = useCallback(\n (locale: LocalesValues) => {\n const pathWithLocale = getLocalizedUrl(pathWithoutLocale, locale);\n\n push(pathWithLocale);\n\n return reload();\n },\n [pathWithoutLocale]\n );\n\n const reactLocaleHook = useLocaleReact({\n onLocaleChange: redirectionFunction,\n });\n\n return {\n ...reactLocaleHook,\n pathWithoutLocale,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAsD;AACtD,oBAA0B;AAC1B,mBAAqC;AACrC,4BAA4C;AAErC,MAAM,sBAAsB,MAAM;AACvC,QAAM,EAAE,MAAM,UAAU,OAAO,QAAI,yBAAU;AAC7C,QAAM,wBAAoB;AAAA,IACxB,UAAM,kCAAqB,QAAQ;AAAA,IACnC,CAAC,QAAQ;AAAA,EACX;AAEA,QAAM,0BAAsB;AAAA,IAC1B,CAAC,WAA0B;AACzB,YAAM,qBAAiB,6BAAgB,mBAAmB,MAAM;AAEhE,WAAK,cAAc;AAEnB,aAAO,OAAO;AAAA,IAChB;AAAA,IACA,CAAC,iBAAiB;AAAA,EACpB;AAEA,QAAM,sBAAkB,sBAAAA,WAAe;AAAA,IACrC,gBAAgB;AAAA,EAClB,CAAC;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,EACF;AACF;","names":["useLocaleReact"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var compareVersion_exports = {};
|
|
20
|
+
__export(compareVersion_exports, {
|
|
21
|
+
compareVersions: () => compareVersions
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(compareVersion_exports);
|
|
24
|
+
const compareVersions = (version1, comparison, version2) => {
|
|
25
|
+
const v1Parts = version1.split(".").map(Number);
|
|
26
|
+
const v2Parts = version2.split(".").map(Number);
|
|
27
|
+
const maxLen = Math.max(v1Parts.length, v2Parts.length);
|
|
28
|
+
let result = 0;
|
|
29
|
+
for (let i = 0; i < maxLen; i++) {
|
|
30
|
+
const part1 = v1Parts[i] || 0;
|
|
31
|
+
const part2 = v2Parts[i] || 0;
|
|
32
|
+
if (part1 > part2) {
|
|
33
|
+
result = 1;
|
|
34
|
+
break;
|
|
35
|
+
} else if (part1 < part2) {
|
|
36
|
+
result = -1;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
switch (comparison) {
|
|
41
|
+
case ">":
|
|
42
|
+
return result === 1;
|
|
43
|
+
case "<":
|
|
44
|
+
return result === -1;
|
|
45
|
+
case "=":
|
|
46
|
+
return result === 0;
|
|
47
|
+
case "\u2265":
|
|
48
|
+
return result === 0 || result === 1;
|
|
49
|
+
case "\u2264":
|
|
50
|
+
return result === 0 || result === -1;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
compareVersions
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=compareVersion.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/server/compareVersion.ts"],"sourcesContent":["/**\n * Compare two semver-like version strings (e.g. \"15.10.4\" vs \"15.3.4\").\n *\n * @param version1 - first version string\n * @param version2 - second version string\n * @param comparison - type of comparison: 'gt', 'lt', 'eq', 'gte', 'lte'\n * @returns boolean indicating if version1 meets the specified comparison condition vs version2\n */\nexport const compareVersions = (\n version1: string,\n comparison: '>' | '<' | '=' | '≥' | '≤',\n version2: string\n): boolean => {\n const v1Parts = version1.split('.').map(Number);\n const v2Parts = version2.split('.').map(Number);\n const maxLen = Math.max(v1Parts.length, v2Parts.length);\n\n // Compute a basic -1, 0, or 1 comparison\n let result = 0;\n for (let i = 0; i < maxLen; i++) {\n const part1 = v1Parts[i] || 0;\n const part2 = v2Parts[i] || 0;\n if (part1 > part2) {\n result = 1;\n break;\n } else if (part1 < part2) {\n result = -1;\n break;\n }\n }\n\n switch (comparison) {\n case '>':\n return result === 1;\n case '<':\n return result === -1;\n case '=':\n return result === 0;\n case '≥':\n return result === 0 || result === 1;\n case '≤':\n return result === 0 || result === -1;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,MAAM,kBAAkB,CAC7B,UACA,YACA,aACY;AACZ,QAAM,UAAU,SAAS,MAAM,GAAG,EAAE,IAAI,MAAM;AAC9C,QAAM,UAAU,SAAS,MAAM,GAAG,EAAE,IAAI,MAAM;AAC9C,QAAM,SAAS,KAAK,IAAI,QAAQ,QAAQ,QAAQ,MAAM;AAGtD,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,QAAQ,KAAK;AAC/B,UAAM,QAAQ,QAAQ,CAAC,KAAK;AAC5B,UAAM,QAAQ,QAAQ,CAAC,KAAK;AAC5B,QAAI,QAAQ,OAAO;AACjB,eAAS;AACT;AAAA,IACF,WAAW,QAAQ,OAAO;AACxB,eAAS;AACT;AAAA,IACF;AAAA,EACF;AAEA,UAAQ,YAAY;AAAA,IAClB,KAAK;AACH,aAAO,WAAW;AAAA,IACpB,KAAK;AACH,aAAO,WAAW;AAAA,IACpB,KAAK;AACH,aAAO,WAAW;AAAA,IACpB,KAAK;AACH,aAAO,WAAW,KAAK,WAAW;AAAA,IACpC,KAAK;AACH,aAAO,WAAW,KAAK,WAAW;AAAA,EACtC;AACF;","names":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var getNextVertion_exports = {};
|
|
20
|
+
__export(getNextVertion_exports, {
|
|
21
|
+
getNextVersion: () => getNextVersion
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(getNextVertion_exports);
|
|
24
|
+
var import_config = require("@intlayer/config");
|
|
25
|
+
var import_fs = require("fs");
|
|
26
|
+
const getNextVersion = () => {
|
|
27
|
+
try {
|
|
28
|
+
const nextConfigPath = import_config.ESMxCJSRequire.resolve("next/package.json");
|
|
29
|
+
const nextPkg = JSON.parse((0, import_fs.readFileSync)(nextConfigPath, "utf-8"));
|
|
30
|
+
return nextPkg.version;
|
|
31
|
+
} catch (e) {
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
getNextVersion
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=getNextVertion.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/server/getNextVertion.ts"],"sourcesContent":["import { ESMxCJSRequire } from '@intlayer/config';\nimport { readFileSync } from 'fs';\n\nexport const getNextVersion = () => {\n try {\n const nextConfigPath = ESMxCJSRequire.resolve('next/package.json');\n\n const nextPkg = JSON.parse(readFileSync(nextConfigPath, 'utf-8'));\n\n return nextPkg.version;\n } catch (e) {\n return undefined;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+B;AAC/B,gBAA6B;AAEtB,MAAM,iBAAiB,MAAM;AAClC,MAAI;AACF,UAAM,iBAAiB,6BAAe,QAAQ,mBAAmB;AAEjE,UAAM,UAAU,KAAK,UAAM,wBAAa,gBAAgB,OAAO,CAAC;AAEhE,WAAO,QAAQ;AAAA,EACjB,SAAS,GAAG;AACV,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,27 +17,31 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var withIntlayer_exports = {};
|
|
20
30
|
__export(withIntlayer_exports, {
|
|
21
31
|
withIntlayer: () => withIntlayer
|
|
22
32
|
});
|
|
23
33
|
module.exports = __toCommonJS(withIntlayer_exports);
|
|
24
|
-
var import_path = require("path");
|
|
25
34
|
var import_config = require("@intlayer/config");
|
|
26
35
|
var import_webpack = require("@intlayer/webpack");
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const nextPkg = JSON.parse((0, import_fs.readFileSync)(nextConfigPath, "utf-8"));
|
|
32
|
-
return parseInt(nextPkg.version.split(".")[0], 10);
|
|
33
|
-
} catch (e) {
|
|
34
|
-
return void 0;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
const nextMajorVersion = getNextVersion();
|
|
36
|
+
var import_deepmerge = __toESM(require("deepmerge"));
|
|
37
|
+
var import_path = require("path");
|
|
38
|
+
var import_compareVersion = require('./compareVersion.cjs');
|
|
39
|
+
var import_getNextVertion = require('./getNextVertion.cjs');
|
|
38
40
|
const isTurbopackEnabled = process.env.npm_lifecycle_script?.includes("--turbo");
|
|
41
|
+
const nextVersion = (0, import_getNextVertion.getNextVersion)();
|
|
42
|
+
const isGteNext13 = (0, import_compareVersion.compareVersions)(nextVersion, "\u2265", "13.0.0");
|
|
43
|
+
const isGteNext15 = (0, import_compareVersion.compareVersions)(nextVersion, "\u2265", "15.0.0");
|
|
44
|
+
const isTurbopackStable = (0, import_compareVersion.compareVersions)(nextVersion, "\u2265", "15.3.0");
|
|
39
45
|
const withIntlayer = (nextConfig = {}) => {
|
|
40
46
|
if (typeof nextConfig !== "object") {
|
|
41
47
|
nextConfig = {};
|
|
@@ -46,44 +52,54 @@ const withIntlayer = (nextConfig = {}) => {
|
|
|
46
52
|
const relativeDictionariesPath = (0, import_path.relative)(baseDir, dictionariesPath);
|
|
47
53
|
const configurationPath = (0, import_path.join)(configDir, "configuration.json");
|
|
48
54
|
const relativeConfigurationPath = (0, import_path.relative)(baseDir, configurationPath);
|
|
49
|
-
const turboConfig =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"*.node": {
|
|
59
|
-
as: "*.node",
|
|
60
|
-
loaders: ["node-loader"]
|
|
61
|
-
}
|
|
55
|
+
const turboConfig = {
|
|
56
|
+
resolveAlias: {
|
|
57
|
+
"@intlayer/dictionaries-entry": relativeDictionariesPath,
|
|
58
|
+
"@intlayer/config/built": relativeConfigurationPath
|
|
59
|
+
},
|
|
60
|
+
rules: {
|
|
61
|
+
"*.node": {
|
|
62
|
+
as: "*.node",
|
|
63
|
+
loaders: ["node-loader"]
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
|
-
}
|
|
66
|
+
};
|
|
67
|
+
const serverExternalPackages = [
|
|
68
|
+
"esbuild",
|
|
69
|
+
"module",
|
|
70
|
+
"fs",
|
|
71
|
+
"chokidar",
|
|
72
|
+
"fsevents"
|
|
73
|
+
];
|
|
65
74
|
const newConfig = {
|
|
66
75
|
// Only add `serverExternalPackages` if Next.js is v15+
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
...
|
|
79
|
-
|
|
76
|
+
...isGteNext15 ? {
|
|
77
|
+
// only for Next ≥15
|
|
78
|
+
serverExternalPackages
|
|
79
|
+
} : {
|
|
80
|
+
// only for Next ≥13 and <15.3
|
|
81
|
+
...isGteNext13 && {
|
|
82
|
+
serverComponentsExternalPackages: serverExternalPackages
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
...isTurbopackEnabled && {
|
|
86
|
+
env: (0, import_config.formatEnvVariable)("next"),
|
|
87
|
+
...isGteNext15 && isTurbopackStable ? {
|
|
88
|
+
// only for Next ≥15.3
|
|
89
|
+
turbopack: turboConfig
|
|
90
|
+
} : {
|
|
91
|
+
experimental: {
|
|
92
|
+
// only for Next ≥13 and <15.3
|
|
93
|
+
turbo: turboConfig
|
|
94
|
+
}
|
|
95
|
+
}
|
|
80
96
|
},
|
|
81
97
|
webpack: (config, options) => {
|
|
82
98
|
if (typeof nextConfig.webpack === "function") {
|
|
83
99
|
config = nextConfig.webpack(config, options);
|
|
84
100
|
}
|
|
85
101
|
config.resolve.alias = {
|
|
86
|
-
...config.resolve.alias
|
|
102
|
+
...config.resolve.alias,
|
|
87
103
|
"@intlayer/dictionaries-entry": (0, import_path.resolve)(relativeDictionariesPath),
|
|
88
104
|
"@intlayer/config/built": (0, import_path.resolve)(relativeConfigurationPath)
|
|
89
105
|
};
|
|
@@ -105,7 +121,7 @@ const withIntlayer = (nextConfig = {}) => {
|
|
|
105
121
|
return config;
|
|
106
122
|
}
|
|
107
123
|
};
|
|
108
|
-
return
|
|
124
|
+
return (0, import_deepmerge.default)(nextConfig, newConfig);
|
|
109
125
|
};
|
|
110
126
|
// Annotate the CommonJS export names for ESM import in node:
|
|
111
127
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { formatEnvVariable, 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 '@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 env: formatEnvVariable('next'),\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,oBAAoD;AACpD,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,WAAW,oBAAoB;AAC9D,QAAM,gCAA4B,sBAAS,SAAS,iBAAiB;AAGrE,QAAM,cAAc;AAAA,IAClB,cAAc;AAAA,MACZ,gCAAgC;AAAA,MAChC,0BAA0B;AAAA,IAC5B;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,SAAK,iCAAkB,MAAM;AAAA,MAC7B,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,oCAAgC,qBAAQ,wBAAwB;AAAA,QAChE,8BAA0B,qBAAQ,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,8BAAe,CAAC;AAAA,MAC1C;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAGA,aAAO,iBAAAA,SAAM,YAAY,SAAS;AACpC;","names":["merge"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { getLocalizedUrl, getPathWithoutLocale } from "intlayer";
|
|
2
|
+
import { getLocalizedUrl, getPathWithoutLocale } from "@intlayer/core";
|
|
3
3
|
import { useRouter } from "next/router.js";
|
|
4
4
|
import { useCallback, useMemo } from "react";
|
|
5
5
|
import { useLocale as useLocaleReact } from "react-intlayer";
|
|
@@ -15,7 +15,7 @@ const useLocalePageRouter = () => {
|
|
|
15
15
|
push(pathWithLocale);
|
|
16
16
|
return reload();
|
|
17
17
|
},
|
|
18
|
-
[
|
|
18
|
+
[pathWithoutLocale]
|
|
19
19
|
);
|
|
20
20
|
const reactLocaleHook = useLocaleReact({
|
|
21
21
|
onLocaleChange: redirectionFunction
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useLocalePageRouter.ts"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useLocalePageRouter.ts"],"sourcesContent":["'use client';\n\nimport { LocalesValues } from '@intlayer/config/client';\nimport { getLocalizedUrl, getPathWithoutLocale } from '@intlayer/core';\nimport { useRouter } from 'next/router.js';\nimport { useCallback, useMemo } from 'react';\nimport { useLocale as useLocaleReact } from 'react-intlayer';\n\nexport const useLocalePageRouter = () => {\n const { push, pathname, reload } = useRouter();\n const pathWithoutLocale = useMemo(\n () => getPathWithoutLocale(pathname),\n [pathname]\n );\n\n const redirectionFunction = useCallback(\n (locale: LocalesValues) => {\n const pathWithLocale = getLocalizedUrl(pathWithoutLocale, locale);\n\n push(pathWithLocale);\n\n return reload();\n },\n [pathWithoutLocale]\n );\n\n const reactLocaleHook = useLocaleReact({\n onLocaleChange: redirectionFunction,\n });\n\n return {\n ...reactLocaleHook,\n pathWithoutLocale,\n };\n};\n"],"mappings":";AAGA,SAAS,iBAAiB,4BAA4B;AACtD,SAAS,iBAAiB;AAC1B,SAAS,aAAa,eAAe;AACrC,SAAS,aAAa,sBAAsB;AAErC,MAAM,sBAAsB,MAAM;AACvC,QAAM,EAAE,MAAM,UAAU,OAAO,IAAI,UAAU;AAC7C,QAAM,oBAAoB;AAAA,IACxB,MAAM,qBAAqB,QAAQ;AAAA,IACnC,CAAC,QAAQ;AAAA,EACX;AAEA,QAAM,sBAAsB;AAAA,IAC1B,CAAC,WAA0B;AACzB,YAAM,iBAAiB,gBAAgB,mBAAmB,MAAM;AAEhE,WAAK,cAAc;AAEnB,aAAO,OAAO;AAAA,IAChB;AAAA,IACA,CAAC,iBAAiB;AAAA,EACpB;AAEA,QAAM,kBAAkB,eAAe;AAAA,IACrC,gBAAgB;AAAA,EAClB,CAAC;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const compareVersions = (version1, comparison, version2) => {
|
|
2
|
+
const v1Parts = version1.split(".").map(Number);
|
|
3
|
+
const v2Parts = version2.split(".").map(Number);
|
|
4
|
+
const maxLen = Math.max(v1Parts.length, v2Parts.length);
|
|
5
|
+
let result = 0;
|
|
6
|
+
for (let i = 0; i < maxLen; i++) {
|
|
7
|
+
const part1 = v1Parts[i] || 0;
|
|
8
|
+
const part2 = v2Parts[i] || 0;
|
|
9
|
+
if (part1 > part2) {
|
|
10
|
+
result = 1;
|
|
11
|
+
break;
|
|
12
|
+
} else if (part1 < part2) {
|
|
13
|
+
result = -1;
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
switch (comparison) {
|
|
18
|
+
case ">":
|
|
19
|
+
return result === 1;
|
|
20
|
+
case "<":
|
|
21
|
+
return result === -1;
|
|
22
|
+
case "=":
|
|
23
|
+
return result === 0;
|
|
24
|
+
case "\u2265":
|
|
25
|
+
return result === 0 || result === 1;
|
|
26
|
+
case "\u2264":
|
|
27
|
+
return result === 0 || result === -1;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
compareVersions
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=compareVersion.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/server/compareVersion.ts"],"sourcesContent":["/**\n * Compare two semver-like version strings (e.g. \"15.10.4\" vs \"15.3.4\").\n *\n * @param version1 - first version string\n * @param version2 - second version string\n * @param comparison - type of comparison: 'gt', 'lt', 'eq', 'gte', 'lte'\n * @returns boolean indicating if version1 meets the specified comparison condition vs version2\n */\nexport const compareVersions = (\n version1: string,\n comparison: '>' | '<' | '=' | '≥' | '≤',\n version2: string\n): boolean => {\n const v1Parts = version1.split('.').map(Number);\n const v2Parts = version2.split('.').map(Number);\n const maxLen = Math.max(v1Parts.length, v2Parts.length);\n\n // Compute a basic -1, 0, or 1 comparison\n let result = 0;\n for (let i = 0; i < maxLen; i++) {\n const part1 = v1Parts[i] || 0;\n const part2 = v2Parts[i] || 0;\n if (part1 > part2) {\n result = 1;\n break;\n } else if (part1 < part2) {\n result = -1;\n break;\n }\n }\n\n switch (comparison) {\n case '>':\n return result === 1;\n case '<':\n return result === -1;\n case '=':\n return result === 0;\n case '≥':\n return result === 0 || result === 1;\n case '≤':\n return result === 0 || result === -1;\n }\n};\n"],"mappings":"AAQO,MAAM,kBAAkB,CAC7B,UACA,YACA,aACY;AACZ,QAAM,UAAU,SAAS,MAAM,GAAG,EAAE,IAAI,MAAM;AAC9C,QAAM,UAAU,SAAS,MAAM,GAAG,EAAE,IAAI,MAAM;AAC9C,QAAM,SAAS,KAAK,IAAI,QAAQ,QAAQ,QAAQ,MAAM;AAGtD,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,QAAQ,KAAK;AAC/B,UAAM,QAAQ,QAAQ,CAAC,KAAK;AAC5B,UAAM,QAAQ,QAAQ,CAAC,KAAK;AAC5B,QAAI,QAAQ,OAAO;AACjB,eAAS;AACT;AAAA,IACF,WAAW,QAAQ,OAAO;AACxB,eAAS;AACT;AAAA,IACF;AAAA,EACF;AAEA,UAAQ,YAAY;AAAA,IAClB,KAAK;AACH,aAAO,WAAW;AAAA,IACpB,KAAK;AACH,aAAO,WAAW;AAAA,IACpB,KAAK;AACH,aAAO,WAAW;AAAA,IACpB,KAAK;AACH,aAAO,WAAW,KAAK,WAAW;AAAA,IACpC,KAAK;AACH,aAAO,WAAW,KAAK,WAAW;AAAA,EACtC;AACF;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ESMxCJSRequire } from "@intlayer/config";
|
|
2
|
+
import { readFileSync } from "fs";
|
|
3
|
+
const getNextVersion = () => {
|
|
4
|
+
try {
|
|
5
|
+
const nextConfigPath = ESMxCJSRequire.resolve("next/package.json");
|
|
6
|
+
const nextPkg = JSON.parse(readFileSync(nextConfigPath, "utf-8"));
|
|
7
|
+
return nextPkg.version;
|
|
8
|
+
} catch (e) {
|
|
9
|
+
return void 0;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
getNextVersion
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=getNextVertion.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/server/getNextVertion.ts"],"sourcesContent":["import { ESMxCJSRequire } from '@intlayer/config';\nimport { readFileSync } from 'fs';\n\nexport const getNextVersion = () => {\n try {\n const nextConfigPath = ESMxCJSRequire.resolve('next/package.json');\n\n const nextPkg = JSON.parse(readFileSync(nextConfigPath, 'utf-8'));\n\n return nextPkg.version;\n } catch (e) {\n return undefined;\n }\n};\n"],"mappings":"AAAA,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAEtB,MAAM,iBAAiB,MAAM;AAClC,MAAI;AACF,UAAM,iBAAiB,eAAe,QAAQ,mBAAmB;AAEjE,UAAM,UAAU,KAAK,MAAM,aAAa,gBAAgB,OAAO,CAAC;AAEhE,WAAO,QAAQ;AAAA,EACjB,SAAS,GAAG;AACV,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
getConfiguration,
|
|
4
|
-
ESMxCJSRequire
|
|
5
|
-
} from "@intlayer/config";
|
|
1
|
+
import { formatEnvVariable, getConfiguration } from "@intlayer/config";
|
|
6
2
|
import { IntlayerPlugin } from "@intlayer/webpack";
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const nextPkg = JSON.parse(readFileSync(nextConfigPath, "utf-8"));
|
|
12
|
-
return parseInt(nextPkg.version.split(".")[0], 10);
|
|
13
|
-
} catch (e) {
|
|
14
|
-
return void 0;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const nextMajorVersion = getNextVersion();
|
|
3
|
+
import merge from "deepmerge";
|
|
4
|
+
import { join, relative, resolve } from "path";
|
|
5
|
+
import { compareVersions } from "./compareVersion.mjs";
|
|
6
|
+
import { getNextVersion } from "./getNextVertion.mjs";
|
|
18
7
|
const isTurbopackEnabled = process.env.npm_lifecycle_script?.includes("--turbo");
|
|
8
|
+
const nextVersion = getNextVersion();
|
|
9
|
+
const isGteNext13 = compareVersions(nextVersion, "\u2265", "13.0.0");
|
|
10
|
+
const isGteNext15 = compareVersions(nextVersion, "\u2265", "15.0.0");
|
|
11
|
+
const isTurbopackStable = compareVersions(nextVersion, "\u2265", "15.3.0");
|
|
19
12
|
const withIntlayer = (nextConfig = {}) => {
|
|
20
13
|
if (typeof nextConfig !== "object") {
|
|
21
14
|
nextConfig = {};
|
|
@@ -26,44 +19,54 @@ const withIntlayer = (nextConfig = {}) => {
|
|
|
26
19
|
const relativeDictionariesPath = relative(baseDir, dictionariesPath);
|
|
27
20
|
const configurationPath = join(configDir, "configuration.json");
|
|
28
21
|
const relativeConfigurationPath = relative(baseDir, configurationPath);
|
|
29
|
-
const turboConfig =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"*.node": {
|
|
39
|
-
as: "*.node",
|
|
40
|
-
loaders: ["node-loader"]
|
|
41
|
-
}
|
|
22
|
+
const turboConfig = {
|
|
23
|
+
resolveAlias: {
|
|
24
|
+
"@intlayer/dictionaries-entry": relativeDictionariesPath,
|
|
25
|
+
"@intlayer/config/built": relativeConfigurationPath
|
|
26
|
+
},
|
|
27
|
+
rules: {
|
|
28
|
+
"*.node": {
|
|
29
|
+
as: "*.node",
|
|
30
|
+
loaders: ["node-loader"]
|
|
42
31
|
}
|
|
43
32
|
}
|
|
44
|
-
}
|
|
33
|
+
};
|
|
34
|
+
const serverExternalPackages = [
|
|
35
|
+
"esbuild",
|
|
36
|
+
"module",
|
|
37
|
+
"fs",
|
|
38
|
+
"chokidar",
|
|
39
|
+
"fsevents"
|
|
40
|
+
];
|
|
45
41
|
const newConfig = {
|
|
46
42
|
// Only add `serverExternalPackages` if Next.js is v15+
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
...
|
|
59
|
-
|
|
43
|
+
...isGteNext15 ? {
|
|
44
|
+
// only for Next ≥15
|
|
45
|
+
serverExternalPackages
|
|
46
|
+
} : {
|
|
47
|
+
// only for Next ≥13 and <15.3
|
|
48
|
+
...isGteNext13 && {
|
|
49
|
+
serverComponentsExternalPackages: serverExternalPackages
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
...isTurbopackEnabled && {
|
|
53
|
+
env: formatEnvVariable("next"),
|
|
54
|
+
...isGteNext15 && isTurbopackStable ? {
|
|
55
|
+
// only for Next ≥15.3
|
|
56
|
+
turbopack: turboConfig
|
|
57
|
+
} : {
|
|
58
|
+
experimental: {
|
|
59
|
+
// only for Next ≥13 and <15.3
|
|
60
|
+
turbo: turboConfig
|
|
61
|
+
}
|
|
62
|
+
}
|
|
60
63
|
},
|
|
61
64
|
webpack: (config, options) => {
|
|
62
65
|
if (typeof nextConfig.webpack === "function") {
|
|
63
66
|
config = nextConfig.webpack(config, options);
|
|
64
67
|
}
|
|
65
68
|
config.resolve.alias = {
|
|
66
|
-
...config.resolve.alias
|
|
69
|
+
...config.resolve.alias,
|
|
67
70
|
"@intlayer/dictionaries-entry": resolve(relativeDictionariesPath),
|
|
68
71
|
"@intlayer/config/built": resolve(relativeConfigurationPath)
|
|
69
72
|
};
|
|
@@ -85,7 +88,7 @@ const withIntlayer = (nextConfig = {}) => {
|
|
|
85
88
|
return config;
|
|
86
89
|
}
|
|
87
90
|
};
|
|
88
|
-
return
|
|
91
|
+
return merge(nextConfig, newConfig);
|
|
89
92
|
};
|
|
90
93
|
export {
|
|
91
94
|
withIntlayer
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { formatEnvVariable, 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 '@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 env: formatEnvVariable('next'),\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,mBAAmB,wBAAwB;AACpD,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,MACZ,gCAAgC;AAAA,MAChC,0BAA0B;AAAA,IAC5B;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,KAAK,kBAAkB,MAAM;AAAA,MAC7B,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,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LocalesValues } from '@intlayer/config/client';
|
|
2
2
|
export declare const useLocalePageRouter: () => {
|
|
3
3
|
pathWithoutLocale: string;
|
|
4
|
-
locale:
|
|
4
|
+
locale: LocalesValues;
|
|
5
5
|
defaultLocale: import("intlayer").Locales;
|
|
6
6
|
availableLocales: import("intlayer").Locales[];
|
|
7
7
|
localeList: import("intlayer").Locales[];
|
|
8
|
-
setLocale: (locale:
|
|
8
|
+
setLocale: (locale: LocalesValues) => void;
|
|
9
9
|
};
|
|
10
10
|
//# sourceMappingURL=useLocalePageRouter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalePageRouter.d.ts","sourceRoot":"","sources":["../../../src/client/useLocalePageRouter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useLocalePageRouter.d.ts","sourceRoot":"","sources":["../../../src/client/useLocalePageRouter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAMxD,eAAO,MAAM,mBAAmB;;;0BAChB,UAAU;6BACV,UAAU;uBACD,UAAU;;CAuBlC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compare two semver-like version strings (e.g. "15.10.4" vs "15.3.4").
|
|
3
|
+
*
|
|
4
|
+
* @param version1 - first version string
|
|
5
|
+
* @param version2 - second version string
|
|
6
|
+
* @param comparison - type of comparison: 'gt', 'lt', 'eq', 'gte', 'lte'
|
|
7
|
+
* @returns boolean indicating if version1 meets the specified comparison condition vs version2
|
|
8
|
+
*/
|
|
9
|
+
export declare const compareVersions: (version1: string, comparison: ">" | "<" | "=" | "\u2265" | "\u2264", version2: string) => boolean;
|
|
10
|
+
//# sourceMappingURL=compareVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compareVersion.d.ts","sourceRoot":"","sources":["../../../src/server/compareVersion.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,EAChB,YAAY,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,QAAG,GAAG,QAAG,EACvC,UAAU,MAAM,KACf,OA+BF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNextVertion.d.ts","sourceRoot":"","sources":["../../../src/server/getNextVertion.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,WAU1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withIntlayer.d.ts","sourceRoot":"","sources":["../../../src/server/withIntlayer.ts"],"names":[],"mappings":"
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intlayer",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.12",
|
|
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": [
|
|
@@ -67,13 +67,14 @@
|
|
|
67
67
|
"./package.json"
|
|
68
68
|
],
|
|
69
69
|
"dependencies": {
|
|
70
|
+
"deepmerge": "^4.3.1",
|
|
70
71
|
"node-loader": "^2.1.0",
|
|
71
|
-
"@intlayer/chokidar": "5.3.
|
|
72
|
-
"@intlayer/core": "5.3.
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"@intlayer/
|
|
76
|
-
"@intlayer/
|
|
72
|
+
"@intlayer/chokidar": "5.3.12",
|
|
73
|
+
"@intlayer/core": "5.3.12",
|
|
74
|
+
"react-intlayer": "5.3.12",
|
|
75
|
+
"@intlayer/dictionaries-entry": "5.3.12",
|
|
76
|
+
"@intlayer/config": "5.3.12",
|
|
77
|
+
"@intlayer/webpack": "5.3.12"
|
|
77
78
|
},
|
|
78
79
|
"devDependencies": {
|
|
79
80
|
"@types/node": "^22.13.10",
|
|
@@ -87,22 +88,22 @@
|
|
|
87
88
|
"tsc-alias": "^1.8.11",
|
|
88
89
|
"tsup": "^8.4.0",
|
|
89
90
|
"typescript": "^5.8.2",
|
|
90
|
-
"@utils/ts-config": "1.0.4",
|
|
91
91
|
"@utils/eslint-config": "1.0.4",
|
|
92
|
+
"@utils/ts-config": "1.0.4",
|
|
92
93
|
"@utils/tsup-config": "1.0.4",
|
|
93
|
-
"
|
|
94
|
-
"
|
|
94
|
+
"intlayer": "5.3.12",
|
|
95
|
+
"@utils/ts-config-types": "1.0.4"
|
|
95
96
|
},
|
|
96
97
|
"peerDependencies": {
|
|
97
98
|
"next": ">=14.0.0",
|
|
98
99
|
"react": ">=16.0.0",
|
|
99
100
|
"react-dom": ">=16.0.0",
|
|
100
|
-
"@intlayer/config": "5.3.
|
|
101
|
-
"@intlayer/
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"intlayer": "5.3.
|
|
101
|
+
"@intlayer/config": "5.3.12",
|
|
102
|
+
"@intlayer/dictionaries-entry": "5.3.12",
|
|
103
|
+
"intlayer": "5.3.12",
|
|
104
|
+
"@intlayer/webpack": "5.3.12",
|
|
105
|
+
"react-intlayer": "5.3.12",
|
|
106
|
+
"@intlayer/core": "5.3.12"
|
|
106
107
|
},
|
|
107
108
|
"engines": {
|
|
108
109
|
"node": ">=14.18"
|