Skip to content

Commit

Permalink
Merge branch 'canary' into docs-getting-started-nits
Browse files Browse the repository at this point in the history
  • Loading branch information
delbaoliveira authored Dec 10, 2024
2 parents b05fd7c + b730b9c commit 9ce07b1
Show file tree
Hide file tree
Showing 1,011 changed files with 40,979 additions and 40,375 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ test/development/basic/hmr/components/parse-error.js
packages/next-swc/docs/assets/**/*
test/lib/amp-validator-wasm.js
test/production/pages-dir/production/fixture/amp-validator-wasm.js
test/e2e/app-dir/server-source-maps/fixtures/default/internal-pkg/sourcemapped.js
test/e2e/app-dir/server-source-maps/fixtures/default/external-pkg/sourcemapped.js
test/e2e/async-modules/amp-validator-wasm.js
test/development/next-lint-eslint-formatter-compact/**/*.js

Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,19 @@ jobs:
elif [ '${{ github.event_name }}' == 'workflow_dispatch' ]
then
echo "value=force-preview" >> $GITHUB_OUTPUT
elif [[ $(node scripts/run-for-change.js --not --type docs --exec echo 'false') != 'false' ]];
then
echo "value=skipped" >> $GITHUB_OUTPUT
else
echo "value=automated-preview" >> $GITHUB_OUTPUT
fi
- name: Print deploy target
run: echo "Deploy target is '${{ steps.deploy-target.outputs.value }}'"

build:
if: ${{ needs.deploy-target.outputs.value != 'skipped' }}
needs:
- deploy-target
runs-on: ubuntu-latest
env:
NEXT_TELEMETRY_DISABLED: 1
Expand Down Expand Up @@ -96,6 +102,7 @@ jobs:

# Build binaries for publishing
build-native:
if: ${{ needs.deploy-target.outputs.value != 'skipped' }}
needs:
- deploy-target
defaults:
Expand Down Expand Up @@ -380,6 +387,9 @@ jobs:
path: .turbo/runs

build-wasm:
if: ${{ needs.deploy-target.outputs.value != 'skipped' }}
needs:
- deploy-target
strategy:
matrix:
target: [web, nodejs]
Expand Down
23 changes: 18 additions & 5 deletions .github/workflows/issue_stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,23 @@ jobs:
name: 'Close stale issues with no reproduction'
with:
repo-token: ${{ secrets.STALE_TOKEN }}
any-of-labels: 'please add a complete reproduction,please simplify reproduction'
close-issue-message: 'This issue has been automatically closed because it received no activity for a month and had no reproduction to investigate. If you think it was closed by accident, please leave a comment. If you are running into a similar issue, please open a new issue with a reproduction. Thank you.'
any-of-labels: 'please add a complete reproduction'
close-issue-message: 'This issue has been automatically closed due to 2 days of inactivity and the avsence of a complete reproduction. If you believe this was done in error, please leave a comment. If you are experiencing a similar issue, consider opening a new issue with a complete reproduction. Thank you.'
days-before-issue-close: 1
days-before-issue-stale: 30
days-before-issue-stale: 2
days-before-pr-close: -1
days-before-pr-stale: -1
exempt-issue-labels: 'blocked,must,should,keep'
operations-per-run: 300 # 1 operation per 100 issues, the rest is to label/comment/close
- uses: actions/stale@v9
id: stale-simple-repro
name: 'Close issues with no simple repro'
with:
repo-token: ${{ secrets.STALE_TOKEN }}
any-of-labels: 'please simplify reproduction'
close-issue-message: 'This issue has been automatically closed due to 14 days of inactivity and the absence of a simple reproduction for investigation. If you believe this was done in error, please leave a comment. If you are experiencing a similar issue, consider opening a new issue with a simple reproduction. Thank you.'
days-before-issue-close: 1
days-before-issue-stale: 14
days-before-pr-close: -1
days-before-pr-stale: -1
exempt-issue-labels: 'blocked,must,should,keep'
Expand All @@ -29,9 +42,9 @@ jobs:
with:
repo-token: ${{ secrets.STALE_TOKEN }}
any-of-labels: 'please verify canary'
close-issue-message: "This issue has been automatically closed because it wasn't verified against next@canary. If you think it was closed by accident, please leave a comment. If you are running into a similar issue, please open a new issue with a reproduction. Thank you."
close-issue-message: 'This issue has been automatically closed due to 14 days of inactivity and the absence of testing against next@canary. If you believe this was done in error, please leave a comment. If you are experiencing a similar issue, consider opening a new issue with a reproduction. Thank you.'
days-before-issue-close: 1
days-before-issue-stale: 30
days-before-issue-stale: 14
days-before-pr-close: -1
days-before-pr-stale: -1
exempt-issue-labels: 'blocked,must,should,keep'
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ bench/nested-deps/components/**/*
**/.tina/__generated__/**
test/lib/amp-validator-wasm.js
test/production/pages-dir/production/fixture/amp-validator-wasm.js
test/e2e/app-dir/server-source-maps/fixtures/default/internal-pkg/sourcemapped.js
test/e2e/app-dir/server-source-maps/fixtures/default/external-pkg/sourcemapped.js
test/e2e/async-modules/amp-validator-wasm.js

# turbopack crates
Expand Down
13 changes: 8 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contributing/examples/adding-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
When you add an example to the [examples](https://github.com/vercel/next.js/tree/canary/examples) directory, please follow these guidelines to ensure high-quality examples:

- TypeScript should be leveraged for new examples (no need for separate JavaScript and TypeScript examples, converting old JavaScript examples is preferred)
- Examples should not add custom ESLint configuration (we have specific templates for ESLint)
- Examples should not add custom ESLint configuration (we have [specific templates for ESLint](https://github.com/vercel/next.js/tree/canary/examples/with-eslint))
- If API routes aren't used in an example, they should be omitted
- If an example exists for a certain library and you would like to showcase a specific feature of that library, the existing example should be updated (instead of adding a new example)
- Package manager specific config should not be added (e.g. `resolutions` in `package.json`)
Expand Down
31 changes: 22 additions & 9 deletions crates/napi/src/next_api/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{path::PathBuf, sync::Arc, thread, time::Duration};

use anyhow::{anyhow, bail, Context, Result};
use napi::{
bindgen_prelude::External,
bindgen_prelude::{within_runtime_if_available, External},
threadsafe_function::{ThreadsafeFunction, ThreadsafeFunctionCallMode},
JsFunction, Status,
};
Expand All @@ -22,9 +22,11 @@ use once_cell::sync::Lazy;
use rand::Rng;
use tokio::{io::AsyncWriteExt, time::Instant};
use tracing::Instrument;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Registry};
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, Registry};
use turbo_rcstr::RcStr;
use turbo_tasks::{get_effects, Completion, Effects, ReadRef, TransientInstance, UpdateInfo, Vc};
use turbo_tasks::{
get_effects, Completion, Effects, ReadRef, ResolvedVc, TransientInstance, UpdateInfo, Vc,
};
use turbo_tasks_fs::{
util::uri_from_file, DiskFileSystem, FileContent, FileSystem, FileSystemPath,
};
Expand All @@ -39,6 +41,7 @@ use turbopack_core::{
use turbopack_ecmascript_hmr_protocol::{ClientUpdateInstruction, ResourceIdentifier};
use turbopack_trace_utils::{
exit::{ExitHandler, ExitReceiver},
filter_layer::FilterLayer,
raw_trace::RawTraceLayer,
trace_writer::TraceWriter,
};
Expand Down Expand Up @@ -315,7 +318,7 @@ pub async fn project_new(

let subscriber = Registry::default();

let subscriber = subscriber.with(EnvFilter::builder().parse(trace).unwrap());
let subscriber = subscriber.with(FilterLayer::try_new(&trace).unwrap());
let dist_dir = options.dist_dir.clone();

let internal_dir = PathBuf::from(&options.project_path).join(dist_dir);
Expand Down Expand Up @@ -527,14 +530,14 @@ impl NapiRoute {
} => NapiRoute {
pathname,
r#type: "page",
html_endpoint: convert_endpoint(html_endpoint),
data_endpoint: convert_endpoint(data_endpoint),
html_endpoint: convert_endpoint(*html_endpoint),
data_endpoint: convert_endpoint(*data_endpoint),
..Default::default()
},
Route::PageApi { endpoint } => NapiRoute {
pathname,
r#type: "page-api",
endpoint: convert_endpoint(endpoint),
endpoint: convert_endpoint(*endpoint),
..Default::default()
},
Route::AppPage(pages) => NapiRoute {
Expand All @@ -559,7 +562,7 @@ impl NapiRoute {
pathname,
original_name: Some(original_name),
r#type: "app-route",
endpoint: convert_endpoint(endpoint),
endpoint: convert_endpoint(*endpoint),
..Default::default()
},
Route::Conflict => NapiRoute {
Expand Down Expand Up @@ -1023,7 +1026,7 @@ pub struct StackFrame {
pub async fn get_source_map(
container: Vc<ProjectContainer>,
file_path: String,
) -> Result<Option<Vc<SourceMap>>> {
) -> Result<Option<ResolvedVc<SourceMap>>> {
let (file, module) = match Url::parse(&file_path) {
Ok(url) => match url.scheme() {
"file" => {
Expand Down Expand Up @@ -1202,6 +1205,16 @@ pub async fn project_get_source_map(
Ok(source_map)
}

#[napi]
pub fn project_get_source_map_sync(
#[napi(ts_arg_type = "{ __napiType: \"Project\" }")] project: External<ProjectInstance>,
file_path: String,
) -> napi::Result<Option<String>> {
within_runtime_if_available(|| {
tokio::runtime::Handle::current().block_on(project_get_source_map(project, file_path))
})
}

/// Runs exit handlers for the project registered using the [`ExitHandler`] API.
#[napi]
pub async fn project_on_exit(
Expand Down
9 changes: 8 additions & 1 deletion crates/napi/src/next_api/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,14 @@ pub fn create_turbo_tasks(
Ok(if persistent_caching {
NextTurboTasks::PersistentCaching(TurboTasks::new(
turbo_tasks_backend::TurboTasksBackend::new(
turbo_tasks_backend::BackendOptions::default(),
turbo_tasks_backend::BackendOptions {
storage_mode: Some(if std::env::var("TURBO_ENGINE_READ_ONLY").is_ok() {
turbo_tasks_backend::StorageMode::ReadOnly
} else {
turbo_tasks_backend::StorageMode::ReadWrite
}),
..Default::default()
},
default_backing_storage(&output_path.join("cache/turbopack"))?,
),
))
Expand Down
18 changes: 9 additions & 9 deletions crates/next-api/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,24 +711,24 @@ pub fn app_entry_point_to_route(
root_layouts,
} => Route::AppRoute {
original_name: page.to_string(),
endpoint: Vc::upcast(
endpoint: ResolvedVc::upcast(
AppEndpoint {
ty: AppEndpointType::Route { path, root_layouts },
app_project,
page,
}
.cell(),
.resolved_cell(),
),
},
AppEntrypoint::AppMetadata { page, metadata } => Route::AppRoute {
original_name: page.to_string(),
endpoint: Vc::upcast(
endpoint: ResolvedVc::upcast(
AppEndpoint {
ty: AppEndpointType::Metadata { metadata },
app_project,
page,
}
.cell(),
.resolved_cell(),
),
},
}
Expand Down Expand Up @@ -1457,10 +1457,10 @@ impl AppEndpoint {
let evaluatable = ResolvedVc::try_sidecast(app_entry.rsc_entry)
.await?
.context("Entry module must be evaluatable")?;
evaluatable_assets.push(*evaluatable);
evaluatable_assets.push(evaluatable);

if let Some(server_action_manifest_loader) = server_action_manifest_loader {
evaluatable_assets.push(server_action_manifest_loader);
evaluatable_assets.push(server_action_manifest_loader.to_resolved().await?);
}

{
Expand All @@ -1483,7 +1483,7 @@ impl AppEndpoint {
this.app_project.rsc_runtime_entries().await?.clone_value();

if let Some(server_action_manifest_loader) = server_action_manifest_loader {
evaluatable_assets.push(server_action_manifest_loader);
evaluatable_assets.push(server_action_manifest_loader.to_resolved().await?);
}

let EntryChunkGroupResult {
Expand Down Expand Up @@ -1511,7 +1511,7 @@ impl AppEndpoint {
.await?;

current_chunks = current_chunks
.concatenate(chunk_group.assets)
.concatenate(*chunk_group.assets)
.resolve()
.await?;
current_availability_info = chunk_group.availability_info;
Expand Down Expand Up @@ -1545,7 +1545,7 @@ impl AppEndpoint {
.await?;

current_chunks = current_chunks
.concatenate(chunk_group.assets)
.concatenate(*chunk_group.assets)
.resolve()
.await?;
current_availability_info = chunk_group.availability_info;
Expand Down
2 changes: 1 addition & 1 deletion crates/next-api/src/dynamic_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub(crate) async fn collect_evaluated_chunk_group(
if let Some(module) = Vc::try_resolve_downcast::<Box<dyn EvaluatableAsset>>(module).await? {
Ok(chunking_context.evaluated_chunk_group_assets(
module.ident(),
Vc::cell(vec![Vc::upcast(module)]),
Vc::cell(vec![ResolvedVc::upcast(module.to_resolved().await?)]),
Value::new(AvailabilityInfo::Root),
))
} else {
Expand Down
8 changes: 4 additions & 4 deletions crates/next-api/src/global_module_id_strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ impl GlobalModuleIdStrategyBuilder {
html_endpoint,
data_endpoint,
} => {
preprocessed_module_ids.push(preprocess_module_ids(*html_endpoint));
preprocessed_module_ids.push(preprocess_module_ids(*data_endpoint));
preprocessed_module_ids.push(preprocess_module_ids(**html_endpoint));
preprocessed_module_ids.push(preprocess_module_ids(**data_endpoint));
}
Route::PageApi { endpoint } => {
preprocessed_module_ids.push(preprocess_module_ids(*endpoint));
preprocessed_module_ids.push(preprocess_module_ids(**endpoint));
}
Route::AppPage(page_routes) => {
for page_route in page_routes {
Expand All @@ -65,7 +65,7 @@ impl GlobalModuleIdStrategyBuilder {
original_name: _,
endpoint,
} => {
preprocessed_module_ids.push(preprocess_module_ids(*endpoint));
preprocessed_module_ids.push(preprocess_module_ids(**endpoint));
}
Route::Conflict => {
tracing::info!("WARN: conflict");
Expand Down
2 changes: 1 addition & 1 deletion crates/next-api/src/instrumentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl InstrumentationEndpoint {
let Some(evaluatable) = ResolvedVc::try_sidecast(module).await? else {
bail!("Entry module must be evaluatable");
};
evaluatable_assets.push(*evaluatable);
evaluatable_assets.push(evaluatable);

let edge_chunking_context = this.project.edge_chunking_context(false);

Expand Down
6 changes: 3 additions & 3 deletions crates/next-api/src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use turbo_tasks::{Completion, ResolvedVc, Value, Vc};
use turbo_tasks_fs::{self, File, FileContent, FileSystemPath};
use turbopack_core::{
asset::AssetContent,
chunk::{availability_info::AvailabilityInfo, ChunkingContextExt},
chunk::{availability_info::AvailabilityInfo, ChunkingContextExt, EvaluatableAsset},
context::AssetContext,
module::{Module, Modules},
output::OutputAssets,
Expand Down Expand Up @@ -104,10 +104,10 @@ impl MiddlewareEndpoint {
bail!("Entry module must be evaluatable");
};

let evaluatable = Vc::try_resolve_sidecast(module)
let evaluatable = Vc::try_resolve_sidecast::<Box<dyn EvaluatableAsset>>(module)
.await?
.context("Entry module must be evaluatable")?;
evaluatable_assets.push(evaluatable);
evaluatable_assets.push(evaluatable.to_resolved().await?);

let edge_chunking_context = self.project.edge_chunking_context(false);

Expand Down
Loading

0 comments on commit 9ce07b1

Please sign in to comment.