@koine/next 2.0.0-beta.2 → 2.0.0-beta.4
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/12/AnalyticsGoogle.js +65 -25
- package/12/AnalyticsGoogle.mjs +41 -15
- package/12/DisableErrorOverlay.js +29 -16
- package/12/DisableErrorOverlay.mjs +8 -5
- package/12/DynamicNamespaces.d.ts +1 -1
- package/12/DynamicNamespaces.js +22 -12
- package/12/DynamicNamespaces.mjs +1 -2
- package/12/Favicon.js +28 -9
- package/12/Favicon.mjs +6 -2
- package/12/Link.d.ts +1 -1
- package/12/Link.js +36 -13
- package/12/Link.mjs +14 -6
- package/12/NextProgress.js +47 -24
- package/12/NextProgress.mjs +26 -17
- package/12/Seo.d.ts +1 -1
- package/12/Seo.js +27 -32
- package/12/Seo.mjs +5 -4
- package/12/SeoDefaults.d.ts +1 -1
- package/12/SeoDefaults.js +27 -13
- package/12/SeoDefaults.mjs +5 -3
- package/12/T.d.ts +1 -1
- package/12/T.js +42 -16
- package/12/T.mjs +20 -6
- package/12/ThemeContext.js +22 -7
- package/12/ThemeContext.mjs +3 -3
- package/12/ThemeProvider.js +164 -147
- package/12/ThemeProvider.mjs +139 -129
- package/12/TransText.js +22 -7
- package/12/TransText.mjs +1 -1
- package/12/app/AppHead.js +29 -9
- package/12/app/AppHead.mjs +8 -2
- package/12/app/AppMain.d.ts +4 -4
- package/12/app/AppMain.js +5 -1
- package/12/app/AppMain.mjs +1 -1
- package/12/app/css/AppMain.js +37 -16
- package/12/app/css/AppMain.mjs +15 -5
- package/12/app/css/AppTheme.d.ts +1 -1
- package/12/app/css/AppTheme.js +28 -13
- package/12/app/css/AppTheme.mjs +7 -4
- package/12/app/css/auth/index.d.ts +1 -1
- package/12/app/css/auth/index.js +38 -15
- package/12/app/css/auth/index.mjs +17 -6
- package/12/app/css/index.d.ts +1 -1
- package/12/app/css/index.js +34 -59
- package/12/app/css/index.mjs +14 -6
- package/12/app/index.js +6 -4
- package/12/app/sc/AppMain.js +68 -27
- package/12/app/sc/AppMain.mjs +46 -13
- package/12/app/sc/AppTheme.d.ts +1 -1
- package/12/app/sc/AppTheme.js +31 -13
- package/12/app/sc/AppTheme.mjs +9 -4
- package/12/app/sc/auth/index.d.ts +1 -1
- package/12/app/sc/auth/index.js +38 -15
- package/12/app/sc/auth/index.mjs +17 -6
- package/12/app/sc/index.d.ts +1 -1
- package/12/app/sc/index.js +34 -61
- package/12/app/sc/index.mjs +14 -6
- package/12/document/Document.js +47 -29
- package/12/document/Document.mjs +24 -14
- package/12/document/css/index.js +47 -32
- package/12/document/css/index.mjs +26 -18
- package/12/document/index.js +18 -6
- package/12/document/sc/index.js +71 -65
- package/12/document/sc/index.mjs +46 -45
- package/12/getT.js +22 -13
- package/12/getT.mjs +2 -4
- package/12/index.js +99 -51
- package/12/index.mjs +2 -2
- package/12/seoBuildTags.js +81 -76
- package/12/seoBuildTags.mjs +59 -55
- package/12/to.js +21 -19
- package/12/to.mjs +4 -10
- package/12/translationAsOptions.js +15 -9
- package/12/translationAsOptions.mjs +6 -6
- package/12/types-i18n.js +4 -3
- package/12/types-i18n.mjs +1 -2
- package/12/types-seo.js +3 -1
- package/12/types-seo.mjs +1 -1
- package/12/useBackUrl.js +30 -16
- package/12/useBackUrl.mjs +8 -8
- package/12/useDateFormat.js +37 -38
- package/12/useDateFormat.mjs +15 -28
- package/12/useForm.d.ts +1 -1
- package/12/useForm.js +46 -20
- package/12/useForm.mjs +25 -13
- package/12/useLocale.js +22 -8
- package/12/useT.d.ts +1 -1
- package/12/useT.js +53 -39
- package/12/useT.mjs +32 -14
- package/12/useTheme.js +22 -11
- package/12/useTheme.mjs +1 -2
- package/12/useTo.js +23 -16
- package/12/useTo.mjs +3 -10
- package/README.md +1 -1
- package/config/index.js +225 -251
- package/config/index.mjs +187 -204
- package/getSiteUrl.js +22 -15
- package/getSiteUrl.mjs +2 -4
- package/index.js +19 -6
- package/load.js +21 -8
- package/load.mjs +3 -4
- package/package.json +19 -17
- package/12/app/css/auth/package.json +0 -6
- package/12/app/css/package.json +0 -6
- package/12/app/package.json +0 -6
- package/12/app/sc/auth/package.json +0 -6
- package/12/app/sc/package.json +0 -6
- package/12/document/css/package.json +0 -6
- package/12/document/package.json +0 -6
- package/12/document/sc/package.json +0 -6
- package/12/package.json +0 -6
- package/config/package.json +0 -6
package/config/index.js
CHANGED
|
@@ -1,62 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
normaliseUrlPathname: function() {
|
|
13
|
+
return normaliseUrlPathname;
|
|
14
|
+
},
|
|
15
|
+
toPath: function() {
|
|
16
|
+
return toPath;
|
|
17
|
+
},
|
|
18
|
+
encodePathname: function() {
|
|
19
|
+
return encodePathname;
|
|
20
|
+
},
|
|
21
|
+
getPathRewrite: function() {
|
|
22
|
+
return getPathRewrite;
|
|
23
|
+
},
|
|
24
|
+
getPathRedirect: function() {
|
|
25
|
+
return getPathRedirect;
|
|
26
|
+
},
|
|
27
|
+
getRedirects: function() {
|
|
28
|
+
return getRedirects;
|
|
29
|
+
},
|
|
30
|
+
getRewrites: function() {
|
|
31
|
+
return getRewrites;
|
|
32
|
+
},
|
|
33
|
+
withKoine: function() {
|
|
34
|
+
return withKoine;
|
|
35
|
+
},
|
|
36
|
+
default: function() {
|
|
37
|
+
return _default;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
function normaliseUrlPathname(pathname = "") {
|
|
16
41
|
// with return pathname.replace(/\/+\//g, "/").replace(/^\/+(.*?)\/+$/, "$1");
|
|
17
42
|
// we would instead return a single slash if only slashes are given
|
|
18
43
|
return pathname.replace(/\/+\//g, "/").replace(/^\/*(.*?)\/*$/, "$1");
|
|
19
44
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* Transform to path any absolute or relative URL
|
|
23
|
-
*
|
|
24
|
-
* Useful when setting up `rewrites` and `redirects` especally in a [multi-zones
|
|
25
|
-
* setup](https://nextjs.org/docs/advanced-features/multi-zones).
|
|
26
|
-
*
|
|
27
|
-
* From a path like `http://localhost/some//malformed/path///` it returns `/some/malformed/path`
|
|
28
|
-
*
|
|
29
|
-
* @see {@link normaliseUrlPathname}
|
|
30
|
-
*/
|
|
31
|
-
function toPath(urlOrPathname) {
|
|
32
|
-
if (urlOrPathname === void 0) { urlOrPathname = ""; }
|
|
33
|
-
var pathname = "";
|
|
45
|
+
function toPath(urlOrPathname = "") {
|
|
46
|
+
let pathname = "";
|
|
34
47
|
try {
|
|
35
|
-
|
|
48
|
+
const parsed = new URL(urlOrPathname);
|
|
36
49
|
pathname = parsed.pathname;
|
|
37
|
-
}
|
|
38
|
-
catch (e) {
|
|
50
|
+
} catch (e) {
|
|
39
51
|
pathname = urlOrPathname;
|
|
40
52
|
}
|
|
41
53
|
// with return pathname.replace(/\/+\//g, "/").replace(/^\/+(.*?)\/+$/, "$1");
|
|
42
54
|
// we would instead return a single slash if only slashes are given
|
|
43
55
|
return pathname.replace(/\/+\//g, "/").replace(/^\/*(.*?)\/*$/, "$1");
|
|
44
56
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
* @see {@link normaliseUrlPathname}
|
|
50
|
-
*/
|
|
51
|
-
function encodePathname(pathname) {
|
|
52
|
-
if (pathname === void 0) { pathname = ""; }
|
|
53
|
-
var parts = normaliseUrlPathname(pathname).split("/");
|
|
54
|
-
return parts
|
|
55
|
-
.filter(function (part) { return !!part; })
|
|
56
|
-
.map(function (part) { return encodeURIComponent(part); })
|
|
57
|
-
.join("/");
|
|
57
|
+
function encodePathname(pathname = "") {
|
|
58
|
+
const parts = normaliseUrlPathname(pathname).split("/");
|
|
59
|
+
return parts.filter((part)=>!!part).map((part)=>encodeURIComponent(part)).join("/");
|
|
58
60
|
}
|
|
59
|
-
exports.encodePathname = encodePathname;
|
|
60
61
|
/**
|
|
61
62
|
* Transform the route translated defintion into a `pathname` and a `template`.
|
|
62
63
|
*
|
|
@@ -66,61 +67,48 @@ exports.encodePathname = encodePathname;
|
|
|
66
67
|
* having asterisks there is a bit cumbersome.
|
|
67
68
|
*
|
|
68
69
|
* @see https://nextjs.org/docs/messages/invalid-multi-match
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
.map(function (part) {
|
|
77
|
-
var _a, _b;
|
|
78
|
-
var hasWildcard = part.endsWith("*");
|
|
70
|
+
*/ function transformRoute(route) {
|
|
71
|
+
const { pathname: rawPathname, template: rawTemplate } = route;
|
|
72
|
+
const pathnameParts = rawPathname.split("/").filter((part)=>!!part);
|
|
73
|
+
const templateParts = rawTemplate.split("/").filter((part)=>!!part);
|
|
74
|
+
const mapPartsByIdx = {};
|
|
75
|
+
const pathname = pathnameParts.map((part)=>{
|
|
76
|
+
const hasWildcard = part.endsWith("*");
|
|
79
77
|
part = part.replace("*", "");
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
: part.trim();
|
|
84
|
-
var asPath = encodeURIComponent(asValue) + (hasWildcard ? "*" : "");
|
|
78
|
+
const isDynamic = part.startsWith("{{") && part.endsWith("}}");
|
|
79
|
+
const asValue = isDynamic ? part.match(/{{(.+)}}/)?.[1].trim() ?? "" : part.trim();
|
|
80
|
+
const asPath = encodeURIComponent(asValue) + (hasWildcard ? "*" : "");
|
|
85
81
|
mapPartsByIdx[asValue] = {
|
|
86
|
-
isDynamic
|
|
87
|
-
hasWildcard
|
|
82
|
+
isDynamic,
|
|
83
|
+
hasWildcard
|
|
88
84
|
};
|
|
89
|
-
return isDynamic ?
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
})
|
|
103
|
-
.join("/");
|
|
104
|
-
return { pathname: pathname, template: template };
|
|
85
|
+
return isDynamic ? `:${asPath}` : asPath;
|
|
86
|
+
}).join("/");
|
|
87
|
+
const template = templateParts.map((part)=>{
|
|
88
|
+
const isDynamic = part.startsWith("[") && part.endsWith("]");
|
|
89
|
+
const asValue = isDynamic ? part.match(/\[(.+)\]/)?.[1].trim() ?? "" : part.trim();
|
|
90
|
+
const hasWildcard = mapPartsByIdx[asValue]?.hasWildcard;
|
|
91
|
+
const asPath = encodeURIComponent(asValue) + (hasWildcard ? "*" : "");
|
|
92
|
+
return isDynamic ? `:${asPath}` : asPath;
|
|
93
|
+
}).join("/");
|
|
94
|
+
return {
|
|
95
|
+
pathname,
|
|
96
|
+
template
|
|
97
|
+
};
|
|
105
98
|
}
|
|
106
99
|
/**
|
|
107
100
|
* Get routes map dictionary
|
|
108
|
-
*/
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (templateBuffer === void 0) { templateBuffer = ""; }
|
|
113
|
-
for (var key in routes) {
|
|
114
|
-
var pathOrNestedRoutes = routes[key];
|
|
115
|
-
var template = "".concat(templateBuffer, "/").concat(key);
|
|
101
|
+
*/ function getRoutesMap(map = {}, routes, pathnameBuffer = "", templateBuffer = "") {
|
|
102
|
+
for(const key in routes){
|
|
103
|
+
const pathOrNestedRoutes = routes[key];
|
|
104
|
+
const template = `${templateBuffer}/${key}`;
|
|
116
105
|
if (typeof pathOrNestedRoutes === "string") {
|
|
117
106
|
map[template] = {
|
|
118
|
-
template
|
|
107
|
+
template,
|
|
119
108
|
pathname: pathOrNestedRoutes,
|
|
120
|
-
wildcard: pathOrNestedRoutes.includes("*")
|
|
109
|
+
wildcard: pathOrNestedRoutes.includes("*")
|
|
121
110
|
};
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
111
|
+
} else {
|
|
124
112
|
getRoutesMap(map, pathOrNestedRoutes, pathnameBuffer, template);
|
|
125
113
|
}
|
|
126
114
|
}
|
|
@@ -128,137 +116,131 @@ function getRoutesMap(map, routes, pathnameBuffer, templateBuffer) {
|
|
|
128
116
|
}
|
|
129
117
|
/**
|
|
130
118
|
* Removes `/index` from a template/url path
|
|
131
|
-
*/
|
|
132
|
-
function getWithoutIndex(template) {
|
|
119
|
+
*/ function getWithoutIndex(template) {
|
|
133
120
|
return template.replace(/\/index$/, "");
|
|
134
121
|
}
|
|
135
|
-
/**
|
|
136
|
-
* Get path rewrite
|
|
137
|
-
*/
|
|
138
122
|
function getPathRewrite(route) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
123
|
+
const { pathname, template } = transformRoute(route);
|
|
124
|
+
const source = `/${normaliseUrlPathname(pathname)}`;
|
|
125
|
+
const destination = `/${normaliseUrlPathname(template)}`;
|
|
142
126
|
// console.log(`rewrite pathname "${source}" to template "${destination}"`);
|
|
143
127
|
return {
|
|
144
|
-
source
|
|
145
|
-
destination: getWithoutIndex(destination)
|
|
128
|
+
source,
|
|
129
|
+
destination: getWithoutIndex(destination)
|
|
146
130
|
};
|
|
147
131
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
function getPathRedirect(locale, route, permanent) {
|
|
153
|
-
if (locale === void 0) { locale = ""; }
|
|
154
|
-
var _a = transformRoute(route), template = _a.template, pathname = _a.pathname;
|
|
155
|
-
var source = "/".concat(normaliseUrlPathname((locale ? "/".concat(locale, "/") : "/") + template));
|
|
156
|
-
var destination = "/".concat(normaliseUrlPathname(pathname));
|
|
132
|
+
function getPathRedirect(locale = "", route, permanent) {
|
|
133
|
+
const { template, pathname } = transformRoute(route);
|
|
134
|
+
const source = `/${normaliseUrlPathname((locale ? `/${locale}/` : "/") + template)}`;
|
|
135
|
+
const destination = `/${normaliseUrlPathname(pathname)}`;
|
|
157
136
|
// console.log(`redirect template "${source}" to pathname "${destination}"`);
|
|
158
137
|
return {
|
|
159
138
|
source: getWithoutIndex(source),
|
|
160
|
-
destination
|
|
139
|
+
destination,
|
|
161
140
|
permanent: Boolean(permanent),
|
|
162
|
-
locale: false
|
|
141
|
+
locale: false
|
|
163
142
|
};
|
|
164
143
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
// if (hideDefaultLocaleInUrl) {
|
|
183
|
-
// redirects.push(getPathRedirect(defaultLocale, route, permanent));
|
|
184
|
-
// }
|
|
185
|
-
if (route.pathname !== getWithoutIndex(template)) {
|
|
186
|
-
redirects.push(getPathRedirect("", route, permanent));
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
if (debug)
|
|
190
|
-
console.info("[@koine/next/config:getRedirects]", redirects);
|
|
191
|
-
return [2 /*return*/, redirects];
|
|
192
|
-
});
|
|
144
|
+
async function getRedirects(defaultLocale, routes, permanent, debug) {
|
|
145
|
+
const redirects = [];
|
|
146
|
+
const routesMap = getRoutesMap({}, routes);
|
|
147
|
+
Object.keys(routesMap).forEach((template)=>{
|
|
148
|
+
const route = routesMap[template];
|
|
149
|
+
// TODO: add option hideDefaultLocaleInUrl?
|
|
150
|
+
// this is meant to redirect the URL with the default locale to the same
|
|
151
|
+
// url without locale prefix, e.g.: /en/about -> /about (assuming en is the
|
|
152
|
+
// defualt locale).
|
|
153
|
+
// Actually this redirect seem not to be necessary, probably the i18n routing
|
|
154
|
+
// mechanism of next 12 already does this, enabling causes infinite redirects
|
|
155
|
+
// if (hideDefaultLocaleInUrl) {
|
|
156
|
+
// redirects.push(getPathRedirect(defaultLocale, route, permanent));
|
|
157
|
+
// }
|
|
158
|
+
if (route.pathname !== getWithoutIndex(template)) {
|
|
159
|
+
redirects.push(getPathRedirect("", route, permanent));
|
|
160
|
+
}
|
|
193
161
|
});
|
|
162
|
+
if (debug) console.info("[@koine/next/config:getRedirects]", redirects);
|
|
163
|
+
return redirects;
|
|
194
164
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
routesMap = getRoutesMap({}, routes);
|
|
204
|
-
Object.keys(routesMap).forEach(function (template) {
|
|
205
|
-
var route = routesMap[template];
|
|
206
|
-
if (route.pathname !== getWithoutIndex(template)) {
|
|
207
|
-
rewrites.push(getPathRewrite(route));
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
if (debug)
|
|
211
|
-
console.info("[@koine/next/config:getRewrites]", rewrites);
|
|
212
|
-
return [2 /*return*/, rewrites];
|
|
213
|
-
});
|
|
165
|
+
async function getRewrites(routes, debug) {
|
|
166
|
+
const rewrites = [];
|
|
167
|
+
const routesMap = getRoutesMap({}, routes);
|
|
168
|
+
Object.keys(routesMap).forEach((template)=>{
|
|
169
|
+
const route = routesMap[template];
|
|
170
|
+
if (route.pathname !== getWithoutIndex(template)) {
|
|
171
|
+
rewrites.push(getPathRewrite(route));
|
|
172
|
+
}
|
|
214
173
|
});
|
|
174
|
+
if (debug) console.info("[@koine/next/config:getRewrites]", rewrites);
|
|
175
|
+
return rewrites;
|
|
215
176
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
* extension for next.js config option [`pageExtensions`](https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions#including-non-page-files-in-the-pages-directory)
|
|
226
|
-
* and it enables the same for `next-translate`.
|
|
227
|
-
*/
|
|
228
|
-
function withKoine(_a) {
|
|
229
|
-
var _b;
|
|
230
|
-
if (_a === void 0) { _a = {
|
|
231
|
-
i18n: { locales: ["en"], defaultLocale: "en" },
|
|
232
|
-
}; }
|
|
233
|
-
var _c = _a.nx, nx = _c === void 0 ? true : _c, _d = _a.svg, svg = _d === void 0 ? true : _d, _e = _a.sc, sc = _e === void 0 ? true : _e, page = _a.page, routes = _a.routes, permanent = _a.permanent, debug = _a.debug, custom = tslib_1.__rest(_a, ["nx", "svg", "sc", "page", "routes", "permanent", "debug"]);
|
|
234
|
-
var nextConfig = tslib_1.__assign({
|
|
177
|
+
function withKoine({ nx = true, svg = true, sc = true, page, routes, permanent, debug, ...custom } = {
|
|
178
|
+
i18n: {
|
|
179
|
+
locales: [
|
|
180
|
+
"en"
|
|
181
|
+
],
|
|
182
|
+
defaultLocale: "en"
|
|
183
|
+
}
|
|
184
|
+
}) {
|
|
185
|
+
const nextConfig = {
|
|
235
186
|
// @see https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions#including-non-page-files-in-the-pages-directory
|
|
236
|
-
pageExtensions: page ? [
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
187
|
+
pageExtensions: page ? [
|
|
188
|
+
"page.tsx",
|
|
189
|
+
"page.ts"
|
|
190
|
+
] : undefined,
|
|
191
|
+
eslint: {
|
|
192
|
+
ignoreDuringBuilds: true
|
|
193
|
+
},
|
|
194
|
+
typescript: {
|
|
195
|
+
ignoreBuildErrors: true
|
|
196
|
+
},
|
|
197
|
+
poweredByHeader: false,
|
|
198
|
+
swcMinify: true,
|
|
199
|
+
modularizeImports: {
|
|
200
|
+
"@koine/api": {
|
|
201
|
+
transform: "@koine/api/{{member}}"
|
|
202
|
+
},
|
|
203
|
+
"@koine/browser": {
|
|
204
|
+
transform: "@koine/browser/{{member}}"
|
|
205
|
+
},
|
|
206
|
+
"@koine/dom": {
|
|
207
|
+
transform: "@koine/dom/{{member}}"
|
|
208
|
+
},
|
|
209
|
+
"@koine/next/?(((\\w*)?/?)*)": {
|
|
210
|
+
transform: "@koine/next/{{ matches.[1] }}/{{member}}"
|
|
211
|
+
},
|
|
212
|
+
"@koine/react/?(((\\w*)?/?)*)": {
|
|
213
|
+
transform: "@koine/react/{{ matches.[1] }}/{{member}}"
|
|
214
|
+
},
|
|
215
|
+
"@koine/utils": {
|
|
216
|
+
transform: "@koine/utils/{{member}}"
|
|
217
|
+
},
|
|
218
|
+
...custom["modularizeImports"] || {}
|
|
219
|
+
},
|
|
220
|
+
experimental: {
|
|
245
221
|
// @see https://github.com/vercel/vercel/discussions/5973#discussioncomment-472618
|
|
246
222
|
// @see critters error https://github.com/vercel/next.js/issues/20742
|
|
247
223
|
// optimizeCss: true,
|
|
248
224
|
// @see https://github.com/vercel/next.js/discussions/30174#discussion-3643870
|
|
249
|
-
scrollRestoration: true
|
|
225
|
+
scrollRestoration: true,
|
|
226
|
+
// concurrentFeatures: true,
|
|
227
|
+
// serverComponents: true,
|
|
228
|
+
// reactRoot: true,
|
|
229
|
+
...custom["experimental"] || {}
|
|
230
|
+
},
|
|
231
|
+
// @see https://github.com/vercel/next.js/issues/7322#issuecomment-887330111
|
|
232
|
+
// reactStrictMode: true,
|
|
233
|
+
...custom
|
|
234
|
+
};
|
|
250
235
|
if (svg) {
|
|
251
236
|
if (nx) {
|
|
252
237
|
// @see https://github.com/gregberge/svgr
|
|
253
238
|
nextConfig["nx"] = {
|
|
254
|
-
svgr: true
|
|
239
|
+
svgr: true
|
|
255
240
|
};
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
var webpackConfig = typeof nextConfig.webpack === "function"
|
|
260
|
-
? nextConfig.webpack(_config, options)
|
|
261
|
-
: _config;
|
|
241
|
+
} else {
|
|
242
|
+
nextConfig.webpack = (_config, options)=>{
|
|
243
|
+
const webpackConfig = typeof nextConfig.webpack === "function" ? nextConfig.webpack(_config, options) : _config;
|
|
262
244
|
// @see https://dev.to/dolearning/importing-svgs-to-next-js-nna#svgr
|
|
263
245
|
webpackConfig.module.rules.push({
|
|
264
246
|
test: /\.svg$/,
|
|
@@ -270,13 +252,13 @@ function withKoine(_a) {
|
|
|
270
252
|
plugins: [
|
|
271
253
|
{
|
|
272
254
|
name: "removeViewBox",
|
|
273
|
-
active: false
|
|
274
|
-
}
|
|
275
|
-
]
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
]
|
|
255
|
+
active: false
|
|
256
|
+
}
|
|
257
|
+
]
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
]
|
|
280
262
|
});
|
|
281
263
|
return webpackConfig;
|
|
282
264
|
};
|
|
@@ -284,60 +266,52 @@ function withKoine(_a) {
|
|
|
284
266
|
}
|
|
285
267
|
if (sc) {
|
|
286
268
|
nextConfig.compiler = {
|
|
287
|
-
styledComponents: true
|
|
269
|
+
styledComponents: true
|
|
288
270
|
};
|
|
289
271
|
}
|
|
290
272
|
if (routes) {
|
|
291
273
|
// we pass the default values, so we can assert I guess
|
|
292
|
-
|
|
293
|
-
return
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
beforeFiles: defaults,
|
|
333
|
-
fallback: [],
|
|
334
|
-
}];
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
} });
|
|
274
|
+
const defaultLocale = nextConfig?.i18n?.defaultLocale;
|
|
275
|
+
return {
|
|
276
|
+
...nextConfig,
|
|
277
|
+
async redirects () {
|
|
278
|
+
const defaults = await getRedirects(defaultLocale, routes, permanent, debug);
|
|
279
|
+
if (nextConfig.redirects) {
|
|
280
|
+
const customs = await nextConfig.redirects();
|
|
281
|
+
return [
|
|
282
|
+
...defaults,
|
|
283
|
+
...customs
|
|
284
|
+
];
|
|
285
|
+
}
|
|
286
|
+
return defaults;
|
|
287
|
+
},
|
|
288
|
+
async rewrites () {
|
|
289
|
+
const defaults = await getRewrites(routes, debug);
|
|
290
|
+
if (nextConfig.rewrites) {
|
|
291
|
+
const customs = await nextConfig.rewrites();
|
|
292
|
+
if (Array.isArray(customs)) {
|
|
293
|
+
return {
|
|
294
|
+
beforeFiles: defaults,
|
|
295
|
+
afterFiles: customs,
|
|
296
|
+
fallback: []
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
return {
|
|
300
|
+
...customs,
|
|
301
|
+
beforeFiles: [
|
|
302
|
+
...defaults,
|
|
303
|
+
...customs.beforeFiles || []
|
|
304
|
+
]
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
afterFiles: [],
|
|
309
|
+
beforeFiles: defaults,
|
|
310
|
+
fallback: []
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
};
|
|
339
314
|
}
|
|
340
315
|
return nextConfig;
|
|
341
316
|
}
|
|
342
|
-
|
|
343
|
-
exports.default = withKoine;
|
|
317
|
+
const _default = withKoine;
|