Skip to content

feat: rspack cacheable noop feature #9990

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

Merged
merged 1 commit into from
Apr 11, 2025
Merged

feat: rspack cacheable noop feature #9990

merged 1 commit into from
Apr 11, 2025

Conversation

jerrykingxyz
Copy link
Contributor

@jerrykingxyz jerrykingxyz commented Apr 11, 2025

Summary

  1. rename cacheable macro to enable_cacheable macro in rspack_macro
// rspack_macro
- pub fn cacheable(args: proc_macro::TokenStream, tokens: proc_macro::TokenStream) -> proc_macro::TokenStream;
+ pub fn enable_cacheable(args: proc_macro::TokenStream, tokens: proc_macro::TokenStream) -> proc_macro::TokenStream;
  1. expose enable_cacheable, disable_cacheable and rename them to cacheable by noop feature
// rspack_cacheable
pub use rspack_macro::{enable_cacheable, disable_cacheable};
#[cfg(not(feature = "noop"))]
pub use rspack_macros::{enable_cacheable as cacheable};
#[cfg(feature = "noop")]
pub use rspack_macros::{disable_cacheable as cacheable};
  1. disable_cacheable generate a function to use rspack_cacheable::with::* to avoid unused import
// disable_cacheable macro expand
use std::path::PathBuf;

use rspack_cacheable::with::AsString;

struct FileInfo {
  path: PathBuf,
}

fn _fileinfo() {
  // use with type to avoid clippy unused import
  let _: Option<(AsString,)> = None;
}

#[test]
fn manual() {
  let data = FileInfo {
    path: PathBuf::default(),
  };
  assert_eq!(data.path, PathBuf::default())
}
  1. allows use of the noop feature to generate less code, and clippy can check for unused fields in struct
#[cacheable]
struct A {
  // This field is not used. Clippy can scan it with noop enabled.
  field: String
}

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@github-actions github-actions bot added release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack. labels Apr 11, 2025
Copy link

netlify bot commented Apr 11, 2025

Deploy Preview for rspack ready!

Name Link
🔨 Latest commit 550785f
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/67f8d9d0d55813000877ef04
😎 Deploy Preview https://deploy-preview-9990--rspack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codspeed-hq bot commented Apr 11, 2025

CodSpeed Performance Report

Merging #9990 will not alter performance

Comparing jerry/cacheable (550785f) with main (11cce66)

Summary

✅ 11 untouched benchmarks

@jerrykingxyz jerrykingxyz merged commit f3f6dd9 into main Apr 11, 2025
33 checks passed
@jerrykingxyz jerrykingxyz deleted the jerry/cacheable branch April 11, 2025 09:20
@h-a-n-a h-a-n-a mentioned this pull request Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy