Closed eric-burel closed 2 years ago
Reproduction in Vulcan core repo:
vulcan:ui-material
( and comment bootstrap)/backoffice
=> SSR fails because MenuIcon is an empty object instead of being a componentConcerned file is packages/vulcan-ui-material/lib/components/backoffice/BackofficeNavbar.jsx
, the failing import is the MenuIcon
Potential solution proposed by @captainn here:
Use a config similar to this, with babel-plugin-transform-imports
{
"meteor": {
"mainModule": {
"client": "client/main.jsx",
"server": "server/main.ts"
},
"testModule": "tests/main.ts",
"nodeModules": {
"recompile": {
"simpl-schema": "legacy",
"uniforms": true,
"uniforms-material": true
}
}
},
"babel": {
"plugins": [
[
"transform-imports",
{
"@material-ui/core": {
"transform": "@material-ui/core/${member}",
"preventFullImport": true
},
"@material-ui/icons": {
"transform": "@material-ui/icons/${member}",
"preventFullImport": true
},
"@material-ui/styles": {
"transform": "@material-ui/styles/${member}",
"preventFullImport": true
},
"uniforms": {
"transform": "uniforms/src/${member}",
"preventFullImport": true
},
"uniforms-material": {
"transform": "uniforms-material/src/${member}",
"preventFullImport": true
}
}
],
"lodash",
"npdev-react-loadable-babel"
]
}
}
@benjamn Would you graciously take a look at this long-standing issue with Meteor module loader?
Just for the record we have since migrated toward Next.js (https://vulcan-next.vercel.app/) and we have recently managed to mimick Meteor package architecture with NPM packages and Tsup (https://github.com/VulcanJS/npm-the-right-way/tree/main/my-package-tsup) but maybe this ticket could help detecting/fixing issues in Meteor. Let me know if you need help to reproduce.
Opened a new Meteor issue with reproduction: https://github.com/meteor/meteor/issues/11900
Mystery solved : this bug affect specifically dev dependencies, and Material UI is a dev dependency in the Vulcan app 🎉 Now we simply need to wait for a fix in Meteor, see linked issue
Issue has been seen there:
https://github.com/meteor/meteor/issues/10065 https://forums.meteor.com/t/importing-from-npm-returns-an-empty-object/44491 https://github.com/thereactivestack-legacy/meteor-webpack/issues/235 https://stackoverflow.com/questions/55382092/importing-gitlab-package-from-meteorjs-returns-empty-object https://forums.meteor.com/t/solved-require-import-npm-require-all-return-empty-object/50153/6 https://ethereum.stackexchange.com/questions/60335/web3-empty-object-server-side-in-meteor
The issue seems to appear eratically at different point in time, and different Meteor versions.
Had this issue when coding the automated backoffice, for material-ui icons and no-ssr. To be investigated.