reactjs - nextjs で tsconfig を無視して ES6 を ES5 に強制的にトランスパイルする
Nextjsはコンパイル時にtsconfigのtargetオプションを無視します。ES6のクラスやアロー関数が関数にトランスパイルされます。
next build を実行すると、ターミナルに書き込まれます
info - Using tsconfig file: ./tsconfig.json
そしてパスエイリアスはエラーを引き起こさない。だから私のtsconfigは適用されている。でもNext.jsはすべてのアロー関数、クラスなどをトランスパイルする
// tsconfig.json
{
"compilerOptions": {
"target": "es2020",
"lib": [
"webworker",
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"baseUrl": ".",
"paths": {
"@/*": [
"./*"
],
"src/*": [
"src/*"
],
},
"incremental": true
},
"exclude": [
"node_modules"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
}
