Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled
280 lines
9.1 KiB
Rust
280 lines
9.1 KiB
Rust
use std::{iter::FromIterator, path::PathBuf};
|
|
|
|
use next_custom_transforms::transforms::{
|
|
disallow_re_export_all_in_page::disallow_re_export_all_in_page,
|
|
dynamic::{NextDynamicMode, next_dynamic},
|
|
fonts::{Config as FontLoaderConfig, next_font_loaders},
|
|
next_ssg::next_ssg,
|
|
react_server_components::server_components,
|
|
server_actions::{self, ServerActionsMode, server_actions},
|
|
strip_page_exports::{ExportFilter, next_transform_strip_page_exports},
|
|
};
|
|
use rustc_hash::FxHashSet;
|
|
use swc_core::{
|
|
atoms::atom,
|
|
common::{FileName, Mark},
|
|
ecma::{
|
|
parser::{EsSyntax, Syntax},
|
|
transforms::{
|
|
base::resolver,
|
|
testing::{FixtureTestConfig, test_fixture},
|
|
},
|
|
},
|
|
};
|
|
use testing::fixture;
|
|
use turbo_rcstr::rcstr;
|
|
|
|
fn syntax() -> Syntax {
|
|
Syntax::Es(EsSyntax {
|
|
jsx: true,
|
|
..Default::default()
|
|
})
|
|
}
|
|
|
|
#[fixture("tests/errors/re-export-all-in-page/**/input.js")]
|
|
fn re_export_all_in_page(input: PathBuf) {
|
|
let output = input.parent().unwrap().join("output.js");
|
|
test_fixture(
|
|
syntax(),
|
|
&|_tr| disallow_re_export_all_in_page(true),
|
|
&input,
|
|
&output,
|
|
FixtureTestConfig {
|
|
allow_error: true,
|
|
module: Some(true),
|
|
..Default::default()
|
|
},
|
|
);
|
|
}
|
|
|
|
#[fixture("tests/errors/next-dynamic/**/input.js")]
|
|
fn next_dynamic_errors(input: PathBuf) {
|
|
let output = input.parent().unwrap().join("output.js");
|
|
test_fixture(
|
|
syntax(),
|
|
&|_tr| {
|
|
next_dynamic(
|
|
true,
|
|
false,
|
|
false,
|
|
false,
|
|
NextDynamicMode::Webpack,
|
|
FileName::Real(PathBuf::from("/some-project/src/some-file.js")).into(),
|
|
Some("/some-project/src".into()),
|
|
)
|
|
},
|
|
&input,
|
|
&output,
|
|
FixtureTestConfig {
|
|
allow_error: true,
|
|
module: Some(true),
|
|
..Default::default()
|
|
},
|
|
);
|
|
}
|
|
|
|
#[fixture("tests/errors/next-ssg/**/input.js")]
|
|
fn next_ssg_errors(input: PathBuf) {
|
|
let output = input.parent().unwrap().join("output.js");
|
|
test_fixture(
|
|
syntax(),
|
|
&|_tr| next_ssg(Default::default()),
|
|
&input,
|
|
&output,
|
|
FixtureTestConfig {
|
|
allow_error: true,
|
|
module: Some(true),
|
|
..Default::default()
|
|
},
|
|
);
|
|
}
|
|
|
|
#[fixture("tests/errors/react-server-components/**/input.js")]
|
|
#[fixture("tests/errors/react-server-components/**/page.js")]
|
|
#[fixture("tests/errors/react-server-components/**/route.js")]
|
|
fn react_server_components_errors(input: PathBuf) {
|
|
use next_custom_transforms::transforms::react_server_components::{Config, Options};
|
|
let is_react_server_layer = input.iter().any(|s| s.to_str() == Some("server-graph"));
|
|
let cache_components_enabled = input.iter().any(|s| s.to_str() == Some("cache-components"));
|
|
let use_cache_enabled = input.iter().any(|s| s.to_str() == Some("use-cache"));
|
|
let taint_enabled = input.iter().any(|s| s.to_str() == Some("taint-enabled"));
|
|
|
|
let app_dir = input
|
|
.iter()
|
|
.position(|s| s.to_str() == Some("app-dir"))
|
|
.map(|pos| input.iter().take(pos + 1).collect());
|
|
|
|
let output = input.parent().unwrap().join("output.js");
|
|
test_fixture(
|
|
syntax(),
|
|
&|tr| {
|
|
server_components(
|
|
FileName::Real(input.clone()).into(),
|
|
Config::WithOptions(Options {
|
|
is_react_server_layer,
|
|
cache_components_enabled,
|
|
use_cache_enabled,
|
|
taint_enabled,
|
|
page_extensions: vec![],
|
|
}),
|
|
tr.comments.as_ref().clone(),
|
|
app_dir.clone(),
|
|
)
|
|
},
|
|
&input,
|
|
&output,
|
|
FixtureTestConfig {
|
|
allow_error: true,
|
|
module: Some(true),
|
|
..Default::default()
|
|
},
|
|
);
|
|
}
|
|
|
|
#[fixture("tests/errors/next-font-loaders/**/input.js")]
|
|
fn next_font_loaders_errors(input: PathBuf) {
|
|
let output = input.parent().unwrap().join("output.js");
|
|
test_fixture(
|
|
syntax(),
|
|
&|_tr| {
|
|
next_font_loaders(FontLoaderConfig {
|
|
relative_file_path_from_root: atom!("pages/test.tsx"),
|
|
font_loaders: vec![
|
|
atom!("@next/font/google").into(),
|
|
atom!("cool-fonts").into(),
|
|
],
|
|
})
|
|
},
|
|
&input,
|
|
&output,
|
|
FixtureTestConfig {
|
|
allow_error: true,
|
|
module: Some(true),
|
|
..Default::default()
|
|
},
|
|
);
|
|
}
|
|
|
|
#[fixture("tests/errors/server-actions/**/input.js")]
|
|
fn react_server_actions_errors(input: PathBuf) {
|
|
use next_custom_transforms::transforms::react_server_components::{Config, Options};
|
|
let is_react_server_layer = input.iter().any(|s| s.to_str() == Some("server-graph"));
|
|
let output = input.parent().unwrap().join("output.js");
|
|
test_fixture(
|
|
syntax(),
|
|
&|tr| {
|
|
let unresolved_mark = Mark::new();
|
|
(
|
|
// The transforms are intentionally declared in the same order as in
|
|
// crates/next-custom-transforms/src/chain_transforms.rs
|
|
resolver(unresolved_mark, Mark::new(), false),
|
|
server_components(
|
|
FileName::Real(PathBuf::from("/app/item.js")).into(),
|
|
Config::WithOptions(Options {
|
|
is_react_server_layer,
|
|
cache_components_enabled: true,
|
|
use_cache_enabled: true,
|
|
taint_enabled: true,
|
|
page_extensions: vec![],
|
|
}),
|
|
tr.comments.as_ref().clone(),
|
|
None,
|
|
),
|
|
server_actions(
|
|
&FileName::Real("/app/item.js".into()),
|
|
None,
|
|
server_actions::Config {
|
|
is_react_server_layer,
|
|
is_development: true,
|
|
use_cache_enabled: true,
|
|
hash_salt: "".into(),
|
|
cache_kinds: FxHashSet::default(),
|
|
},
|
|
tr.comments.as_ref().clone(),
|
|
unresolved_mark,
|
|
tr.cm.clone(),
|
|
Default::default(),
|
|
ServerActionsMode::Webpack,
|
|
),
|
|
)
|
|
},
|
|
&input,
|
|
&output,
|
|
FixtureTestConfig {
|
|
allow_error: true,
|
|
module: Some(true),
|
|
..Default::default()
|
|
},
|
|
);
|
|
}
|
|
|
|
#[fixture("tests/errors/strip-page-exports/**/input.js")]
|
|
fn next_transform_strip_page_exports_errors(input: PathBuf) {
|
|
let output = input.parent().unwrap().join("output.js");
|
|
test_fixture(
|
|
syntax(),
|
|
&|_tr| {
|
|
next_transform_strip_page_exports(ExportFilter::StripDataExports, Default::default())
|
|
},
|
|
&input,
|
|
&output,
|
|
FixtureTestConfig {
|
|
allow_error: true,
|
|
module: Some(true),
|
|
..Default::default()
|
|
},
|
|
);
|
|
}
|
|
|
|
#[fixture("tests/errors/use-cache-not-allowed/**/input.js")]
|
|
fn use_cache_not_allowed(input: PathBuf) {
|
|
use next_custom_transforms::transforms::react_server_components::{Config, Options};
|
|
let output = input.parent().unwrap().join("output.js");
|
|
test_fixture(
|
|
syntax(),
|
|
&|tr| {
|
|
let unresolved_mark = Mark::new();
|
|
(
|
|
// The transforms are intentionally declared in the same order as in
|
|
// crates/next-custom-transforms/src/chain_transforms.rs
|
|
resolver(unresolved_mark, Mark::new(), false),
|
|
server_components(
|
|
FileName::Real(PathBuf::from("/app/item.js")).into(),
|
|
Config::WithOptions(Options {
|
|
is_react_server_layer: true,
|
|
cache_components_enabled: false,
|
|
use_cache_enabled: false,
|
|
taint_enabled: true,
|
|
page_extensions: vec![],
|
|
}),
|
|
tr.comments.as_ref().clone(),
|
|
None,
|
|
),
|
|
server_actions(
|
|
&FileName::Real("/app/item.js".into()),
|
|
None,
|
|
server_actions::Config {
|
|
is_react_server_layer: true,
|
|
is_development: true,
|
|
use_cache_enabled: false,
|
|
hash_salt: "".into(),
|
|
cache_kinds: FxHashSet::from_iter([rcstr!("x")]),
|
|
},
|
|
tr.comments.as_ref().clone(),
|
|
unresolved_mark,
|
|
tr.cm.clone(),
|
|
Default::default(),
|
|
ServerActionsMode::Webpack,
|
|
),
|
|
)
|
|
},
|
|
&input,
|
|
&output,
|
|
FixtureTestConfig {
|
|
allow_error: true,
|
|
module: Some(true),
|
|
..Default::default()
|
|
},
|
|
);
|
|
}
|