Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(next-swc/relay): make pages directory optional #43116

Merged
merged 5 commits into from Nov 20, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/next-swc/crates/core/src/relay.rs
Expand Up @@ -27,7 +27,7 @@ impl Default for RelayLanguageConfig {

struct Relay<'a> {
root_dir: PathBuf,
pages_dir: PathBuf,
pages_dir: Option<PathBuf>,
file_name: FileName,
config: &'a Config,
}
Expand Down Expand Up @@ -107,7 +107,11 @@ impl<'a> Relay<'a> {

if let Some(artifact_directory) = &self.config.artifact_directory {
Ok(self.root_dir.join(artifact_directory).join(filename))
} else if real_file_name.starts_with(&self.pages_dir) {
} else if self
.pages_dir
.as_ref()
.map_or(false, |pages_dir| real_file_name.starts_with(pages_dir))
{
Err(BuildRequirePathError::ArtifactDirectoryExpected {
file_name: real_file_name.display().to_string(),
})
Expand Down Expand Up @@ -181,7 +185,7 @@ pub fn relay(config: &Config, file_name: FileName, pages_dir: Option<PathBuf>) -
Relay {
root_dir: std::env::current_dir().unwrap(),
file_name,
pages_dir: pages_dir.unwrap_or_else(|| panic!("pages_dir is expected.")),
pages_dir,
config,
}
}