1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00
node-red/packages/node_modules/@node-red/editor-client/src/ace
2020-11-05 13:48:55 +00:00
..
bin Disable 'use strict' checking in Function node 2020-11-05 13:48:55 +00:00
mode Disable 'use strict' checking in Function node 2020-11-05 13:48:55 +00:00
README.md Create custom ace javascript mode to handle Function sig 2018-10-02 23:01:34 +01:00

How to build the custom ACE modes for Node-RED

Node-RED includes custom JSONata and JavaScript modes.

JSONata

The ace/mode/jsonata mode is maintained under editor-client/src/vendor/jsonata. Those files are edited in place and copied into the build by Grunt.

JavaScript

The ace/mode/nrjavascript mode is used exclusively by the Function node. It inherits almost entirely from the normal JavaScript mode. The one key difference is that it wraps the code with a Function before parsing. This is required to avoid some false-flagged errors.

The source of the mode is under editor-client/src/ace/mode. If those files are modified in anyway, they must be manually built to generate the files under editor-client/src/ace/bin and checked in. Those files are the ones the Grunt built copies out in the Node-RED build.

Building the mode files

Setup build environment

cd /tmp/
git clone https://github.com/ajaxorg/ace.git
cd ace
npm install

Copy mode src files into build environment

cd <node-red-source-directory
cp packages/node_modules/@node-red/editor-client/src/ace/mode/* \
    /tmp/ace/lib/ace/mode/

Run the build

cd /tmp/ace
node ./Makefile.dryice.js -m -nc

Copy the built versions back

cp build/src-min-noconflict/*-nrjavascript.js \
   <node-red-source-directory>/packages/node_modules/@node-red/editor-client/src/ace/bin/
cp build/src-min-noconflict/snippets/nrjavascript.js \
   <node-red-source-directory>/packages/node_modules/@node-red/editor-client/src/ace/bin/snippets/