Hi, I am following the directions from the docs ( Building Custom JavaScript Components | PowerShell Universal ). I had to make a few changes to get it to work as I outlined below. I started this as I have been trying to replicate the UniversalDashbaord.QueryBuilder from PSDevUK. I need to expand on it, but it never works (typically the Minified 31 error - as well as Resulting JSON is truncated as serialization has exceeded the set depth of 2 if i’m trying to add the component after page load).
With following the docs, I get a different error. That error is Minified React error #130. Any help or direction would be appreciated.
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
Index.js:
Changed the name it’s registering as I did not know if “udcomponent” would conflict with another component, even with the assetID being passed.
UniversalDashboard.register("uddocexample", UDComponent)
Webpack.config.js:
The isDev constant does not work, it’s not reading the env variable correctly. env is being passed as an object. This also means in the return section, the mode isn’t being read as production.
The other part is the rules for js|jsx files. I had to define the preset options in here as it doesn’t seem to read from the .babelrc file.
const isDev = env.development ? true : false;
const expMode = env.production ? 'production' : 'development';
return {
mode: expMode,
...
module: {
rules: [{
test: /\.(js|jsx)$/,
exclude: [/node_modules/, /output/],
use: {
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
'@babel/preset-react'
]
}
}
},
...
}