-
Notifications
You must be signed in to change notification settings - Fork 3
/
next.config.js
48 lines (40 loc) · 1.16 KB
/
next.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const path = require('path');
const TRANS_VIRTUAL_MODULE_NAME = 'virtual-lingui-trans';
class LinguiTransRscResolver {
apply(resolver) {
const target = resolver.ensureHook('resolve');
resolver
.getHook('resolve')
.tapAsync('LinguiTransRscResolver', (request, resolveContext, callback) => {
if (request.request === TRANS_VIRTUAL_MODULE_NAME) {
const req = {
...request,
request: request.context.issuerLayer === 'rsc'
// RSC Version without Context
? path.resolve('./src/i18n/rsc-trans.tsx')
// Regular version
: '@lingui/react',
};
return resolver.doResolve(target, req, null, resolveContext, callback);
}
callback();
});
}
}
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
swcPlugins: [
['@lingui/swc-plugin', {
'runtimeModules': {
'trans': [TRANS_VIRTUAL_MODULE_NAME, 'Trans'],
},
}],
],
},
webpack: (config) => {
config.resolve.plugins.push(new LinguiTransRscResolver());
return config;
},
}
module.exports = nextConfig