Skip to content

Commit

Permalink
Merge branch 'main' into refactor/css-loading
Browse files Browse the repository at this point in the history
  • Loading branch information
JSerFeng authored Nov 27, 2024
2 parents fac9e77 + 2edb6b4 commit 6cb1b12
Show file tree
Hide file tree
Showing 248 changed files with 5,261 additions and 2,011 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/typos@v1.27.3
- uses: crate-ci/typos@v1.28.1
with:
files: .

Expand Down Expand Up @@ -288,7 +288,7 @@ jobs:
- uses: ./.github/actions/rustup
with:
shared-key: check
- uses: cargo-bins/[email protected].13
- uses: cargo-bins/[email protected].14
- run: cargo binstall --no-confirm cargo-shear
- run: cargo shear

Expand Down
3 changes: 3 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions crates/node_binding/binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,7 @@ export interface RawEntryDynamicResult {
export interface RawEnvironment {
const?: boolean
arrowFunction?: boolean
nodePrefixForCoreModules?: boolean
}

export interface RawEvalDevToolModulePluginOptions {
Expand Down Expand Up @@ -1722,6 +1723,7 @@ export interface RawOptions {
experiments: RawExperiments
node?: RawNodeOption
profile: boolean
amd?: string
bail: boolean
__references: Record<string, any>
}
Expand Down
2 changes: 1 addition & 1 deletion crates/node_binding/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rspack/binding",
"version": "1.1.3",
"version": "1.1.4",
"license": "MIT",
"description": "Node binding for rspack",
"main": "binding.js",
Expand Down
9 changes: 4 additions & 5 deletions crates/node_binding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use napi::bindgen_prelude::*;
use rspack_binding_options::BuiltinPlugin;
use rspack_core::{Compilation, PluginExt};
use rspack_error::Diagnostic;
use rspack_fs_node::{AsyncNodeWritableFileSystem, ThreadsafeNodeFS};
use rspack_fs_node::{NodeFileSystem, ThreadsafeNodeFS};

mod compiler;
mod diagnostic;
Expand Down Expand Up @@ -70,10 +70,9 @@ impl Rspack {
compiler_options,
plugins,
rspack_binding_options::buildtime_plugins::buildtime_plugins(),
Some(Box::new(
AsyncNodeWritableFileSystem::new(output_filesystem)
.map_err(|e| Error::from_reason(format!("Failed to create writable filesystem: {e}",)))?,
)),
Some(Box::new(NodeFileSystem::new(output_filesystem).map_err(
|e| Error::from_reason(format!("Failed to create writable filesystem: {e}",)),
)?)),
None,
Some(resolver_factory),
Some(loader_resolver_factory),
Expand Down
4 changes: 2 additions & 2 deletions crates/node_binding/src/resolver_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::Arc;

use napi_derive::napi;
use rspack_core::{Resolve, ResolverFactory};
use rspack_fs::{NativeFileSystem, SyncReadableFileSystem};
use rspack_fs::{FileSystem, NativeFileSystem};

use crate::{
raw_resolve::{
Expand All @@ -15,7 +15,7 @@ use crate::{
pub struct JsResolverFactory {
pub(crate) resolver_factory: Option<Arc<ResolverFactory>>,
pub(crate) loader_resolver_factory: Option<Arc<ResolverFactory>>,
pub(crate) input_filesystem: Arc<dyn SyncReadableFileSystem>,
pub(crate) input_filesystem: Arc<dyn FileSystem>,
}

#[napi]
Expand Down
2 changes: 2 additions & 0 deletions crates/rspack_binding_options/src/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub struct RawOptions {
pub experiments: RawExperiments,
pub node: Option<RawNodeOption>,
pub profile: bool,
pub amd: Option<String>,
pub bail: bool,
#[napi(js_name = "__references", ts_type = "Record<string, any>")]
pub __references: References,
Expand Down Expand Up @@ -93,6 +94,7 @@ impl TryFrom<RawOptions> for CompilerOptions {
optimization,
node,
profile: value.profile,
amd: value.amd,
bail: value.bail,
__references: value.__references,
})
Expand Down
2 changes: 2 additions & 0 deletions crates/rspack_binding_options/src/options/raw_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ impl From<RawCrossOriginLoading> for CrossOriginLoading {
pub struct RawEnvironment {
pub r#const: Option<bool>,
pub arrow_function: Option<bool>,
pub node_prefix_for_core_modules: Option<bool>,
}

impl From<RawEnvironment> for Environment {
fn from(value: RawEnvironment) -> Self {
Self {
r#const: value.r#const,
arrow_function: value.arrow_function,
node_prefix_for_core_modules: value.node_prefix_for_core_modules,
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions crates/rspack_binding_values/src/compilation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,10 @@ impl JsCompilation {
) -> napi::Result<PathWithInfo> {
let compilation = self.as_ref()?;

let path_and_asset_info =
compilation.get_path_with_info(&filename.into(), data.to_path_data())?;
Ok(path_and_asset_info.into())
let mut asset_info = AssetInfo::default();
let path =
compilation.get_path_with_info(&filename.into(), data.to_path_data(), &mut asset_info)?;
Ok((path, asset_info).into())
}

#[napi]
Expand Down
8 changes: 4 additions & 4 deletions crates/rspack_cacheable/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ impl<'a> ContextGuard<'a> {
Self { context }
}

pub fn add_to_sharing<S: Sharing<SerializeError>>(
pub fn add_to_sharing<S: Sharing<SerializeError> + ?Sized>(
&self,
sharing: &mut S,
) -> Result<(), SerializeError> {
sharing.start_sharing(CONTEXT_ADDR);
sharing.finish_sharing(CONTEXT_ADDR, self as *const _ as usize)
}

pub fn sharing_context<S: Sharing<SerializeError>>(
pub fn sharing_context<S: Sharing<SerializeError> + ?Sized>(
sharing: &'a mut S,
) -> Result<&'a dyn Any, SerializeError> {
match sharing.start_sharing(CONTEXT_ADDR) {
Expand All @@ -40,7 +40,7 @@ impl<'a> ContextGuard<'a> {
}
}

pub fn add_to_pooling<P: Pooling<DeserializeError>>(
pub fn add_to_pooling<P: Pooling<DeserializeError> + ?Sized>(
&self,
pooling: &mut P,
) -> Result<(), DeserializeError> {
Expand All @@ -51,7 +51,7 @@ impl<'a> ContextGuard<'a> {
}
}

pub fn pooling_context<P: Pooling<DeserializeError>>(
pub fn pooling_context<P: Pooling<DeserializeError> + ?Sized>(
pooling: &'a mut P,
) -> Result<&'a dyn Any, DeserializeError> {
match pooling.start_pooling(CONTEXT_ADDR) {
Expand Down
1 change: 0 additions & 1 deletion crates/rspack_cacheable/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pub use rspack_macros::{cacheable, cacheable_dyn};
#[cfg(feature = "noop")]
pub use rspack_macros::{disable_cacheable as cacheable, disable_cacheable_dyn as cacheable_dyn};
pub mod r#dyn;
pub mod utils;
pub mod with;

mod context;
Expand Down
3 changes: 0 additions & 3 deletions crates/rspack_cacheable/src/utils/mod.rs

This file was deleted.

108 changes: 0 additions & 108 deletions crates/rspack_cacheable/src/utils/type_wrapper.rs

This file was deleted.

4 changes: 2 additions & 2 deletions crates/rspack_cacheable/src/with/as.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ where
impl<T, A, S> SerializeWith<T, S> for As<A>
where
A: AsConverter<T> + Archive + Serialize<S>,
S: Fallible<Error = SerializeError> + Sharing,
S: Fallible<Error = SerializeError> + Sharing + ?Sized,
{
#[inline]
fn serialize_with(field: &T, serializer: &mut S) -> Result<Self::Resolver, SerializeError> {
Expand All @@ -60,7 +60,7 @@ impl<T, A, D> DeserializeWith<Archived<A>, T, D> for As<A>
where
A: AsConverter<T> + Archive,
A::Archived: Deserialize<A, D>,
D: Fallible<Error = DeserializeError> + Pooling,
D: Fallible<Error = DeserializeError> + Pooling + ?Sized,
{
#[inline]
fn deserialize_with(field: &Archived<A>, de: &mut D) -> Result<T, DeserializeError> {
Expand Down
4 changes: 2 additions & 2 deletions crates/rspack_cacheable/src/with/as_cacheable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl<T: Archive> ArchiveWith<T> for AsCacheable {
impl<T, S> SerializeWith<T, S> for AsCacheable
where
T: Archive + Serialize<S>,
S: ?Sized + Fallible,
S: Fallible + ?Sized,
{
#[inline]
fn serialize_with(field: &T, serializer: &mut S) -> Result<Self::Resolver, S::Error> {
Expand All @@ -32,7 +32,7 @@ impl<T, D> DeserializeWith<Archived<T>, T, D> for AsCacheable
where
T: Archive,
T::Archived: Deserialize<T, D>,
D: ?Sized + Fallible,
D: Fallible + ?Sized,
{
#[inline]
fn deserialize_with(field: &Archived<T>, de: &mut D) -> Result<T, D::Error> {
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_cacheable/src/with/as_inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl<T, A, O, D> DeserializeWith<A::Archived, T, D> for AsInner<A>
where
T: AsInnerConverter<Inner = O>,
A: ArchiveWith<O> + DeserializeWith<A::Archived, O, D>,
D: ?Sized + Fallible,
D: Fallible + ?Sized,
{
fn deserialize_with(field: &A::Archived, d: &mut D) -> Result<T, D::Error> {
Ok(T::from_inner(A::deserialize_with(field, d)?))
Expand Down
5 changes: 3 additions & 2 deletions crates/rspack_cacheable/src/with/as_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ where
}
}

impl<WK, WV, K, V, S: Fallible + ?Sized> Serialize<S> for Entry<&'_ K, &'_ V, WK, WV>
impl<WK, WV, K, V, S> Serialize<S> for Entry<&'_ K, &'_ V, WK, WV>
where
WK: SerializeWith<K, S>,
WV: SerializeWith<V, S>,
S: Fallible + ?Sized,
{
#[inline]
fn serialize(&self, serializer: &mut S) -> Result<Self::Resolver, S::Error> {
Expand Down Expand Up @@ -90,7 +91,7 @@ where
T: AsMapConverter<Key = K, Value = V>,
WK: ArchiveWith<K>,
WV: ArchiveWith<V>,
S: Fallible + ?Sized + Allocator + Writer,
S: Fallible + Allocator + Writer + ?Sized,
for<'a> Entry<&'a K, &'a V, WK, WV>: Serialize<S>,
{
fn serialize_with(field: &T, s: &mut S) -> Result<Self::Resolver, S::Error> {
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_cacheable/src/with/as_preset/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod camino;
mod json;
mod lightningcss;
mod rspack_resolver;
mod rspack_source;
mod rspack_sources;
mod serde_json;
mod swc;
mod ustr;
Expand Down
Loading

0 comments on commit 6cb1b12

Please sign in to comment.