Frontmatter
| tagName | 9.5.0 |
| name | examples.serverside.gridContainer |
| publishedAt | 5/25/2025, 7:08:51 PM |
| isPrerelease | |
| isDraft |
examples.serverside.gridContainer
- Added a new example to fully load a grid container configuration per remote
- Added
container.Base: loadItems()with support for all environments
Online Demos: https://neomjs.com/dist/production/examples/serverside/gridContainer/ https://neomjs.com/examples/serverside/gridContainer/
Most important files: https://github.com/neomjs/neo/blob/dev/examples/serverside/gridContainer/Viewport.mjs https://github.com/neomjs/neo/blob/dev/examples/serverside/gridContainer/resources/data/grid-container.json
The JSON file contains:
{
"modules": [
"src/grid/Container.mjs"
],
"items": [/**/]
}
This does get consumed by:
async loadItems(url) {
let response = await fetch(url),
remoteData = await response.json();
if (remoteData.modules?.length > 0) {
await Promise.all(remoteData.modules.map(modulePath => {
// Adjust relative URLs
if (!modulePath.startsWith('http')) {
modulePath = (Neo.config.environment === 'development' ? '../../' : '../../../../') + modulePath
}
return import(/* webpackIgnore: true */ modulePath)
}))
}
return remoteData.items
}
Meaning:
- Devs need to specify related modules which have to be there.
- This works perfectly fine the the development mode
- For
dist/production, it is impossible to let Webpack bundle the dynamic modules, since it could be anything. - Neo.mjs provides the ability to run multiple environments inside the same app, which comes to the rescue => We can and have to combine the
developmentanddist/productionenvironments for this specific use case.
Feedback from Google Gemini: