framework
framework copied to clipboard
Passing a map as a runtimeConfig entry
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
This feature would really be great. I think module options don't accept Map as well.
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())