Unverified Commit bc5164fe authored by Maia Teegarden's avatar Maia Teegarden Committed by GitHub

Allow webpack config, but warn if no turbo config (#49170)

Allows webpack config so Turbopack can be used for dev and webpack can
be used for production. Also warns if there is no corresponding
Turbopack config (only a warning since webpack config could be prod
specific)

Closes WEB-984

<img width="647" alt="Screenshot 2023-05-03 at 12 32 08 PM"
src="https://user-images.githubusercontent.com/2865858/236027314-4c762b4d-ebe4-486a-bd64-5215dcf60db6.png">
parent 92405d24
...@@ -25,6 +25,7 @@ const supportedTurbopackNextConfigOptions = [ ...@@ -25,6 +25,7 @@ const supportedTurbopackNextConfigOptions = [
'experimental.swcFileReading', 'experimental.swcFileReading',
'experimental.forceSwcTransforms', 'experimental.forceSwcTransforms',
// options below are not really supported, but ignored // options below are not really supported, but ignored
'webpack',
'devIndicators', 'devIndicators',
'onDemandEntries', 'onDemandEntries',
'experimental.cpus', 'experimental.cpus',
...@@ -98,6 +99,9 @@ export async function validateTurboNextConfig({ ...@@ -98,6 +99,9 @@ export async function validateTurboNextConfig({
let babelrc = await getBabelConfigFile(dir) let babelrc = await getBabelConfigFile(dir)
if (babelrc) babelrc = path.basename(babelrc) if (babelrc) babelrc = path.basename(babelrc)
let hasWebpack = false
let hasTurbo = false
let unsupportedConfig: string[] = [] let unsupportedConfig: string[] = []
let rawNextConfig: NextConfig = {} let rawNextConfig: NextConfig = {}
...@@ -156,6 +160,13 @@ export async function validateTurboNextConfig({ ...@@ -156,6 +160,13 @@ export async function validateTurboNextConfig({
: supportedTurbopackNextConfigOptions : supportedTurbopackNextConfigOptions
for (const key of customKeys) { for (const key of customKeys) {
if (key.startsWith('webpack')) {
hasWebpack = true
}
if (key.startsWith('experimental.turbo')) {
hasTurbo = true
}
let isSupported = let isSupported =
supportedKeys.some((supportedKey) => key.startsWith(supportedKey)) || supportedKeys.some((supportedKey) => key.startsWith(supportedKey)) ||
getDeepValue(rawNextConfig, key) === getDeepValue(defaultConfig, key) getDeepValue(rawNextConfig, key) === getDeepValue(defaultConfig, key)
...@@ -185,6 +196,17 @@ export async function validateTurboNextConfig({ ...@@ -185,6 +196,17 @@ export async function validateTurboNextConfig({
feedbackMessage = chalk.dim(feedbackMessage) feedbackMessage = chalk.dim(feedbackMessage)
} }
if (hasWebpack && !hasTurbo) {
console.warn(
`\n${chalk.yellow(
'Warning:'
)} Webpack is configured while Turbopack is not, which may cause problems.\n
${chalk.dim(
`See instructions if you need to configure Turbopack:\n https://turbo.build/pack/docs/features/customizing-turbopack\n`
)}`
)
}
if (babelrc) { if (babelrc) {
unsupportedParts += `\n- Babel detected (${chalk.cyan( unsupportedParts += `\n- Babel detected (${chalk.cyan(
babelrc babelrc
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment