From a79aa58ef7ef131c8248d2f2342ebfe5657a901a Mon Sep 17 00:00:00 2001 From: jerrykingxyz Date: Fri, 13 Dec 2024 11:36:39 +0800 Subject: [PATCH] fix: ci --- .../raw_experiments/raw_cache/raw_storage.rs | 2 +- crates/rspack_storage/tests/build.rs | 2 +- crates/rspack_storage/tests/dev.rs | 2 +- crates/rspack_storage/tests/error.rs | 2 +- .../tests/__snapshots__/Defaults.test.js.snap | 2 +- .../defaultsCases/cache/cache-filesystem-dev.js | 3 +++ .../tests/defaultsCases/mode/development.js | 3 +++ .../tests/defaultsCases/mode/production.js | 3 --- .../tests/defaultsCases/mode/undefined.js | 3 --- packages/rspack/src/config/defaults.ts | 13 ++++++++++--- 10 files changed, 21 insertions(+), 14 deletions(-) diff --git a/crates/rspack_binding_options/src/options/raw_experiments/raw_cache/raw_storage.rs b/crates/rspack_binding_options/src/options/raw_experiments/raw_cache/raw_storage.rs index 35e09212ca8..1a5e6afa234 100644 --- a/crates/rspack_binding_options/src/options/raw_experiments/raw_cache/raw_storage.rs +++ b/crates/rspack_binding_options/src/options/raw_experiments/raw_cache/raw_storage.rs @@ -15,7 +15,7 @@ impl From for StorageOptions { "filesystem" => StorageOptions::FileSystem { directory: value.directory.into(), }, - s => panic!("unsupport storage type {s}"), + s => panic!("unsupported storage type {s}"), } } } diff --git a/crates/rspack_storage/tests/build.rs b/crates/rspack_storage/tests/build.rs index 662cdd02b5e..2bd3a5d5e50 100644 --- a/crates/rspack_storage/tests/build.rs +++ b/crates/rspack_storage/tests/build.rs @@ -1,5 +1,4 @@ #[cfg(test)] -#[cfg_attr(miri, ignore)] mod test_storage_dev { use std::{collections::HashMap, path::PathBuf, sync::Arc}; @@ -140,6 +139,7 @@ mod test_storage_dev { } #[tokio::test] + #[cfg_attr(miri, ignore)] async fn test_dev() { let cases = [ ( diff --git a/crates/rspack_storage/tests/dev.rs b/crates/rspack_storage/tests/dev.rs index 74c2afe8240..55868a6dcb3 100644 --- a/crates/rspack_storage/tests/dev.rs +++ b/crates/rspack_storage/tests/dev.rs @@ -1,5 +1,4 @@ #[cfg(test)] -#[cfg_attr(miri, ignore)] mod test_storage_build { use std::{collections::HashMap, path::PathBuf, sync::Arc}; @@ -107,6 +106,7 @@ mod test_storage_build { } #[tokio::test] + #[cfg_attr(miri, ignore)] async fn test_build() { let cases = [ ( diff --git a/crates/rspack_storage/tests/error.rs b/crates/rspack_storage/tests/error.rs index af9e781ac6c..866c1508864 100644 --- a/crates/rspack_storage/tests/error.rs +++ b/crates/rspack_storage/tests/error.rs @@ -1,5 +1,4 @@ #[cfg(test)] -#[cfg_attr(miri, ignore)] mod test_storage_error { use std::{path::PathBuf, sync::Arc}; @@ -155,6 +154,7 @@ mod test_storage_error { } #[tokio::test] + #[cfg_attr(miri, ignore)] async fn test_error() { let cases = [ ( diff --git a/packages/rspack-test-tools/tests/__snapshots__/Defaults.test.js.snap b/packages/rspack-test-tools/tests/__snapshots__/Defaults.test.js.snap index e161cc3aa7a..608114f77a5 100644 --- a/packages/rspack-test-tools/tests/__snapshots__/Defaults.test.js.snap +++ b/packages/rspack-test-tools/tests/__snapshots__/Defaults.test.js.snap @@ -18,7 +18,7 @@ Object { }, experiments: Object { asyncWebAssembly: false, - cache: true, + cache: false, css: undefined, futureDefaults: false, incremental: Object { diff --git a/packages/rspack-test-tools/tests/defaultsCases/cache/cache-filesystem-dev.js b/packages/rspack-test-tools/tests/defaultsCases/cache/cache-filesystem-dev.js index 50f523937b8..d24cb95fb8d 100644 --- a/packages/rspack-test-tools/tests/defaultsCases/cache/cache-filesystem-dev.js +++ b/packages/rspack-test-tools/tests/defaultsCases/cache/cache-filesystem-dev.js @@ -16,6 +16,9 @@ module.exports = { - "devtool": false, + "devtool": "eval", @@ ... @@ + - "cache": false, + + "cache": true, + @@ ... @@ - "mode": "none", + "mode": "development", @@ ... @@ diff --git a/packages/rspack-test-tools/tests/defaultsCases/mode/development.js b/packages/rspack-test-tools/tests/defaultsCases/mode/development.js index e0871cd0693..9760dde289f 100644 --- a/packages/rspack-test-tools/tests/defaultsCases/mode/development.js +++ b/packages/rspack-test-tools/tests/defaultsCases/mode/development.js @@ -14,6 +14,9 @@ module.exports = { - "devtool": false, + "devtool": "eval", @@ ... @@ + - "cache": false, + + "cache": true, + @@ ... @@ - "mode": "none", + "mode": "development", @@ ... @@ diff --git a/packages/rspack-test-tools/tests/defaultsCases/mode/production.js b/packages/rspack-test-tools/tests/defaultsCases/mode/production.js index 9efce72a070..fd598b9fd39 100644 --- a/packages/rspack-test-tools/tests/defaultsCases/mode/production.js +++ b/packages/rspack-test-tools/tests/defaultsCases/mode/production.js @@ -7,9 +7,6 @@ module.exports = { - Expected + Received - @@ ... @@ - - "cache": true, - + "cache": false, @@ ... @@ - "incremental": Object { - "buildChunkGraph": false, diff --git a/packages/rspack-test-tools/tests/defaultsCases/mode/undefined.js b/packages/rspack-test-tools/tests/defaultsCases/mode/undefined.js index cb34e8e3490..94fa2c86262 100644 --- a/packages/rspack-test-tools/tests/defaultsCases/mode/undefined.js +++ b/packages/rspack-test-tools/tests/defaultsCases/mode/undefined.js @@ -7,9 +7,6 @@ module.exports = { - Expected + Received - @@ ... @@ - - "cache": true, - + "cache": false, @@ ... @@ - "incremental": Object { - "buildChunkGraph": false, diff --git a/packages/rspack/src/config/defaults.ts b/packages/rspack/src/config/defaults.ts index 52b0aab34d2..af221c0653a 100644 --- a/packages/rspack/src/config/defaults.ts +++ b/packages/rspack/src/config/defaults.ts @@ -88,7 +88,14 @@ export const applyRspackOptionsDefaults = ( // but Rspack currently does not support this option F(options, "cache", () => development); - applyExperimentsDefaults(options.experiments, { production }); + applyExperimentsDefaults(options.experiments, { + production, + development + }); + + if (options.cache === false) { + options.experiments.cache = false; + } applySnapshotDefaults(options.snapshot, { production }); @@ -194,10 +201,10 @@ const applyInfrastructureLoggingDefaults = ( const applyExperimentsDefaults = ( experiments: ExperimentsNormalized, - { production }: { production: boolean } + { production, development }: { production: boolean; development: boolean } ) => { // IGNORE(experiments.cache): In webpack, cache is undefined by default - F(experiments, "cache", () => !production); + F(experiments, "cache", () => development); D(experiments, "futureDefaults", false); // IGNORE(experiments.lazyCompilation): In webpack, lazyCompilation is undefined by default