-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Hi, the name uibuilder-react-example is too long for newer versions of uibuilder which limit the url to 20 chars max.
Also, there is now a much better way to incorporate this repo into Node-RED.
- Add a new uibuilder node to your flow, set the URL and deploy.
- Open the Editor config panel and on the Advanced tab, change the "Serve" setting to Dist. The
index.htmlfile in thesrcfolder can be deleted. - Open the Editor config panel and change the Template to External. Then use
gaillarddamien/uibuilder-react-exampleas the template. It will import this repo to the correct folder. - Open a command line on the node-red server, navigate to the folder. Run
npm install.
There are also a couple of things that don't quite work correctly in your repo depending on how node-red and uibuilder are installed:
-
You should change the
dependenciesin your repo todevDependenciesto avoid future issues. -
In package.json,
"node-red-contrib-uibuilder": "file:../../node_modules/node-red-contrib-uibuilder",will not always work. You should use the live package"node-red-contrib-uibuilder": "*",. Even then npm can really screw things up! So if the build can't find the package, you might have to do some tweaking of yournode_modulesfolder. -
In
src/scenes/UserData.js, the path to the old client is wrong. It should be../../node_modules/node-red-contrib-uibuilder/front-end/uibuilderfe. -
Because you are using the "old" front-end client, you need to add the the Socket.IO client to package.json and
importit before you import the client.ALTERNATIVELY, you can use the new client by changing the import to
import uibuilder from '../../node_modules/node-red-contrib-uibuilder/src/front-end-module/uibuilder.module'- however, in that case, although your build works, your dev server fails because I use more modern javascript that Babel cannot understand.You could also import the ESM version of the library:
import uibuilder from '../../node_modules/node-red-contrib-uibuilder/front-end/uibuilder.esm'. That also works with your build but though it doesn't give an error when starting the dev server, it fails to load Socket.IO correctly.So either of the new client builds work fine for node-red itself, they just don't work for the REACT dev server for some reason. It is possible that adding a better JS parser that understands more modern JavaScript might help.