-
Notifications
You must be signed in to change notification settings - Fork 29.5k
Closed
Milestone
Description
Bug report
I updated nextjs from 9.3.6
to 9.4.0
.
Describe the bug
After updating I do not get typescript errors anymore checked during buildtime. This was working in 9.3.6
.
To Reproduce
As I have quite a complex mono repository, I'm unable to provide the source of that.
Major differences to a stock configuration is a custom babel configuration:
module.exports = {
presets: [],
plugins: [
'lodash',
'@babel/proposal-class-properties',
'react-intl-auto',
'babel-plugin-graphql-tag'
],
env: {
test: {
presets: [
'@babel/typescript',
[ '@babel/preset-env',
{
targets: {
node: process.versions.node
}
}
],
'@babel/preset-react'
]
},
nodeTs: {
presets: [
'@babel/typescript',
'@babel/preset-react',
[
'@babel/preset-env',
{
targets: {
node: process.versions.node
}
}
]
]
},
nextjs: {
presets: ['next/babel']
}
}
}
And a custom next.config.ts:
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path')
const withDevTool = (nextConfig: any = {}) => {
return {
...nextConfig,
webpack(config: any, options: any) {
const { dev } = options
if (dev) {
config.devtool = 'eval-source-map'
}
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
}
return config
},
}
}
export default () => {
const optimizedImages = require('next-optimized-images')
const withTM = require('next-transpile-modules')([
'query-string',
'imask/esm',
/** ..some more private modules */
])
const withCustomBabelConfigFile = require('next-plugin-custom-babel-config')
const withCSS = require('@zeit/next-css')
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
return withDevTool(
withBundleAnalyzer(
optimizedImages(
withCustomBabelConfigFile(
withCSS(
withTM({
babelConfigFile: path.resolve(
path.join(__dirname, '../../../../babel.config.js')
),
distDir: 'dist',
})
)
)
)
)
)
}
I'm using a custom server with additional express middleware.
// This file doesn't go through babel or webpack transformation.
// Make sure the syntax and sources this file requires are compatible with the current node version you are running
// See https://github.com/zeit/next.js/issues/1245 for discussions on Universal Webpack or universal Babel
import 'dotenv/config'
import express from 'express'
import next from 'next'
import { defaultMiddleware } from '../index'
import { appConfig } from './appConfig'
const applicationFactory = (): void => {
const dev = process.env.NODE_ENV !== 'production'
const conf = dev
? // eslint-disable-next-line @typescript-eslint/no-var-requires
require('./next.config').default()
: {
distDir: 'dist',
}
const app = next({
dev,
conf,
})
const handle = app.getRequestHandler()
app.prepare().then(() => {
const server = express()
const proxyInstance = defaultMiddleware(server, appConfig)
server.get('*', (req, res) => {
return handle(req, res)
})
const port = process.env.PORT || 3000
// @ts-ignore
const listener = server.listen(port, (err: Error) => {
if (err) {
throw err
}
// tslint:disable-next-line:no-console
console.log(`> Ready on http://localhost:${port}`)
})
listener.on('upgrade', (req: any, socket: any, ...rest: any) => {
socket.on('error', (error: any) => {
console.error(error)
})
proxyInstance.upgrade(req, socket, ...rest)
})
})
}
export default applicationFactory
Expected behavior
Typescript errors should be reported.
System information
- OS: Windows
- Version of Next.js: 9.4.0
- Version of Node.js: 12.13.1
bengrunfeld and zenVentzi
Metadata
Metadata
Assignees
Labels
No labels