New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: registry importModule function #3984
base: master
Are you sure you want to change the base?
Conversation
80cf63d
to
88d1648
Compare
Use parsedModule.module for modulePath Signed-off-by: inglkruiz <12603425+inglkruiz@users.noreply.github.com>
88d1648
to
04b36e7
Compare
@knolleary Hi, could you review this PR? sorry for bothering you. |
Hi @inglkruiz Sorry for the delay. It wasn't immediately obvious what this PR was fixing, because loading external modules was working fine here. I see now it occurs if you specify a version as part of the module name in the Function node - Once I understood what it was fixing, it was much clearer to review. |
@knolleary Thanks for paying attention to it. I have one more question, the package I'm using |
I forgot to ask, do you think that could work? I understand he's suggesting us to remove |
The problem is ESM is a mess. There is no one-size-fits-all solution if you need to load any module without knowing ahead of time what flavour of ESM/CJS, what settings they may or may not have included in their package.json and a million other bits of incompatibility between the different module types. It's fine if you're writing the code directly, as you can write whatever is needed for the given module. But we have to try to handle everything in Node-RED. The code we have today came as a result of testing lots of different ESM and CJS modules to try to find something that works somewhat consistently for the set of modules we were testing with. Any changes to this code will need testing against lots of different modules to ensure absolutely no changes in behaviour for existing users. My fear is this becomes a case of 'fix it for module A, break it for module B'. |
I understand, the situation is quite cumbersome. If you could list what packages you have tested I think I could try to make it work covering more cases and automating some tests. Just offering some help. |
Proposed changes
Use
parsedModule.module
instead ofmodule
,module
contains the version installed, therefore importing the module results in an error because the folder does not exists innode_modules
. See screenshot.Bug introduced here > #3645
Checklist
grunt
to verify the unit tests pass