fix(turbopack): add list of packages that should never be marked as e… (#59020)

### What?

Turbopack was missing the list of modules / requests that should never
be marked as external:

8d1c619ad6/packages/next/src/build/handle-externals.ts (L188)

This could lead to errors with i.e. `next/image` not receiving the
correct image config.

Closes PACK-2047

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Leah 2023-11-28 17:41:28 +01:00 committed by GitHub
parent f4c14935aa
commit 9c79186610
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -80,7 +80,15 @@ impl ResolvePlugin for ExternalCjsModulesResolvePlugin {
if *condition(self.root).matches(context).await? {
return Ok(ResolveResultOption::none());
}
if !matches!(&*request.await?, Request::Module { .. }) {
let request_value = &*request.await?;
if !matches!(request_value, Request::Module { .. }) {
return Ok(ResolveResultOption::none());
}
// from https://github.com/vercel/next.js/blob/8d1c619ad650f5d147207f267441caf12acd91d1/packages/next/src/build/handle-externals.ts#L188
let never_external_regex = lazy_regex::regex!("^(?:private-next-pages\\/|next\\/(?:dist\\/pages\\/|(?:app|document|link|image|legacy\\/image|constants|dynamic|script|navigation|headers|router)$)|string-hash|private-next-rsc-action-validate|private-next-rsc-action-client-wrapper|private-next-rsc-action-proxy$)");
if never_external_regex.is_match(&request_value.request().unwrap_or_default()) {
return Ok(ResolveResultOption::none());
}