sys.localStorage crashes native builds. v3.6.1

Hello i am trying to make a native build for Mac OS. When i do this the editor logs a lot of errors:

I know it happens only if i have a reference to sys.localStorage in any class which is exported as const.

When i remove sys.localStorage from my code the editor makes a build without errors.

So here an example:

Screen Shot 2022-11-06 at 18.59.17

Screen Shot 2022-11-06 at 18.59.48

MainEnums.ts has only one line:
export const test = new Test()

Test.ts:

import {sys} from 'cc'

export class Test {
    constructor() {
        sys.localStorage.removeItem('test')
        const item = sys.localStorage.getItem('test')
        sys.localStorage.setItem('test', "null")
    }
}

Update:

Any component must import a class or a namespace where is an exported class value which calls sys.localStorage in a constructor.

The problem also happens in web build. But the web and simulator preview work fine.

Here is a demo project. Just open it and try to make a build.
NewProject.zip (15.9 KB)

I am also facing this

This issue has been recorded and can be followed up here : script missing or invalid when use sys.localStorage · Issue #13308 · cocos/cocos-engine · GitHub, thanks for the feedback.