Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow some more options for Turbopack #48401

Merged
merged 2 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/next/src/cli/next-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ const nextDev: CliCommand = async (argv) => {
const rawNextConfig = await validateTurboNextConfig({
isCustomTurbopack,
...devServerOptions,
isDev: true,
})

const distDir = path.join(dir, rawNextConfig.distDir || '.next')
Expand Down
27 changes: 26 additions & 1 deletion packages/next/src/lib/turbopack-warning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,37 @@ const supportedTurbopackNextConfigOptions = [
'reactStrictMode',
'swcMinify',
'transpilePackages',
'experimental.swcFileReading',
'experimental.forceSwcTransforms',
]

// The following will need to be supported by `next build --turbo`
const prodSpecificTurboNextConfigOptions = [
'eslint.ignoreDuringBuilds',
'typescript.ignoreDuringBuilds',
'staticPageGenerationTimeout',
'outputFileTracing',
'output',
'generateBuildId',
'analyticsId',
'compress',
'productionBrowserSourceMaps',
'optimizeFonts',
'poweredByHeader',
]

// check for babelrc, swc plugins
export async function validateTurboNextConfig({
dir,
isCustomTurbopack,
isDev,
}: {
allowRetry?: boolean
isCustomTurbopack?: boolean
dir: string
port: number
hostname?: string
isDev?: boolean
}) {
const { getPkgManager } =
require('../lib/helpers/get-pkg-manager') as typeof import('../lib/helpers/get-pkg-manager')
Expand Down Expand Up @@ -74,6 +93,12 @@ export async function validateTurboNextConfig({
})
}

let supported = isDev
? supportedTurbopackNextConfigOptions
: [
...supportedTurbopackNextConfigOptions,
...prodSpecificTurboNextConfigOptions,
]
const checkUnsupportedCustomConfig = (
configKey = '',
parentUserConfig: any,
Expand All @@ -83,7 +108,7 @@ export async function validateTurboNextConfig({
// these should not error
if (
// we only want the key after the dot for experimental options
supportedTurbopackNextConfigOptions
supported
.map((key) => key.split('.').splice(-1)[0])
.includes(configKey)
) {
Expand Down