Skip to content
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

v5.0.0 issues #1113

Closed
paulrobertlloyd opened this issue Aug 20, 2024 · 6 comments · Fixed by #1115
Closed

v5.0.0 issues #1113

paulrobertlloyd opened this issue Aug 20, 2024 · 6 comments · Fixed by #1115
Labels

Comments

@paulrobertlloyd
Copy link

paulrobertlloyd commented Aug 20, 2024

Describe the bug

Quick to the draw I know, but was coincidently updating dependencies on my project, and noticed the v5.0.0 PR being prepared, and then the package released, so had a go at upgrading. And I’ve spotted 2 issues (these may be down to user error, but I don’t think so).

1. Can’t import the package into an ESM-based project

My project is ESM based, yet I’m getting the following error:

(node:76282) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/paulrobertlloyd/Sites/indiekit/node_modules/keyv/dist/esm/index.js:1
import { defaultSerialize, defaultDeserialize } from '@keyv/serialize';
^^^^^^

SyntaxError: Cannot use import statement outside a module

I know that shipping modules that support CJS and ESM gets super complicated, so not sure if there’s an issue with how the package is set up to support ESM modules or with how I’m importing it into my project?

2. Types (expression is not constructable)

I get the following error raised in my IDE for the Keyv class:

This expression is not constructable.
  Type 'typeof import("/Users/paulrobertlloyd/Sites/indiekit/node_modules/keyv/dist/esm/index")' has no construct signatures.ts(2351)

Perhaps related the above?

How To Reproduce (best to provide workable code or tests!)

I’ve followed the migration instructions, but the errors reported seem separate to any specific implementation.

You can see the changes I made to upgrade to v5.0.0 in this branch: getindiekit/indiekit@main...spike/update-kev-mongo-deps

You should be able to install the project, and then run the following unit test to see the reported error:

npm i
node packages/indiekit/test/index.js

Congrats on the release; hopefully these are quickly solvable launch niggles! 🎉

@keerthana-tw
Copy link

I am facing an issue when used with KeyvAdapter (from @apollo/utils.keyvadapter). After the upgrade, a typescript error started coming as

error TS2345: Argument of type 'Keyv' is not assignable to parameter of type 'Keyv<string, Record<string, unknown>>'.
  Type 'Keyv' is missing the following properties from type 'Keyv<string, Record<string, unknown>>': once, getMaxListeners, rawListeners, listenerCount, and 3 more.
src/services/cache.ts(21,49): error TS2769: No overload matches this call.
  Overload 1 of 2, '(store?: KeyvStoreAdapter | KeyvOptions | Map<any, any> | undefined, options?: Omit<KeyvOptions, "store"> | undefined): Keyv', gave the following error.
    Object literal may only specify known properties, and 'cacheClient' does not exist in type 'KeyvStoreAdapter | KeyvOptions | Map<any, any>'.
  Overload 2 of 2, '(options?: KeyvOptions | undefined): Keyv', gave the following error.
    Object literal may only specify known properties, and 'cacheClient' does not exist in type 'KeyvOptions'.

There was no breaking changes mentioned in the dependency PR. It would be great if someone can point to docs/references where it explains how to update to the current version so that its adaptable

@goto-bus-stop
Copy link

@keerthana-tw apollo's KeyvAdapter is not updated to support Keyv v5 yet. It's not a problem in Keyv v5. I filed an issue for apollo-utils to upgrade.

@jaredwray
Copy link
Owner

Describe the bug

Quick to the draw I know, but was coincidently updating dependencies on my project, and noticed the v5.0.0 PR being prepared, and then the package released, so had a go at upgrading. And I’ve spotted 2 issues (these may be down to user error, but I don’t think so).

1. Can’t import the package into an ESM-based project

My project is ESM based, yet I’m getting the following error:

(node:76282) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/paulrobertlloyd/Sites/indiekit/node_modules/keyv/dist/esm/index.js:1
import { defaultSerialize, defaultDeserialize } from '@keyv/serialize';
^^^^^^

SyntaxError: Cannot use import statement outside a module

I know that shipping modules that support CJS and ESM gets super complicated, so not sure if there’s an issue with how the package is set up to support ESM modules or with how I’m importing it into my project?

2. Types (expression is not constructable)

I get the following error raised in my IDE for the Keyv class:

This expression is not constructable.
  Type 'typeof import("/Users/paulrobertlloyd/Sites/indiekit/node_modules/keyv/dist/esm/index")' has no construct signatures.ts(2351)

Perhaps related the above?

How To Reproduce (best to provide workable code or tests!)

I’ve followed the migration instructions, but the errors reported seem separate to any specific implementation.

You can see the changes I made to upgrade to v5.0.0 in this branch: getindiekit/[email protected]/update-kev-mongo-deps

You should be able to install the project, and then run the following unit test to see the reported error:

npm i
node packages/indiekit/test/index.js

Congrats on the release; hopefully these are quickly solvable launch niggles! 🎉

@paulrobertlloyd - thanks and we are looking at this now.

@jaredwray
Copy link
Owner

#1115 is up to resolve ESM issues

@jaredwray
Copy link
Owner

@paulrobertlloyd - can you validate that 5.0.1 solves the issue?

@paulrobertlloyd
Copy link
Author

@jaredwray It does! Thanks for quickly resolving these 2 issues 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants