Skip to content

Commit

Permalink
feat(next-dev): reenable turbopack beta message (#55116)
Browse files Browse the repository at this point in the history
### 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
  • Loading branch information
kwonoj committed Sep 12, 2023
1 parent d3656cc commit 0bf5cbb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/next-swc/crates/next-core/src/next_config.rs
Expand Up @@ -84,6 +84,7 @@ pub struct NextConfig {
pub transpile_packages: Option<Vec<String>>,
pub modularize_imports: Option<IndexMap<String, ModularizeImportPackageConfig>>,
sass_options: Option<serde_json::Value>,
trailing_slash: bool,

// Partially supported
pub compiler: Option<CompilerConfig>,
Expand Down Expand Up @@ -119,7 +120,6 @@ pub struct NextConfig {
static_page_generation_timeout: f64,
swc_minify: Option<bool>,
target: Option<String>,
trailing_slash: bool,
typescript: TypeScriptConfig,
use_file_system_public_routes: bool,
webpack: Option<serde_json::Value>,
Expand Down Expand Up @@ -413,7 +413,7 @@ pub struct ExperimentalConfig {
pub swc_plugins: Option<Vec<(String, serde_json::Value)>>,

// unsupported
adjust_font_fallbacks: Option<bool>,
optimize_package_imports: Option<Vec<String>>,
adjust_font_fallbacks_with_size_adjust: Option<bool>,
allow_middleware_response_body: Option<bool>,
amp: Option<serde_json::Value>,
Expand Down
6 changes: 6 additions & 0 deletions packages/next/src/cli/next-dev.ts
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down
16 changes: 15 additions & 1 deletion packages/next/src/lib/turbopack-warning.ts
Expand Up @@ -6,6 +6,7 @@ import { PHASE_DEVELOPMENT_SERVER } from '../shared/lib/constants'
const supportedTurbopackNextConfigOptions = [
'configFileName',
'env',
'basePath',
'modularizeImports',
'compiler.emotion',
'compiler.relay',
Expand All @@ -19,6 +20,9 @@ const supportedTurbopackNextConfigOptions = [
'reactStrictMode',
'swcMinify',
'transpilePackages',
'trailingSlash',
'i18n.locales',
'i18n.defaultLocale',
'sassOptions.includePaths',
'experimental.serverComponentsExternalPackages',
'experimental.turbo',
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion test/turbopack-tests-manifest.js
Expand Up @@ -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',
Expand All @@ -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 }
Expand Down

0 comments on commit 0bf5cbb

Please sign in to comment.