Unverified Commit aeafed94 authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

Turbopack: Fail when module type is unhandled (#63535)

This causes Turbopack to fail and communicate when a file with an
unhandled or unregistered extension is built.

Test Plan: `TURBOPACK=1 pnpm test-dev
test/development/basic/hmr.test.ts`


Closes PACK-2803
parent 8ab62613
This diff is collapsed.
...@@ -37,11 +37,11 @@ swc_core = { version = "0.90.22", features = [ ...@@ -37,11 +37,11 @@ swc_core = { version = "0.90.22", features = [
testing = { version = "0.35.20" } testing = { version = "0.35.20" }
# Turbo crates # Turbo crates
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240319.2" } turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240320.2" }
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros.. # [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros..
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240319.2" } turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240320.2" }
# [TODO]: need to refactor embed_directory! macro usage in next-core # [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240319.2" } turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240320.2" }
# General Deps # General Deps
......
...@@ -51,7 +51,10 @@ export function isWellKnownError(issue: Issue): boolean { ...@@ -51,7 +51,10 @@ export function isWellKnownError(issue: Issue): boolean {
const { title } = issue const { title } = issue
const formattedTitle = renderStyledStringToErrorAnsi(title) const formattedTitle = renderStyledStringToErrorAnsi(title)
// TODO: add more well known errors // TODO: add more well known errors
if (formattedTitle.includes('Module not found')) { if (
formattedTitle.includes('Module not found') ||
formattedTitle.includes('Unknown module type')
) {
return true return true
} }
......
...@@ -877,7 +877,17 @@ describe.each([[''], ['/docs']])( ...@@ -877,7 +877,17 @@ describe.each([[''], ['/docs']])(
expect(await hasRedbox(browser)).toBe(true) expect(await hasRedbox(browser)).toBe(true)
expect(await getRedboxHeader(browser)).toMatch('Failed to compile') expect(await getRedboxHeader(browser)).toMatch('Failed to compile')
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
if (process.env.TURBOPACK) {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"./components/parse-error.xyz
Unknown module type
This module doesn't have an associated type. Use a known file extension, or register a loader for it.
Read more: https://nextjs.org/docs/app/api-reference/next-config-js/turbo#webpack-loaders"
`)
} else {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"./components/parse-error.xyz "./components/parse-error.xyz
Module parse failed: Unexpected token (3:0) Module parse failed: Unexpected token (3:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
...@@ -891,7 +901,7 @@ describe.each([[''], ['/docs']])( ...@@ -891,7 +901,7 @@ describe.each([[''], ['/docs']])(
./components/parse-error.xyz ./components/parse-error.xyz
./pages/hmr/about8.js" ./pages/hmr/about8.js"
`) `)
}
await next.patchFile(aboutPage, aboutContent) await next.patchFile(aboutPage, aboutContent)
await check( await check(
......
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