Skip to content

Turbopack: don’t warn about webpack being configured when experimental.turbo is set #77998

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

Merged
merged 1 commit into from
Apr 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/next/src/lib/turbopack-warning.ts
Original file line number Diff line number Diff line change
@@ -144,7 +144,7 @@ export async function validateTurboNextConfig({
if (key.startsWith('webpack') && rawNextConfig.webpack) {
hasWebpackConfig = true
}
if (key.startsWith('turbopack')) {
if (key.startsWith('turbopack') || key.startsWith('experimental.turbo')) {
hasTurboConfig = true
}

@@ -180,7 +180,7 @@ export async function validateTurboNextConfig({
`Webpack is configured while Turbopack is not, which may cause problems.`
)
Log.warn(
`See instructions if you need to configure Turbopack:\n https://nextjs.org/docs/app/api-reference/next-config-js/turbo\n`
`See instructions if you need to configure Turbopack:\n https://nextjs.org/docs/app/api-reference/next-config-js/turbopack\n`
)
}

96 changes: 96 additions & 0 deletions test/e2e/config-turbopack/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* eslint-disable jest/no-standalone-expect */
import { nextTestSetup } from 'e2e-utils'

const WARNING_MESSAGE = 'Webpack is configured while Turbopack is not'

const itif = (condition: boolean) => (condition ? it : it.skip)

describe('config-turbopack', () => {
describe('when webpack is configured but Turbopack is not', () => {
const { next, isTurbopack } = nextTestSetup({
files: {
'app/page.js': `
export default function Page() {
return <p>hello world</p>
}
`,
'next.config.js': `
module.exports = {
webpack: (config) => {
return config
},
}
`,
},
})

itif(isTurbopack)('warns', async () => {
if (next) await next.render('/')
expect(next.cliOutput).toContain(WARNING_MESSAGE)
})
})

describe('when webpack is configured and config.turbopack is set', () => {
const { next, isTurbopack } = nextTestSetup({
files: {
'app/page.js': `
export default function Page() {
return <p>hello world</p>
}
`,
'next.config.js': `
module.exports = {
turbopack: {
rules: {
'*.foo': {
loaders: ['foo-loader']
}
}
},
webpack: (config) => {
return config
},
}
`,
},
})

itif(isTurbopack)('does not warn', async () => {
if (next) await next.render('/')
expect(next.cliOutput).not.toContain(WARNING_MESSAGE)
})
})

describe('when webpack is configured and config.experimental.turbo is set', () => {
const { next, isTurbopack } = nextTestSetup({
files: {
'app/page.js': `
export default function Page() {
return <p>hello world</p>
}
`,
'next.config.js': `
module.exports = {
experimental: {
turbo: {
rules: {
'*.foo': {
loaders: ['foo-loader']
}
}
}
},
webpack: (config) => {
return config
},
}
`,
},
})

itif(isTurbopack)('does not warn', async () => {
if (next) await next.render('/')
expect(next.cliOutput).not.toContain(WARNING_MESSAGE)
})
})
})

Unchanged files with check annotations Beta

format!("{:?}", err).into()
}
#[wasm_bindgen(js_name = "minifySync")]

Check warning on line 27 in crates/wasm/src/lib.rs

GitHub Actions / build-wasm (nodejs)

this function definition involves an argument of type `()` which is affected by the wasm ABI transition

Check warning on line 27 in crates/wasm/src/lib.rs

GitHub Actions / build-wasm (web)

this function definition involves an argument of type `()` which is affected by the wasm ABI transition
pub fn minify_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
console_error_panic_hook::set_once();
Ok(serde_wasm_bindgen::to_value(&value)?)
}
#[wasm_bindgen(js_name = "minify")]

Check warning on line 58 in crates/wasm/src/lib.rs

GitHub Actions / build-wasm (nodejs)

this function definition involves an argument of type `()` which is affected by the wasm ABI transition

Check warning on line 58 in crates/wasm/src/lib.rs

GitHub Actions / build-wasm (web)

this function definition involves an argument of type `()` which is affected by the wasm ABI transition
pub fn minify(s: JsString, opts: JsValue) -> js_sys::Promise {
// TODO: This'll be properly scheduled once wasm have standard backed thread
// support.
future_to_promise(async { minify_sync(s, opts) })
}
#[wasm_bindgen(js_name = "transformSync")]

Check warning on line 65 in crates/wasm/src/lib.rs

GitHub Actions / build-wasm (nodejs)

this function definition involves an argument of type `()` which is affected by the wasm ABI transition

Check warning on line 65 in crates/wasm/src/lib.rs

GitHub Actions / build-wasm (web)

this function definition involves an argument of type `()` which is affected by the wasm ABI transition
pub fn transform_sync(s: JsValue, opts: JsValue) -> Result<JsValue, JsValue> {
console_error_panic_hook::set_once();
Ok(serde_wasm_bindgen::to_value(&out)?)
}
#[wasm_bindgen(js_name = "transform")]

Check warning on line 135 in crates/wasm/src/lib.rs

GitHub Actions / build-wasm (nodejs)

this function definition involves an argument of type `()` which is affected by the wasm ABI transition

Check warning on line 135 in crates/wasm/src/lib.rs

GitHub Actions / build-wasm (web)

this function definition involves an argument of type `()` which is affected by the wasm ABI transition
pub fn transform(s: JsValue, opts: JsValue) -> js_sys::Promise {
// TODO: This'll be properly scheduled once wasm have standard backed thread
// support.
future_to_promise(async { transform_sync(s, opts) })
}
#[wasm_bindgen(js_name = "parseSync")]

Check warning on line 142 in crates/wasm/src/lib.rs

GitHub Actions / build-wasm (nodejs)

this function definition involves an argument of type `()` which is affected by the wasm ABI transition

Check warning on line 142 in crates/wasm/src/lib.rs

GitHub Actions / build-wasm (web)

this function definition involves an argument of type `()` which is affected by the wasm ABI transition
pub fn parse_sync(s: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
console_error_panic_hook::set_once();
.map_err(convert_err)
}
#[wasm_bindgen(js_name = "parse")]

Check warning on line 187 in crates/wasm/src/lib.rs

GitHub Actions / build-wasm (nodejs)

this function definition involves an argument of type `()` which is affected by the wasm ABI transition

Check warning on line 187 in crates/wasm/src/lib.rs

GitHub Actions / build-wasm (web)

this function definition involves an argument of type `()` which is affected by the wasm ABI transition
pub fn parse(s: JsString, opts: JsValue) -> js_sys::Promise {
// TODO: This'll be properly scheduled once wasm have standard backed thread
// support.
use wasm_bindgen::prelude::*;
use wasm_bindgen_futures::future_to_promise;
#[wasm_bindgen(js_name = "mdxCompileSync")]

Check warning on line 6 in crates/wasm/src/mdx.rs

GitHub Actions / build-wasm (nodejs)

this function definition involves an argument of type `()` which is affected by the wasm ABI transition

Check warning on line 6 in crates/wasm/src/mdx.rs

GitHub Actions / build-wasm (web)

this function definition involves an argument of type `()` which is affected by the wasm ABI transition
pub fn mdx_compile_sync(value: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
let value: String = value.into();
let option: Options = serde_wasm_bindgen::from_value(opts)?;
})
}
#[wasm_bindgen(js_name = "mdxCompile")]

Check warning on line 18 in crates/wasm/src/mdx.rs

GitHub Actions / build-wasm (nodejs)

this function definition involves an argument of type `()` which is affected by the wasm ABI transition

Check warning on line 18 in crates/wasm/src/mdx.rs

GitHub Actions / build-wasm (web)

this function definition involves an argument of type `()` which is affected by the wasm ABI transition
pub fn mdx_compile(value: JsString, opts: JsValue) -> js_sys::Promise {
// TODO: This'll be properly scheduled once wasm have standard backed thread
// support.