Closed coreyfarrell closed 4 years ago
Would you like to send a Pull Request to address this issue? Remember to add unit tests.
I've just tested this and I am not able to reproduce it. Can you provide a full repro repo?
I had to use this in order to set the root folder for fastify-static
:
fastify.register(fastifyStatic, {
root: join(dirname(fileURLToPath(import.meta.url)), "static"),
});
Ok I found the line that throws in ESM contexts: https://github.com/fastify/fastify-plugin/blob/master/plugin.js#L89
💥 Regression Report
Loading plugins which use
fastify-plugin
produces a warning message when running a native ES module program.Last working version
Worked up to version: 2.0.2
Stopped working in version: 2.0.3
To Reproduce
Steps to reproduce the behavior:
Install latest fastify and fastify-static, run the following script.mjs (tested in Node.js 14.8.0):
Expected behavior
fastify-static should validate the expected version of fastify is installed, nothing should display. Instead it prints:
Adding a printout of the exception shows
TypeError: Cannot read property 'filename' of undefined
.Your Environment