Skip postcss config location resolving in node_modules (#60697)

## What?

Skip postcss config resolving in node_modules for Turbopack. This
matches current Next.js on webpack closer as that only resolves the
postcss config from the project root. The additional feature Turbopack
has is that it can find a postcss config relative to the css being
compiled. This is useful for e.g. reducing the amount of overhead
certain postcss plugins that only have to run against a single file take
(i.e. Tailwindcss).


Depends on github.com/vercel/turbo/pull/7012 landing first.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2109

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
This commit is contained in:
Tim Neutkens 2024-01-17 14:54:17 +01:00 committed by GitHub
parent c583528116
commit 4548fed1cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 105 additions and 66 deletions

70
Cargo.lock generated
View file

@ -321,7 +321,7 @@ dependencies = [
[[package]]
name = "auto-hash-map"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"serde",
"smallvec",
@ -3498,7 +3498,7 @@ dependencies = [
[[package]]
name = "node-file-trace"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"serde",
@ -7538,7 +7538,7 @@ dependencies = [
[[package]]
name = "turbo-tasks"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"async-trait",
@ -7570,7 +7570,7 @@ dependencies = [
[[package]]
name = "turbo-tasks-build"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"cargo-lock",
@ -7582,7 +7582,7 @@ dependencies = [
[[package]]
name = "turbo-tasks-bytes"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"bytes",
@ -7597,7 +7597,7 @@ dependencies = [
[[package]]
name = "turbo-tasks-env"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"dotenvs",
@ -7611,7 +7611,7 @@ dependencies = [
[[package]]
name = "turbo-tasks-fetch"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"indexmap 1.9.3",
@ -7628,7 +7628,7 @@ dependencies = [
[[package]]
name = "turbo-tasks-fs"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"auto-hash-map",
@ -7659,7 +7659,7 @@ dependencies = [
[[package]]
name = "turbo-tasks-hash"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"base16",
"hex",
@ -7671,7 +7671,7 @@ dependencies = [
[[package]]
name = "turbo-tasks-macros"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"convert_case 0.6.0",
@ -7685,7 +7685,7 @@ dependencies = [
[[package]]
name = "turbo-tasks-macros-shared"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"proc-macro2",
"quote",
@ -7695,7 +7695,7 @@ dependencies = [
[[package]]
name = "turbo-tasks-malloc"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"mimalloc",
]
@ -7703,7 +7703,7 @@ dependencies = [
[[package]]
name = "turbo-tasks-memory"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"auto-hash-map",
@ -7728,7 +7728,7 @@ dependencies = [
[[package]]
name = "turbopack"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"async-recursion",
@ -7760,7 +7760,7 @@ dependencies = [
[[package]]
name = "turbopack-binding"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"auto-hash-map",
"mdxjs",
@ -7801,7 +7801,7 @@ dependencies = [
[[package]]
name = "turbopack-build"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"indexmap 1.9.3",
@ -7825,7 +7825,7 @@ dependencies = [
[[package]]
name = "turbopack-cli-utils"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"clap 4.4.2",
@ -7843,7 +7843,7 @@ dependencies = [
[[package]]
name = "turbopack-core"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"async-recursion",
@ -7873,7 +7873,7 @@ dependencies = [
[[package]]
name = "turbopack-css"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"async-trait",
@ -7900,7 +7900,7 @@ dependencies = [
[[package]]
name = "turbopack-dev"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"indexmap 1.9.3",
@ -7924,7 +7924,7 @@ dependencies = [
[[package]]
name = "turbopack-dev-server"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"async-compression",
@ -7961,7 +7961,7 @@ dependencies = [
[[package]]
name = "turbopack-ecmascript"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"async-trait",
@ -7996,7 +7996,7 @@ dependencies = [
[[package]]
name = "turbopack-ecmascript-hmr-protocol"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"serde",
"serde_json",
@ -8007,7 +8007,7 @@ dependencies = [
[[package]]
name = "turbopack-ecmascript-plugins"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"async-trait",
@ -8030,7 +8030,7 @@ dependencies = [
[[package]]
name = "turbopack-ecmascript-runtime"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"indoc",
@ -8047,7 +8047,7 @@ dependencies = [
[[package]]
name = "turbopack-env"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"indexmap 1.9.3",
@ -8063,7 +8063,7 @@ dependencies = [
[[package]]
name = "turbopack-image"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"base64 0.21.4",
@ -8083,7 +8083,7 @@ dependencies = [
[[package]]
name = "turbopack-json"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"serde",
@ -8098,7 +8098,7 @@ dependencies = [
[[package]]
name = "turbopack-mdx"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"mdxjs",
@ -8113,7 +8113,7 @@ dependencies = [
[[package]]
name = "turbopack-node"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"async-stream",
@ -8148,7 +8148,7 @@ dependencies = [
[[package]]
name = "turbopack-static"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"serde",
@ -8164,7 +8164,7 @@ dependencies = [
[[package]]
name = "turbopack-swc-utils"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"swc_core",
"turbo-tasks",
@ -8175,7 +8175,7 @@ dependencies = [
[[package]]
name = "turbopack-trace-utils"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"crossbeam-channel",
@ -8191,7 +8191,7 @@ dependencies = [
[[package]]
name = "turbopack-wasm"
version = "0.1.0"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e"
source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.3#438bdd0b198163a37ff6050cf8ae2c7ca8b07753"
dependencies = [
"anyhow",
"indexmap 1.9.3",
@ -8213,7 +8213,7 @@ version = "1.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
dependencies = [
"cfg-if 0.1.10",
"cfg-if 1.0.0",
"rand",
"static_assertions",
]

View file

@ -37,11 +37,11 @@ swc_core = { version = "0.87.16", features = [
testing = { version = "0.35.14" }
# Turbo crates
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240117.1" }
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240117.3" }
# [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-240117.1" }
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240117.3" }
# [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240117.1" }
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240117.3" }
# General Deps

View file

@ -18,13 +18,16 @@ use turbopack_binding::{
},
dev::{react_refresh::assert_can_resolve_react_refresh, DevChunkingContext},
ecmascript::{chunk::EcmascriptChunkingContext, TreeShakingMode},
node::execution_context::ExecutionContext,
node::{
execution_context::ExecutionContext,
transforms::postcss::{PostCssConfigLocation, PostCssTransformOptions},
},
turbopack::{
condition::ContextCondition,
module_options::{
module_options_context::ModuleOptionsContext, CustomEcmascriptTransformPlugins,
JsxTransformOptions, MdxTransformModuleOptions, PostCssTransformOptions,
TypescriptTransformOptions, WebpackLoadersOptions,
JsxTransformOptions, MdxTransformModuleOptions, TypescriptTransformOptions,
WebpackLoadersOptions,
},
resolve_options_context::ResolveOptionsContext,
},
@ -258,23 +261,34 @@ pub async fn get_client_module_options_context(
},
));
let postcss_transform_options = Some(PostCssTransformOptions {
let postcss_transform_options = PostCssTransformOptions {
postcss_package: Some(get_postcss_package_mapping(project_path)),
config_location: PostCssConfigLocation::ProjectPathOrLocalPath,
..Default::default()
});
};
let postcss_foreign_transform_options = PostCssTransformOptions {
// For node_modules we don't want to resolve postcss config relative to the file being
// compiled, instead it only uses the project root postcss config.
config_location: PostCssConfigLocation::ProjectPath,
..postcss_transform_options.clone()
};
let enable_postcss_transform = Some(postcss_transform_options.cell());
let enable_foreign_postcss_transform = Some(postcss_foreign_transform_options.cell());
let module_options_context = ModuleOptionsContext {
preset_env_versions: Some(env),
execution_context: Some(execution_context),
custom_ecma_transform_plugins,
tree_shaking_mode: Some(TreeShakingMode::ReexportsOnly),
enable_postcss_transform,
..Default::default()
};
// node_modules context
let foreign_codes_options_context = ModuleOptionsContext {
enable_webpack_loaders: foreign_webpack_loaders,
enable_postcss_transform: enable_foreign_postcss_transform,
// NOTE(WEB-1016) PostCSS transforms should also apply to foreign code.
enable_postcss_transform: postcss_transform_options.clone(),
..module_options_context.clone()
};
@ -284,7 +298,6 @@ pub async fn get_client_module_options_context(
// the modules.
enable_jsx: Some(jsx_runtime_options),
enable_webpack_loaders,
enable_postcss_transform: postcss_transform_options,
enable_typescript_transform: Some(tsconfig),
enable_mdx_rs,
decorators: Some(decorators_options),

View file

@ -19,13 +19,15 @@ use turbopack_binding::{
},
ecmascript::{references::esm::UrlRewriteBehavior, TransformPlugin, TreeShakingMode},
ecmascript_plugin::transform::directives::client::ClientDirectiveTransformer,
node::execution_context::ExecutionContext,
node::{
execution_context::ExecutionContext,
transforms::postcss::{PostCssConfigLocation, PostCssTransformOptions},
},
turbopack::{
condition::ContextCondition,
module_options::{
CustomEcmascriptTransformPlugins, JsxTransformOptions, MdxTransformModuleOptions,
ModuleOptionsContext, PostCssTransformOptions, TypescriptTransformOptions,
WebpackLoadersOptions,
ModuleOptionsContext, TypescriptTransformOptions, WebpackLoadersOptions,
},
resolve_options_context::ResolveOptionsContext,
transition::Transition,
@ -280,10 +282,20 @@ pub async fn get_server_module_options_context(
let foreign_code_context_condition =
foreign_code_context_condition(next_config, project_path).await?;
let postcss_transform_options = Some(PostCssTransformOptions {
let postcss_transform_options = PostCssTransformOptions {
postcss_package: Some(get_postcss_package_mapping(project_path)),
config_location: PostCssConfigLocation::ProjectPathOrLocalPath,
..Default::default()
});
};
let postcss_foreign_transform_options = PostCssTransformOptions {
// For node_modules we don't want to resolve postcss config relative to the file
// being compiled, instead it only uses the project root postcss
// config.
config_location: PostCssConfigLocation::ProjectPath,
..postcss_transform_options.clone()
};
let enable_postcss_transform = Some(postcss_transform_options.cell());
let enable_foreign_postcss_transform = Some(postcss_foreign_transform_options.cell());
// A separate webpack rules will be applied to codes matching
// foreign_code_context_condition. This allows to import codes from
@ -400,7 +412,7 @@ pub async fn get_server_module_options_context(
custom_rules: internal_custom_rules.clone(),
enable_webpack_loaders: foreign_webpack_loaders,
// NOTE(WEB-1016) PostCSS transforms should also apply to foreign code.
enable_postcss_transform: postcss_transform_options.clone(),
enable_postcss_transform: enable_foreign_postcss_transform,
..module_options_context.clone()
};
@ -414,7 +426,7 @@ pub async fn get_server_module_options_context(
ModuleOptionsContext {
enable_jsx: Some(jsx_runtime_options),
enable_webpack_loaders,
enable_postcss_transform: postcss_transform_options,
enable_postcss_transform,
enable_typescript_transform: Some(tsconfig),
enable_mdx_rs,
decorators: Some(decorators_options),
@ -469,7 +481,7 @@ pub async fn get_server_module_options_context(
custom_rules: internal_custom_rules.clone(),
enable_webpack_loaders: foreign_webpack_loaders,
// NOTE(WEB-1016) PostCSS transforms should also apply to foreign code.
enable_postcss_transform: postcss_transform_options.clone(),
enable_postcss_transform: enable_foreign_postcss_transform,
..module_options_context.clone()
};
let internal_module_options_context = ModuleOptionsContext {
@ -491,7 +503,7 @@ pub async fn get_server_module_options_context(
ModuleOptionsContext {
enable_jsx: Some(jsx_runtime_options),
enable_webpack_loaders,
enable_postcss_transform: postcss_transform_options,
enable_postcss_transform,
enable_typescript_transform: Some(tsconfig),
enable_mdx_rs,
decorators: Some(decorators_options),
@ -555,7 +567,7 @@ pub async fn get_server_module_options_context(
custom_rules: internal_custom_rules.clone(),
enable_webpack_loaders: foreign_webpack_loaders,
// NOTE(WEB-1016) PostCSS transforms should also apply to foreign code.
enable_postcss_transform: postcss_transform_options.clone(),
enable_postcss_transform: enable_foreign_postcss_transform,
..module_options_context.clone()
};
let internal_module_options_context = ModuleOptionsContext {
@ -566,7 +578,7 @@ pub async fn get_server_module_options_context(
ModuleOptionsContext {
enable_jsx: Some(jsx_runtime_options),
enable_webpack_loaders,
enable_postcss_transform: postcss_transform_options,
enable_postcss_transform,
enable_typescript_transform: Some(tsconfig),
enable_mdx_rs,
decorators: Some(decorators_options),
@ -591,6 +603,13 @@ pub async fn get_server_module_options_context(
tree_shaking_mode: Some(TreeShakingMode::ReexportsOnly),
..Default::default()
};
let foreign_code_module_options_context = ModuleOptionsContext {
custom_rules: internal_custom_rules.clone(),
enable_webpack_loaders: foreign_webpack_loaders,
// NOTE(WEB-1016) PostCSS transforms should also apply to foreign code.
enable_postcss_transform: enable_foreign_postcss_transform,
..module_options_context.clone()
};
let internal_module_options_context = ModuleOptionsContext {
enable_typescript_transform: Some(TypescriptTransformOptions::default().cell()),
custom_rules: internal_custom_rules,
@ -598,14 +617,14 @@ pub async fn get_server_module_options_context(
};
ModuleOptionsContext {
enable_webpack_loaders,
enable_postcss_transform: postcss_transform_options,
enable_postcss_transform,
enable_typescript_transform: Some(tsconfig),
enable_mdx_rs,
decorators: Some(decorators_options),
rules: vec![
(
foreign_code_context_condition,
module_options_context.clone().cell(),
foreign_code_module_options_context.cell(),
),
(
ContextCondition::InPath(next_js_fs().root()),
@ -640,6 +659,13 @@ pub async fn get_server_module_options_context(
tree_shaking_mode: Some(TreeShakingMode::ReexportsOnly),
..Default::default()
};
let foreign_code_module_options_context = ModuleOptionsContext {
custom_rules: internal_custom_rules.clone(),
enable_webpack_loaders: foreign_webpack_loaders,
// NOTE(WEB-1016) PostCSS transforms should also apply to foreign code.
enable_postcss_transform: enable_foreign_postcss_transform,
..module_options_context.clone()
};
let internal_module_options_context = ModuleOptionsContext {
enable_typescript_transform: Some(TypescriptTransformOptions::default().cell()),
custom_rules: internal_custom_rules,
@ -648,14 +674,14 @@ pub async fn get_server_module_options_context(
ModuleOptionsContext {
enable_jsx: Some(jsx_runtime_options),
enable_webpack_loaders,
enable_postcss_transform: postcss_transform_options,
enable_postcss_transform,
enable_typescript_transform: Some(tsconfig),
enable_mdx_rs,
decorators: Some(decorators_options),
rules: vec![
(
foreign_code_context_condition,
module_options_context.clone().cell(),
foreign_code_module_options_context.cell(),
),
(
ContextCondition::InPath(next_js_fs().root()),

View file

@ -194,7 +194,7 @@
"@types/ws": "8.2.0",
"@vercel/ncc": "0.34.0",
"@vercel/nft": "0.26.2",
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.1",
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.3",
"acorn": "8.5.0",
"amphtml-validator": "1.0.35",
"anser": "1.4.9",

View file

@ -1077,8 +1077,8 @@ importers:
specifier: 0.26.2
version: 0.26.2
'@vercel/turbopack-ecmascript-runtime':
specifier: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.1
version: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.1(react-refresh@0.12.0)(webpack@5.86.0)'
specifier: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.3
version: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.3(react-refresh@0.12.0)(webpack@5.86.0)'
acorn:
specifier: 8.5.0
version: 8.5.0
@ -25649,9 +25649,9 @@ packages:
/zwitch@2.0.4:
resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}
'@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.1(react-refresh@0.12.0)(webpack@5.86.0)':
resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.1}
id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.1'
'@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.3(react-refresh@0.12.0)(webpack@5.86.0)':
resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.3}
id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.3'
name: '@vercel/turbopack-ecmascript-runtime'
version: 0.0.0
dependencies: