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

importing modules inside of ESM package fails #104

Closed
2 tasks done
ksmithut opened this issue Nov 15, 2020 · 4 comments
Closed
2 tasks done

importing modules inside of ESM package fails #104

ksmithut opened this issue Nov 15, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@ksmithut
Copy link

Describe the bug

Importing a module from this package inside of an ESM enabled package results in an Error.

To Reproduce

I have a gist here: https://gist.github.com/ksmithut/d5f787fa0eca67295c5d360054fccf82

  • macOS 11.0.1
  • node 15.2.0

You can clone it and run it:

git clone https://gist.github.com/ksmithut/d5f787fa0eca67295c5d360054fccf82 reproduce
cd reproduce
npm install
npm start

Code to reproduce the behaviour:

{
  "type": "module",
  "dependencies": {
    "jose": "^3.0.1"
  }
}
import generateKeyPair from 'jose/util/generate_key_pair'

Expected behaviour

To import the module in an ESM environment.

Environment:

  • jose version: v3.0.1
  • affected runtime is: Node.js 15.2.0 and Node.js 14.15.0 tested

Additional context

Perhaps if the ESM module files were exported with a .mjs extension it would work as expected? I'm not sure what the right answer is for modules exporting both CJS and ESM.

  • the bug is happening on latest jose too.
  • i have searched the issues tracker on github for similar issues and couldn't find anything related.
@panva
Copy link
Owner

panva commented Nov 15, 2020

sigh, the individual package.json entries in each of the esm namespaces didn't get published ... looking into it.

@panva panva closed this as completed in 7b6364f Nov 15, 2020
@panva panva added bug Something isn't working and removed triage labels Nov 16, 2020
@panva
Copy link
Owner

panva commented Nov 16, 2020

Fixed in v3.0.2

@gcacars
Copy link

gcacars commented Dec 30, 2020

Not fixed. How I can import this module? I can figure out.

import { JWKS } from 'jose';
import generateSecret from 'jose/util/generate_secret';

Unable to resolve path to module...

@panva We could also have an example with how generate HS256 in keysets? like this
I trying this (but module doesn't load... :/
keystore.add(await generateSecret('HS256'));

@panva
Copy link
Owner

panva commented Dec 30, 2020

@gcacars you're mixing up two different major versions. Please refer to the specific version's documentation you want to use. I'm locking this.

Repository owner locked as resolved and limited conversation to collaborators Dec 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants