diff --git a/src/config/bin_package.rs b/src/config/bin_package.rs index 1457f67f..c984c454 100644 --- a/src/config/bin_package.rs +++ b/src/config/bin_package.rs @@ -4,7 +4,7 @@ use cargo_metadata::{Metadata, Target}; use super::{project::ProjectDefinition, Profile, ProjectConfig}; use crate::{ config::Opts, - ext::{MetadataExt, PackageExt, PathBufExt, PathExt}, + ext::{MetadataExt, PathBufExt, PathExt}, internal_prelude::*, }; pub struct BinPackage { @@ -48,7 +48,7 @@ impl BinPackage { let packages = metadata.workspace_packages(); let package = packages .iter() - .find(|p| *p.name == name && p.has_bin_target()) + .find(|p| *p.name == name) .ok_or_else(|| eyre!(r#"Could not find the project bin-package "{name}""#,))?; let package = (*package).clone(); diff --git a/src/config/lib_package.rs b/src/config/lib_package.rs index a5986696..94d91bb8 100644 --- a/src/config/lib_package.rs +++ b/src/config/lib_package.rs @@ -1,7 +1,8 @@ use crate::{ config::Opts, - ext::{MetadataExt, PathBufExt, PathExt}, + ext::{MetadataExt, PackageExt, PathBufExt, PathExt}, internal_prelude::*, + logger::GRAY, service::site::{SiteFile, SourcedSiteFile}, }; use camino::Utf8PathBuf; @@ -45,6 +46,14 @@ impl LibPackage { .find(|p| *p.name == name) .ok_or_else(|| eyre!(r#"Could not find the project lib-package "{name}""#,))?; + let Some(target_lib) = package.cdylib_target() else { + return Err(eyre!( + r#"Could not find a cdylib library target for the leptos lib-package "{}" defined in {}"#, + package.name, + GRAY.paint(package.manifest_path.as_str()), + )); + }; + let mut features = if !cli.lib_features.is_empty() { cli.lib_features.clone() } else if !config.lib_features.is_empty() { @@ -70,7 +79,7 @@ impl LibPackage { .join("front") .join("wasm32-unknown-unknown") .join(profile.to_string()) - .join(name.replace('-', "_")) + .join(target_lib.name.clone()) .with_extension("wasm"); let site = config .site_pkg_dir diff --git a/src/config/project.rs b/src/config/project.rs index 11117402..228e538a 100644 --- a/src/config/project.rs +++ b/src/config/project.rs @@ -1,8 +1,7 @@ use crate::{ config::{hash_file::HashFile, lib_package::LibPackage}, - ext::{PackageExt, Paint, PathBufExt, PathExt}, + ext::{PathBufExt, PathExt}, internal_prelude::*, - logger::GRAY, service::site::Site, }; use camino::{Utf8Path, Utf8PathBuf}; @@ -456,17 +455,6 @@ impl ProjectDefinition { ) -> Result<(Self, ProjectConfig)> { let conf = ProjectConfig::parse(dir, metadata, cargo_metadata)?; - ensure!( - package.cdylib_target().is_some(), - "Cargo.toml has leptos metadata but is missing a cdylib library target. {}", - GRAY.paint(package.manifest_path.as_str()) - ); - ensure!( - package.has_bin_target(), - "Cargo.toml has leptos metadata but is missing a bin target. {}", - GRAY.paint(package.manifest_path.as_str()) - ); - Ok(( ProjectDefinition { name: package.name.to_string(), diff --git a/src/ext/eyre.rs b/src/ext/eyre.rs index 46185e5c..8cc13305 100644 --- a/src/ext/eyre.rs +++ b/src/ext/eyre.rs @@ -5,7 +5,7 @@ pub(crate) mod reexports { //! re-exports pub use super::{AnyhowCompatWrapErr as _, CustomWrapErr as _}; - pub use color_eyre::eyre::{self, anyhow, bail, ensure, eyre, Report as Error, Result}; + pub use color_eyre::eyre::{self, anyhow, bail, eyre, Report as Error, Result}; } use reexports::*;