diff --git a/crates/rspack_binding_values/src/raw_options/raw_module/mod.rs b/crates/rspack_binding_values/src/raw_options/raw_module/mod.rs index 8697622ac733..f63faa257142 100644 --- a/crates/rspack_binding_values/src/raw_options/raw_module/mod.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_module/mod.rs @@ -435,7 +435,7 @@ impl From for CssModuleParserOptions { #[derive(Debug, Default)] #[napi(object)] pub struct RawJsonParserOptions { - pub exports_depth: Option, + pub exports_depth: Option, } impl From for JsonParserOptions { diff --git a/crates/rspack_core/src/options/module.rs b/crates/rspack_core/src/options/module.rs index 5ac9e43ef947..05137ca4b1d9 100644 --- a/crates/rspack_core/src/options/module.rs +++ b/crates/rspack_core/src/options/module.rs @@ -292,7 +292,7 @@ pub struct CssModuleParserOptions { #[cacheable] #[derive(Debug, Clone, MergeFrom)] pub struct JsonParserOptions { - pub exports_depth: Option, + pub exports_depth: Option, } #[derive(Debug)] diff --git a/crates/rspack_plugin_json/src/json_exports_dependency.rs b/crates/rspack_plugin_json/src/json_exports_dependency.rs index 12c469fc45bc..69130b2aed7e 100644 --- a/crates/rspack_plugin_json/src/json_exports_dependency.rs +++ b/crates/rspack_plugin_json/src/json_exports_dependency.rs @@ -13,11 +13,11 @@ pub struct JsonExportsDependency { id: DependencyId, #[cacheable(with=AsPreset)] data: JsonValue, - exports_depth: f64, + exports_depth: u32, } impl JsonExportsDependency { - pub fn new(data: JsonValue, exports_depth: f64) -> Self { + pub fn new(data: JsonValue, exports_depth: u32) -> Self { Self { data, id: DependencyId::new(), @@ -33,9 +33,8 @@ impl Dependency for JsonExportsDependency { } fn get_exports(&self, _mg: &ModuleGraph) -> Option { - let exports_depth: u64 = self.exports_depth as u64; Some(ExportsSpec { - exports: get_exports_from_data(&self.data, exports_depth, 1) + exports: get_exports_from_data(&self.data, self.exports_depth, 1) .unwrap_or(ExportsOfExportsSpec::Null), ..Default::default() }) @@ -74,8 +73,8 @@ impl DependencyTemplate for JsonExportsDependency { fn get_exports_from_data( data: &JsonValue, - exports_depth: u64, - cur_depth: u64, + exports_depth: u32, + cur_depth: u32, ) -> Option { if cur_depth > exports_depth { return None; diff --git a/crates/rspack_plugin_json/src/lib.rs b/crates/rspack_plugin_json/src/lib.rs index a611a5a7a396..3b2408b2a4cf 100644 --- a/crates/rspack_plugin_json/src/lib.rs +++ b/crates/rspack_plugin_json/src/lib.rs @@ -33,7 +33,7 @@ mod utils; #[cacheable] #[derive(Debug)] struct JsonParserAndGenerator { - pub exports_depth: f64, + pub exports_depth: u32, } #[cacheable_dyn] 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 ad6651bc3b20..ef0e2e2c85c8 100644 --- a/packages/rspack-test-tools/tests/__snapshots__/Defaults.test.js.snap +++ b/packages/rspack-test-tools/tests/__snapshots__/Defaults.test.js.snap @@ -193,7 +193,7 @@ Object { wrappedContextRegExp: /\\.\\*/, }, json: Object { - exportsDepth: Infinity, + exportsDepth: 9007199254740991, }, }, rules: Array [], 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 e94d0cf2f4e6..27093d67420f 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 @@ -22,7 +22,7 @@ module.exports = { - "mode": "none", + "mode": "development", @@ ... @@ - - "exportsDepth": Infinity, + - "exportsDepth": 9007199254740991, + "exportsDepth": 1, @@ ... @@ - "chunkIds": "natural", diff --git a/packages/rspack-test-tools/tests/defaultsCases/mode/development.js b/packages/rspack-test-tools/tests/defaultsCases/mode/development.js index fb22531773f6..7095b8a29133 100644 --- a/packages/rspack-test-tools/tests/defaultsCases/mode/development.js +++ b/packages/rspack-test-tools/tests/defaultsCases/mode/development.js @@ -20,7 +20,7 @@ module.exports = { - "mode": "none", + "mode": "development", @@ ... @@ - - "exportsDepth": Infinity, + - "exportsDepth": 9007199254740991, + "exportsDepth": 1, @@ ... @@ - "chunkIds": "natural", diff --git a/tests/webpack-test/configCases/json/bailout-flag-dep-export-perf/webpack.config.js b/tests/webpack-test/configCases/json/bailout-flag-dep-export-perf/webpack.config.js index 9b83c43996c6..5b899783606f 100644 --- a/tests/webpack-test/configCases/json/bailout-flag-dep-export-perf/webpack.config.js +++ b/tests/webpack-test/configCases/json/bailout-flag-dep-export-perf/webpack.config.js @@ -4,7 +4,7 @@ module.exports = { module: { parser: { json: { - exportsDepth: Infinity + exportsDepth: Number.MAX_SAFE_INTEGER } } }