Ideas for Arc XP

Remove autogenerate/rewriting of the eventsHandler module in IFX Node SDK

Is there a reason why the IFX Node SDK auto-writes the eventsHandler module? This functionality has proven to be a bit of a thorn in my side for the following reasons...

  1. It generates code that breaks linting rules I have established. The module.exports object does not end with a semicolon, and the file does not end with a new line. I have to either exclude the file from linting checks, or continually git restore it during development.

  2. It is not compatible with same-folder testing architecture. If I have a defaultHandler.test.js file in the eventsHandlers folder, the eventsHandler.js file is generated with malformed javascript:

const defaultHandler = require('./eventsHandlers/defaultHandler');

const defaultHandler.test = require('./eventsHandlers/defaultHandler.test');
module.exports = { defaultHandler, defaultHandler.test }

In addition, the autogeneration of this particular file is not immediately obvious, so I spent quite some time confused why it kept changing on me. The generated code seems quite simple, so I don't understand what purpose autogenerating it really serves.

  • Lowell Kissling
  • Jul 4 2024
  • Will not implement
IFX
  • Attach files
  • Admin
    Bridgette Gigi commented
    10 Oct 18:27

    Most welcome!

  • Lowell Kissling commented
    10 Oct 17:17

    Hi Bridgette, thank you for the helpful responses. Given the clarification on where tests can live in the codebase, I've decided to simply exclude the file from linting checks. Thank you for looking into this for me, and thanks for the engineering team for the detailed answer.

  • Admin
    Bridgette Gigi commented
    10 Oct 14:49

    I got more information:

    After the script generates the eventHandlers.js file for the first time, they can remove the prelocalTestingServer and postinstall scripts from package.json to prevent overwriting that file. Moving forward, they will just need to add any new handler files to the previously generated file so that the SDK can locate them at runtime.


  • Admin
    Bridgette Gigi commented
    09 Oct 20:21

    I'm not as familiar with this as my engineering team, so I asked them. This was their response:

    You can exclude the file from linting checks. Our SDK structure doesn’t support testing files in the same folder. Users must place their test files in a separate ./test folder at the root of the project. In the future, we may improve this by providing example test files in the starter template.
    And in general, we can work on removing this process, but that will require us time and publish a new SDK version.

    Is this helpful?

  • Lowell Kissling commented
    08 Oct 20:04

    Hi Bridgette, thanks for responding. I am not sure what files you are referring to, could you be more specific?

  • Admin
    Bridgette Gigi commented
    08 Oct 16:00

    Hi Lowell, sorry to hear about this frustration. I will add this to our team's agenda for discussion. Are you aware that you can delete those files and all references to them?