Cannot export an object from public to page

Ref: https://support.wix.com/en/article/corvid-javascript-support

The javascript article above provides an example of exporting an object from the public module, but I cannot get it to work.
From the article:

Exporting Objects
You can export an object from a module. For example:

// Filename - public/amodule.js
export let myObject = { 
    prop1: "Here", 
    prop2: "There"       
}

You can then import it and refer to its properties:

import myObject from'public/amodule.js'; 
console.log(myObject.prop1) 
// Logs: "Here"

I reproduced this example exactly, putting the first code snippet in a module public/amodule.js, and the second on an empty page.
What I get is:

TypeError: Cannot read property ‘prop1’ of undefined

Can someone explain how to do this?

Hi Bill,

I was able to reproduce the same issue as you.

It seems the article left out that you should add curly brackets to myObject when importing it.

Try it like this on the page:

import { myObject } from "public/amodule.js";

$w.onReady(function () {
    console.log(myObject.prop1)
});

Hope this helps!

Dara | Corvid Team

Yes, Dara! Thank you for the clarification. I feel foolish that I did not try that. I thought the article implied that the syntax for importing objects was different than importing functions. It is not. I am amazed that this important error has not been discovered and clarified to all users before.

Hey Bill,

I have submitted feedback for the article so hopefully we’ll have that updated soon to avoid any further confusion!

Dara | Corvid Team