-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
ESM imports are failing #253
Comments
There isn’t a named export called fastifyCookie |
import pkg from '@fastify/cookie'; should work |
But that fails TypeScript types. |
For context, |
If you're looking for the equivalent of this import, it would be the following: import fastifyCookie from '@fastify/cookie'; It uses default exports - notice how there aren't curly brackets ( |
Ah, misread the error indicators in VSCode. import fastifyCookie from '@fastify/cookie'; The error is coming from ESLint:
https://github.com/import-js/eslint-plugin-import/blob/v2.28.1/docs/rules/no-named-as-default.md i.e. Looks like ESLint thinks that there is |
I can only assume that this is because of:
which exists inside of the I am not familiar with TypeScript namespaces, so cannot comment whether this is an issue with this package or ESLint rule. |
According to the eslint rule, this is a warning for you as an end user, as it could be that you wanted to use the named import and not the default import. Nothing to do with us. |
But there is no named export. |
Line 214 in 290e559
|
So that takes us to the original issue. import { fastifyCookie } from '...' Does not work |
Please provide a repo |
This was already confirmed to be an issue. |
That will not work if that was the intention. To do an ESM named export, a property of I haven't properly looked at the code but ESLint might be mistakenly thinking that a named export exists while it doesn't. Why do you import it like that anyway? This is the de-facto way of registering plugins/routes: // await is optional *here*
await fastify.register(import("@fastify/cookie"), {
}); |
Prerequisites
Fastify version
N/A
Plugin version
9.0.4
Node.js version
19.9.0
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
13.2.1
Description
Importing in ESM workspace is failing with an error:
Steps to Reproduce
Add
"type": "module"
topackage.json
.Expected Behavior
Should work with ESM imports.
The text was updated successfully, but these errors were encountered: