SimpleModuleLoader currently caches modules by path only, even though ModuleRequest already treats import attributes as part of the request.
That means the same module path can be reused across requests with different attributes.
A concrete case is JSON modules:
- import
data.json with with { type: 'json' }
- import the same
data.json again without attributes
The second import should reject, but it currently succeeds because the first request already put the module in cache and the later lookup ignores attributes.
This looks to come from SimpleModuleLoader::get_with_attributes() and insert_with_attributes() both ignoring the attributes, and the cache lookup happening before the loader checks whether the current request has the right import attributes.
Relevant files:
core/engine/src/module/loader/mod.rs
core/engine/src/module/mod.rs
SimpleModuleLoadercurrently caches modules by path only, even thoughModuleRequestalready treats import attributes as part of the request.That means the same module path can be reused across requests with different attributes.
A concrete case is JSON modules:
data.jsonwithwith { type: 'json' }data.jsonagain without attributesThe second import should reject, but it currently succeeds because the first request already put the module in cache and the later lookup ignores attributes.
This looks to come from
SimpleModuleLoader::get_with_attributes()andinsert_with_attributes()both ignoring the attributes, and the cache lookup happening before the loader checks whether the current request has the right import attributes.Relevant files:
core/engine/src/module/loader/mod.rscore/engine/src/module/mod.rs