Presence of package.json
causes autoload to throw Error: fastify-autoload cannot import plugin
.
#188
Closed
2 tasks done
Prerequisites
Fastify version
3.20.2
Plugin version
3.8.0
Node.js version
16.4.2
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
11.4
Description
There seems to be a logic bug here that assumes
indexDirent
doesn't exist just because apackage.json
is present.fastify-autoload/index.js
Lines 138 to 162 in ce2a45e
I'm working in a TypeScript monorepo and am trying to minimize directory nesting. Loading
__dirname
seemed to work, but when I started to use workspaces and added apackage.json
to myapi/
, the autoloader stopped working.If I understand the intent behind the code, I think it should be this, seeing as we may not have returned on line 154.
Steps to Reproduce
package.json
in a directoryindex.(j|t)s
in that directoryIf you remove the
package.json
it works again.Expected Behavior
The autoloader should not throw if there is an index file and a package file.
Given these files.
The text was updated successfully, but these errors were encountered: