From 0bf5cbb901020c8e4cccd26dc7e577865a667629 Mon Sep 17 00:00:00 2001 From: OJ Kwon <1210596+kwonoj@users.noreply.github.com> Date: Tue, 12 Sep 2023 09:39:26 -0700 Subject: [PATCH] feat(next-dev): reenable turbopack beta message (#55116) ### What? Minor PR brings back turbopack beta message. We'll need to improve the actual checks per progress, but that might need auditing what's working vs not later. Closes WEB-1517 --- .../next-swc/crates/next-core/src/next_config.rs | 4 ++-- packages/next/src/cli/next-dev.ts | 6 ++++++ packages/next/src/lib/turbopack-warning.ts | 16 +++++++++++++++- test/turbopack-tests-manifest.js | 4 +++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/packages/next-swc/crates/next-core/src/next_config.rs b/packages/next-swc/crates/next-core/src/next_config.rs index c4e90cca6908..b0521dc335a2 100644 --- a/packages/next-swc/crates/next-core/src/next_config.rs +++ b/packages/next-swc/crates/next-core/src/next_config.rs @@ -84,6 +84,7 @@ pub struct NextConfig { pub transpile_packages: Option>, pub modularize_imports: Option>, sass_options: Option, + trailing_slash: bool, // Partially supported pub compiler: Option, @@ -119,7 +120,6 @@ pub struct NextConfig { static_page_generation_timeout: f64, swc_minify: Option, target: Option, - trailing_slash: bool, typescript: TypeScriptConfig, use_file_system_public_routes: bool, webpack: Option, @@ -413,7 +413,7 @@ pub struct ExperimentalConfig { pub swc_plugins: Option>, // unsupported - adjust_font_fallbacks: Option, + optimize_package_imports: Option>, adjust_font_fallbacks_with_size_adjust: Option, allow_middleware_response_body: Option, amp: Option, diff --git a/packages/next/src/cli/next-dev.ts b/packages/next/src/cli/next-dev.ts index 83114a3556cd..5f192005950b 100644 --- a/packages/next/src/cli/next-dev.ts +++ b/packages/next/src/cli/next-dev.ts @@ -22,6 +22,7 @@ import { getReservedPortExplanation, isPortIsReserved, } from '../lib/helpers/get-reserved-port' +import { validateTurboNextConfig } from '../lib/turbopack-warning' let dir: string let config: NextConfigComplete @@ -227,6 +228,11 @@ const nextDev: CliCommand = async (args) => { if (args['--turbo']) { process.env.TURBOPACK = '1' + await validateTurboNextConfig({ + isCustomTurbopack: !!process.env.__INTERNAL_CUSTOM_TURBOPACK_BINDINGS, + ...devServerOptions, + isDev: true, + }) } const distDir = path.join(dir, config.distDir ?? '.next') diff --git a/packages/next/src/lib/turbopack-warning.ts b/packages/next/src/lib/turbopack-warning.ts index 51f6179b5e04..817707614716 100644 --- a/packages/next/src/lib/turbopack-warning.ts +++ b/packages/next/src/lib/turbopack-warning.ts @@ -6,6 +6,7 @@ import { PHASE_DEVELOPMENT_SERVER } from '../shared/lib/constants' const supportedTurbopackNextConfigOptions = [ 'configFileName', 'env', + 'basePath', 'modularizeImports', 'compiler.emotion', 'compiler.relay', @@ -19,6 +20,9 @@ const supportedTurbopackNextConfigOptions = [ 'reactStrictMode', 'swcMinify', 'transpilePackages', + 'trailingSlash', + 'i18n.locales', + 'i18n.defaultLocale', 'sassOptions.includePaths', 'experimental.serverComponentsExternalPackages', 'experimental.turbo', @@ -214,7 +218,17 @@ export async function validateTurboNextConfig({ babelrc )})\n ${`Babel is not yet supported. To use Turbopack at the moment,\n you'll need to remove your usage of Babel.`}` } - if (unsupportedConfig.length) { + + if ( + unsupportedConfig.length === 1 && + unsupportedConfig[0] === 'experimental.optimizePackageImports' + ) { + console.warn( + `\n${chalk.yellow('Warning:')} ${chalk.cyan( + 'experimental.optimizePackageImports' + )} is not yet supported by Turbopack and will be ignored.` + ) + } else if (unsupportedConfig.length) { unsupportedParts += `\n\n- Unsupported Next.js configuration option(s) (${chalk.cyan( 'next.config.js' )})\n ${`To use Turbopack, remove the following configuration options:\n${unsupportedConfig diff --git a/test/turbopack-tests-manifest.js b/test/turbopack-tests-manifest.js index ca0064641cf6..0dd738906d4d 100644 --- a/test/turbopack-tests-manifest.js +++ b/test/turbopack-tests-manifest.js @@ -131,7 +131,6 @@ const enabledTests = [ 'test/integration/ssg-dynamic-routes-404-page/test/index.test.js', 'test/integration/static-404/test/index.test.js', 'test/integration/static-page-name/test/index.test.js', - 'test/integration/trailing-slash-dist/test/index.test.js', 'test/integration/trailing-slashes-href-resolving/test/index.test.js', 'test/production/app-dir-hide-suppressed-error-during-next-export/index.test.ts', 'test/production/app-dir-prefetch-non-iso-url/index.test.ts', @@ -141,6 +140,9 @@ const enabledTests = [ 'test/production/jest/transpile-packages.test.ts', 'test/production/postcss-plugin-config-as-string/index.test.ts', 'test/production/suppo.ts', + + // disabled due to nextConfig.distDir + //'test/integration/trailing-slash-dist/test/index.test.js', ] module.exports = { enabledTests }