From 4903ef4d863a8fd020ea53f075419d4f5a4667e8 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Wed, 10 Apr 2024 19:51:07 -0700 Subject: [PATCH] Flag the whole json module behind the json feature --- core/interop/src/modules/json.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/interop/src/modules/json.rs b/core/interop/src/modules/json.rs index 09779f56fe9..7a398d40268 100644 --- a/core/interop/src/modules/json.rs +++ b/core/interop/src/modules/json.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "json")] //! Functions to create [`Module`]s that expose JSON data directly //! as the default export. #![allow(clippy::module_name_repetitions)] @@ -9,7 +10,6 @@ use boa_engine::{js_string, Context, JsValue, Module}; /// /// # Errors /// This will return an error if the JSON string is invalid or cannot be converted. -#[cfg(feature = "json")] pub fn json_string_module(json: &str, context: &mut Context) -> boa_engine::JsResult { let json_value = serde_json::from_str::(json).map_err(|e| { boa_engine::JsError::from_opaque(js_string!(format!("Failed to parse JSON: {}", e)).into()) @@ -18,7 +18,6 @@ pub fn json_string_module(json: &str, context: &mut Context) -> boa_engine::JsRe Ok(Module::from_value_as_default(value, context)) } -#[cfg(feature = "json")] #[test] fn test_json_module_from_str() { use crate::loaders::HashMapModuleLoader;