Description
Version
v16.14.0
Platform
Linux xxXxx 5.13.0-30-generic #33-Ubuntu SMP Fri Feb 4 17:03:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
I'm the main author of Scully.
In our @next
version we switched completely to ESM modules. I have an internal register of plugins.
Up to version 16.4.0, our code works as expected.
After that, I'm erroring out on plugins that are not 'found'. This seems to happen because I get a new copy of the plugin registry.
That would only be possible as somehow the module loading imports the same thing twice.
It does not happen when I don't use the --experimental-specifier-resolution=node
option.
However, as I have to load a piece of code dynamically, I do need that option. I have no control over the code I need to load, and it is importing without specifying the extension.
So, if I leave off the option, and I try to load the dynamic code I'm getting a load of Error [ERR_MODULE_NOT_FOUND]: Cannot find module
errors.
A workaround could be if I can somehow tell NodeJs that the dynamic code is ESM, and is available with the .js
extension.
There is already a package.json in the dynamic folder that has {type: "module"}
So, I'm unsure what exactly triggered this change in behavior between node 16.13.2 and 16.14.0(and later, the latest 17 has the same issue), But I would love a way so I can work around this.
Its going to be time-consuming to create an simple replication out of this, so I hope I can get some guidance here.
How often does it reproduce? Is there a required condition?
every time I run the program with >16.14.0
What is the expected behavior?
For my programs to work as before.
What do you see instead?
The error my program shows is there because we handle error conditions, and doesn't add anything to this issue.
Before 16.14:
After:
Additional information
No response