framework icon indicating copy to clipboard operation
framework copied to clipboard

Passing a map as a runtimeConfig entry

Open msdsk opened this issue 3 years ago • 2 comments

Environment

  • Operating System: Linux
  • Node Version: v17.2.0
  • Nuxt Version: 3.0.0-rc.3
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

in nuxt.config.ts add:

...
  runtimeConfig: {
    public: {
      someMap: new Map()
    }
  },
...

Describe the bug

The map is transformed into an empty object (regardless if the map was empty or not) instead of being passed to the browser as-is.

Additional context

The expected behavior was working in rc1

Logs

No response

msdsk avatar May 18 '22 20:05 msdsk

This feature would really be great. I think module options don't accept Map as well.

wobsoriano avatar May 18 '22 20:05 wobsoriano

Runtime config set in Nuxt config needs to be serialisable. Map is not a valid type for it, and no matter what, won't be passed directly to the browser. It's possible we could accept Map as a type for it in nuxt.config but I think the benefit is very slight, when you could simply do:

runtimeConfig: Object.fromEntries(config.entries())

danielroe avatar Jul 21 '22 15:07 danielroe