Skip to content

Commit

Permalink
fix: cargo test
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind committed Aug 26, 2024
1 parent 6de23e6 commit f5fa45e
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 25 deletions.
34 changes: 31 additions & 3 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ proc-macro2 = { version = "1.0.79" }
quote = { version = "1.0.35" }
rayon = { version = "1.10.0" }
regex = { version = "1.10.4" }
rspack_sources = { git = "https://github.com/SyMind/rspack-sources.git", rev = "096649f" }
rspack_sources = { git = "https://github.com/SyMind/rspack-sources.git", rev = "d64fd01" }
rustc-hash = { version = "1.1.0" }
schemars = { version = "0.8.16" }
serde = { version = "1.0.197" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ impl From<RawCopyPattern> for CopyPattern {

fn convert_to_enum(input: Either<String, Buffer>) -> RawSource {
match input {
Either::A(s) => RawSource::Source(s),
Either::B(b) => RawSource::Buffer(b.to_vec()),
Either::A(s) => RawSource::from(s),
Either::B(b) => RawSource::from(b.to_vec()),
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_binding_values/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<'a> StreamChunks<'a> for CompatSource {
fn stream_chunks(
&'a self,
options: &MapOptions,
on_chunk: OnChunk,
on_chunk: OnChunk<'_, 'a>,
on_source: OnSource<'_, 'a>,
on_name: OnName<'_, 'a>,
) -> GeneratedInfo {
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_core/src/normal_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ impl Diagnosable for NormalModule {
impl NormalModule {
fn create_source(&self, content: Content, source_map: Option<SourceMap>) -> Result<BoxSource> {
if content.is_buffer() {
return Ok(RawSource::Buffer(content.into_bytes()).boxed());
return Ok(RawSource::from(content.into_bytes()).boxed());
}
let source_map_kind = self.get_source_map_kind();
if source_map_kind.enabled()
Expand Down
16 changes: 5 additions & 11 deletions crates/rspack_plugin_copy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ use futures::future::BoxFuture;
use glob::{MatchOptions, Pattern as GlobPattern};
use regex::Regex;
use rspack_core::{
rspack_sources::RawSource, AssetInfo, AssetInfoRelated, Compilation, CompilationAsset,
CompilationLogger, CompilationProcessAssets, FilenameTemplate, Logger, PathData, Plugin,
rspack_sources::{RawSource, Source},
AssetInfo, AssetInfoRelated, Compilation, CompilationAsset, CompilationLogger,
CompilationProcessAssets, FilenameTemplate, Logger, PathData, Plugin,
};
use rspack_error::{Diagnostic, DiagnosticError, Error, ErrorExt, Result};
use rspack_hash::{HashDigest, HashFunction, HashSalt, RspackHash, RspackHashDigest};
Expand Down Expand Up @@ -148,14 +149,7 @@ impl CopyRspackPlugin {
salt: &HashSalt,
) -> RspackHashDigest {
let mut hasher = RspackHash::with_salt(function, salt);
match &source {
RawSource::Buffer(buffer) => {
buffer.hash(&mut hasher);
}
RawSource::Source(source) => {
source.hash(&mut hasher);
}
}
source.buffer().hash(&mut hasher);
hasher.digest(digest)
}

Expand Down Expand Up @@ -290,7 +284,7 @@ impl CopyRspackPlugin {
}
};

let mut source = RawSource::Buffer(source_vec.clone());
let mut source = RawSource::from(source_vec.clone());

if let Some(transform) = &pattern.transform {
match transform {
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_plugin_hmr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ async fn process_assets(&self, compilation: &mut Compilation) -> Result<()> {
filename,
CompilationAsset::new(
Some(
RawSource::Source(
RawSource::from(
serde_json::json!({
"c": c,
"r": r,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,18 @@ fn render_chunk(
let mut source = ConcatSource::default();

if matches!(chunk.kind, ChunkKind::HotUpdate) {
source.add(RawSource::Source(format!(
source.add(RawSource::from(format!(
"{}[{}]('{}', ",
global_object,
serde_json::to_string(hot_update_global).map_err(|e| error!(e.to_string()))?,
chunk.expect_id()
)));
source.add(render_source.source.clone());
if has_runtime_modules {
source.add(RawSource::Source(",".to_string()));
source.add(RawSource::from(",".to_string()));
source.add(render_chunk_runtime_modules(compilation, chunk_ukey)?);
}
source.add(RawSource::Source(")".to_string()));
source.add(RawSource::from(")".to_string()));
} else {
let chunk_loading_global = &compilation.options.output.chunk_loading_global;

Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_plugin_swc_js_minimizer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ async fn process_assets(&self, compilation: &mut Compilation) -> Result<()> {
.contains_key(filename)
{
ConcatSource::new([
RawSource::Source(banner).boxed(),
RawSource::from(banner).boxed(),
RawSource::from("\n").boxed(),
source
]).boxed()
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_plugin_swc_js_minimizer/src/minify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ pub fn minify(
.insert(
filename.to_string(),
ExtractedCommentsInfo {
source: RawSource::Source(extracted_comments.join("\n\n")).boxed(),
source: RawSource::from(extracted_comments.join("\n\n")).boxed(),
comments_file_name: extract_comments.filename.to_string(),
},
);
Expand Down

0 comments on commit f5fa45e

Please sign in to comment.