22const {
33 ObjectDefineProperties,
44} = primordials ;
5+ const { hasInspector } = internalBinding ( 'config' ) ;
56const { getOptionValue } = require ( 'internal/options' ) ;
67const { kConstructorKey, Storage } = internalBinding ( 'webstorage' ) ;
78const { getValidatedPath } = require ( 'internal/fs/utils' ) ;
8- const { InspectorLocalStorage, InspectorSessionStorage } = require ( 'internal/inspector/webstorage' ) ;
99const kInMemoryPath = ':memory:' ;
1010
1111module . exports = { Storage } ;
1212
1313let lazyLocalStorage ;
1414let lazySessionStorage ;
15+ let lazyInspectorStorage ;
1516let localStorageWarned = false ;
1617
1718// Check at load time if localStorage file is provided to determine enumerability.
1819// If not provided, localStorage is non-enumerable to avoid breaking {...globalThis}.
1920const localStorageLocation = getOptionValue ( '--localstorage-file' ) ;
21+ const experimentalStorageInspection =
22+ hasInspector && getOptionValue ( '--experimental-storage-inspection' ) ;
23+
24+ function getInspectorStorage ( ) {
25+ if ( lazyInspectorStorage === undefined ) {
26+ lazyInspectorStorage = require ( 'internal/inspector/webstorage' ) ;
27+ }
28+ return lazyInspectorStorage ;
29+ }
2030
2131ObjectDefineProperties ( module . exports , {
2232 __proto__ : null ,
@@ -37,7 +47,8 @@ ObjectDefineProperties(module.exports, {
3747 return undefined ;
3848 }
3949
40- if ( getOptionValue ( '--experimental-storage-inspection' ) ) {
50+ if ( experimentalStorageInspection ) {
51+ const { InspectorLocalStorage } = getInspectorStorage ( ) ;
4152 lazyLocalStorage = new InspectorLocalStorage ( kConstructorKey , getValidatedPath ( localStorageLocation ) , true ) ;
4253 } else {
4354 lazyLocalStorage = new Storage ( kConstructorKey , getValidatedPath ( localStorageLocation ) ) ;
@@ -52,7 +63,8 @@ ObjectDefineProperties(module.exports, {
5263 enumerable : true ,
5364 get ( ) {
5465 if ( lazySessionStorage === undefined ) {
55- if ( getOptionValue ( '--experimental-storage-inspection' ) ) {
66+ if ( experimentalStorageInspection ) {
67+ const { InspectorSessionStorage } = getInspectorStorage ( ) ;
5668 lazySessionStorage = new InspectorSessionStorage ( kConstructorKey , kInMemoryPath , false ) ;
5769 } else {
5870 lazySessionStorage = new Storage ( kConstructorKey , kInMemoryPath ) ;
0 commit comments