Skip to content

Commit e8b2387

Browse files
authored
Update config validation for latest turbopack changes (vercel#44223)
* remove postcss and tailwind warnings * update list of supported config options
1 parent 7c8d006 commit e8b2387

File tree

1 file changed

+13
-61
lines changed

1 file changed

+13
-61
lines changed

packages/next/cli/next-dev.ts

Lines changed: 13 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,8 @@ const nextDev: cliCommand = async (argv) => {
161161
port,
162162
}
163163

164-
// check for postcss, babelrc, swc plugins
164+
// check for babelrc, swc plugins
165165
async function validateNextConfig(isCustomTurbopack: boolean) {
166-
const { findConfigPath } =
167-
require('../lib/find-config') as typeof import('../lib/find-config')
168166
const { getPkgManager } =
169167
require('../lib/helpers/get-pkg-manager') as typeof import('../lib/helpers/get-pkg-manager')
170168
const { getBabelConfigFile } =
@@ -175,8 +173,6 @@ const nextDev: cliCommand = async (argv) => {
175173
require('next/dist/compiled/chalk') as typeof import('next/dist/compiled/chalk')
176174
const { interopDefault } =
177175
require('../lib/interop-default') as typeof import('../lib/interop-default')
178-
const findUp =
179-
require('next/dist/compiled/find-up') as typeof import('next/dist/compiled/find-up')
180176

181177
// To regenerate the TURBOPACK gradient require('gradient-string')('blue', 'red')('>>> TURBOPACK')
182178
const isTTY = process.stdout.isTTY
@@ -190,13 +186,10 @@ const nextDev: cliCommand = async (argv) => {
190186
let thankYouMsg = `Thank you for trying Next.js v13 with Turbopack! As a reminder,\nTurbopack is currently in alpha and not yet ready for production.\nWe appreciate your ongoing support as we work to make it ready\nfor everyone.\n`
191187

192188
let unsupportedParts = ''
193-
// TODO: warning for postcss mentioning sidecar
194189
let babelrc = await getBabelConfigFile(dir)
195190
if (babelrc) babelrc = path.basename(babelrc)
196191

197192
let hasNonDefaultConfig
198-
let postcssFile
199-
let tailwindFile
200193
let rawNextConfig: NextConfig = {}
201194

202195
try {
@@ -220,7 +213,7 @@ const nextDev: cliCommand = async (argv) => {
220213
if (
221214
configKey === 'serverComponentsExternalPackages' ||
222215
configKey === 'appDir' ||
223-
configKey === 'transpilePackages' ||
216+
configKey === 'images' ||
224217
configKey === 'reactStrictMode' ||
225218
configKey === 'swcMinify' ||
226219
configKey === 'configFileName'
@@ -248,29 +241,11 @@ const nextDev: cliCommand = async (argv) => {
248241
hasNonDefaultConfig = Object.keys(rawNextConfig).some((key) =>
249242
checkUnsupportedCustomConfig(key, rawNextConfig, defaultConfig)
250243
)
251-
252-
const packagePath = findUp.sync('package.json', { cwd: dir })
253-
let hasSideCar = false
254-
255-
if (packagePath) {
256-
const pkgData = require(packagePath)
257-
hasSideCar = Object.values(
258-
(pkgData.scripts || {}) as Record<string, string>
259-
).some(
260-
(script) => script.includes('tailwind') || script.includes('postcss')
261-
)
262-
}
263-
postcssFile = !hasSideCar && (await findConfigPath(dir, 'postcss'))
264-
tailwindFile = !hasSideCar && (await findConfigPath(dir, 'tailwind'))
265-
266-
if (postcssFile) postcssFile = path.basename(postcssFile)
267-
if (tailwindFile) tailwindFile = path.basename(tailwindFile)
268244
} catch (e) {
269245
console.error('Unexpected error occurred while checking config', e)
270246
}
271247

272-
const hasWarningOrError =
273-
tailwindFile || postcssFile || babelrc || hasNonDefaultConfig
248+
const hasWarningOrError = babelrc || hasNonDefaultConfig
274249
if (!hasWarningOrError) {
275250
thankYouMsg = chalk.dim(thankYouMsg)
276251
}
@@ -297,40 +272,19 @@ const nextDev: cliCommand = async (argv) => {
297272
unsupportedParts += `\n\n- Unsupported Next.js configuration option(s) (${chalk.cyan(
298273
'next.config.js'
299274
)})\n ${chalk.dim(
300-
`The only configurations options supported are:\n - ${chalk.cyan(
301-
'experimental.serverComponentsExternalPackages'
302-
)}\n - ${chalk.cyan(
303-
'transpilePackages'
304-
)}\n To use Turbopack, remove other configuration options.`
275+
`The only configurations options supported are:\n${[
276+
'reactStrictMode',
277+
'experimental.appDir',
278+
'experimental.serverComponentsExternalPackages',
279+
'images',
280+
'swcMinify',
281+
'configFileName',
282+
]
283+
.map((name) => ` - ${chalk.cyan(name)}\n`)
284+
.join('')} To use Turbopack, remove other configuration options.`
305285
)} `
306286
}
307287

308-
if (postcssFile || tailwindFile) {
309-
console.warn(
310-
`${chalk.bold.yellow(
311-
'Warning:'
312-
)} You are using configuration that may require additional\nsetup with Turbopack. If you already made these changes please\nignore this warning.\n`
313-
)
314-
}
315-
316-
if (postcssFile) {
317-
console.warn(
318-
`- PostCSS detected (${chalk.cyan(postcssFile)})\n` +
319-
` ${chalk.dim(
320-
'PostCSS is not yet supported by Next.js v13 with Turbopack.\n To use with Turbopack, see: https://nextjs.link/turbopack-postcss'
321-
)}\n`
322-
)
323-
}
324-
325-
if (tailwindFile) {
326-
console.warn(
327-
`- Tailwind detected (${chalk.cyan(tailwindFile)})\n` +
328-
` ${chalk.dim(
329-
'Tailwind is not yet supported by Next.js v13 with Turbopack.\n To use with Turbopack, see: https://nextjs.link/turbopack-tailwind'
330-
)}\n`
331-
)
332-
}
333-
334288
if (unsupportedParts) {
335289
const pkgManager = getPkgManager(dir)
336290

@@ -425,8 +379,6 @@ If you cannot make the changes above, but still want to try out\nNext.js v13 wit
425379
: packagePath
426380
? path.dirname(packagePath)
427381
: undefined),
428-
serverComponentsExternalPackages:
429-
rawNextConfig.experimental?.serverComponentsExternalPackages,
430382
})
431383
// Start preflight after server is listening and ignore errors:
432384
preflight().catch(() => {})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy