Closed crapthings closed 3 years ago
You'd probably want to create a stub react module, that would simply re-export the global React instance. Internally, all react-meteor-data
does is import from the 'react'
node_module. You can probably work this out on your own, without any changes to the internals of react-meteor-data
.
You could use Meteor's "nodeModules" key in package.json to make sure your local package gets picked up for recompilation, and/or use "babel-plugin-transform-imports" to redirect the imports to your local package.
it looks nodeModules in package.json doesn't work with babel plugin
It definitely works. I use it all the time. Here is an example:
"babel": {
"plugins": [
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-do-expressions",
[
"transform-imports",
{
"cloudinary": {
"transform": "cloudinary/lib/cloudinary.js"
},
"@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",
[
"@babel/plugin-transform-react-jsx",
{
"pragma": "h"
}
]
]
},
"meteor": {
"mainModule": {
"client": "client/main.js",
"server": "server/main.js"
},
"nodeModules": {
"recompile": {
"cloudinary": true,
"simpl-schema": "legacy",
"uniforms": true,
"uniforms-material": true
}
}
}
Note: You have to use the recompile setting above for it to work.
for now we use a stub react module just
package.json
{
"name": "react",
"version": "17.0.1",
"main": "index.js"
}
index.js
modules.exports = global.React;
so it doesn't touch ast
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
we're moving react to use cdn version, but react-meteor-data doesn't use global one