Skip to content
Open
Show file tree
Hide file tree
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
20 changes: 10 additions & 10 deletions turbopack/crates/turbopack-node/src/evaluate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ use serde_json::Value as JsonValue;
use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{
Completion, FxIndexMap, NonLocalValue, OperationVc, PrettyPrintError, ResolvedVc, TaskInput,
TryJoinIterExt, ValueToString, Vc, duration_span, fxindexmap, mark_top_level_task,
TryJoinIterExt, Vc, duration_span, fxindexmap, mark_top_level_task,
parallel::available_parallelism, take_effects, trace::TraceRawVcs,
};
use turbo_tasks_env::{EnvMap, ProcessEnv};
use turbo_tasks_fs::{File, FileContent, FileSystemPath, to_sys_path};
use turbo_tasks_hash::{DeterministicHash, Xxh3Hash64Hasher};
use turbopack_core::{
asset::AssetContent,
changed::content_changed,
Expand Down Expand Up @@ -151,14 +150,15 @@ async fn emit_evaluate_pool_assets_operation(
main_entry_ident,
} = &*entries.await?;

let module_ident = main_entry_ident.to_string().await?;
let module_ident_hash = {
let mut hasher = Xxh3Hash64Hasher::new();
module_ident.deterministic_hash(&mut hasher);
hasher.finish()
};
let file_name = format!("{module_ident_hash:016x}.js");
let entrypoint = chunking_context.output_root().await?.join(&file_name)?;
let entrypoint = chunking_context
.chunk_path(
None,
**main_entry_ident,
Some(rcstr!("pool_entry")),
rcstr!(".js"),
)
.owned()
.await?;

let bootstrap = chunking_context.root_entry_chunk_group_asset(
entrypoint.clone(),
Expand Down
18 changes: 8 additions & 10 deletions turbopack/crates/turbopack-node/src/transforms/postcss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serde::Deserialize;
use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{
Completion, Completions, NonLocalValue, ResolvedVc, TaskInput, TryFlatJoinIterExt, Vc,
fxindexmap, trace::TraceRawVcs,
fxindexmap, trace::TraceRawVcs, turbofmt,
};
use turbo_tasks_fs::{
File, FileContent, FileSystemEntryType, FileSystemPath, json::parse_json_with_source_context,
Expand Down Expand Up @@ -355,8 +355,7 @@ pub(crate) async fn config_loader_source(
project_path: FileSystemPath,
postcss_config_path: FileSystemPath,
) -> Result<Vc<Box<dyn Source>>> {
let postcss_config_path_value = postcss_config_path.clone();
let postcss_config_path_filename = postcss_config_path_value.file_name();
let postcss_config_path_filename = postcss_config_path.file_name();

if postcss_config_path_filename == "package.json" {
return Ok(Vc::upcast(JsonSource::new(
Expand All @@ -366,9 +365,7 @@ pub(crate) async fn config_loader_source(
)));
}

if postcss_config_path_value.path.ends_with(".json")
|| postcss_config_path_filename == ".postcssrc"
{
if postcss_config_path.path.ends_with(".json") || postcss_config_path_filename == ".postcssrc" {
return Ok(Vc::upcast(JsonSource::new(
postcss_config_path,
Vc::cell(None),
Expand All @@ -377,11 +374,11 @@ pub(crate) async fn config_loader_source(
}

// We can only load js files with `import()`.
if !postcss_config_path_value.path.ends_with(".js") {
if !postcss_config_path.path.ends_with(".js") {
return Ok(Vc::upcast(FileSource::new(postcss_config_path)));
}

let Some(config_path) = project_path.get_relative_path_to(&postcss_config_path_value) else {
let Some(config_path) = project_path.get_relative_path_to(&postcss_config_path) else {
bail!("Unable to get relative path to postcss config");
};

Expand Down Expand Up @@ -418,18 +415,19 @@ async fn postcss_executor(
) -> Result<Vc<ProcessResult>> {
let config_asset = asset_context
.process(
config_loader_source(project_path, postcss_config_path),
config_loader_source(project_path, postcss_config_path.clone()),
ReferenceType::Entry(EntryReferenceSubType::Undefined),
)
.module()
.to_resolved()
.await?;

Ok(asset_context.process(
Vc::upcast(FileSource::new(
Vc::upcast(FileSource::new_with_query(
embed_file_path(rcstr!("transforms/postcss.ts"))
.owned()
.await?,
turbofmt!("?config={postcss_config_path}").await?,
)),
ReferenceType::Internal(ResolvedVc::cell(fxindexmap! {
rcstr!("CONFIG") => config_asset
Expand Down
14 changes: 12 additions & 2 deletions turbopack/crates/turbopack-node/src/transforms/webpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use turbopack_core::{
file_source::FileSource,
ident::AssetIdent,
issue::{Issue, IssueExt, IssueSeverity, IssueSource, IssueStage, StyledString},
module::Module,
module_graph::{
ModuleGraph, SingleModuleGraph,
chunk_group_info::{ChunkGroup, ChunkGroupEntry},
Expand Down Expand Up @@ -762,8 +763,16 @@ impl EvaluateContext for WebpackLoaderContext {
.await?;

// Generate a full Node.js bundle using the real runtime
let output_root = self.chunking_context.output_root().owned().await?;
let entry_path = output_root.join("importModule.js")?;
let entry_path = self
.chunking_context
.chunk_path(
None,
module.ident(),
Some(rcstr!("importModule")),
rcstr!(".js"),
)
.owned()
.await?;

let bootstrap = self.chunking_context.root_entry_chunk_group_asset(
entry_path.clone(),
Expand All @@ -780,6 +789,7 @@ impl EvaluateContext for WebpackLoaderContext {
true,
)
.await?;
let output_root = self.chunking_context.output_root().owned().await?;

let mut chunks = Vec::new();
for asset in all_assets {
Expand Down
Loading