Code Monkey home page Code Monkey logo

Comments (10)

Robin-Hoodie avatar Robin-Hoodie commented on June 12, 2024 1

Thanks for the input @junderw , I've been able to "resolve" (pun intended) this now

For anyone experiencing the same problem, here's the TLDR:

Jest currently does not support the package.json#exports field (see jestjs/jest#9771). Currently Jest plans to add support for it in v28. In case v28 has been released when you're reading this, I'd try just upgrading Jest and see if that resolves the issue.

If v28 has not been released yet or v28 also does not resolve this issue, you can use the suggestion mentioned here
I've implemented this as follows:

// jest.config.js
module.exports = {
  resolver: "<rootDir>/jest-resolver.js"
  // any other options go here
}

// ./jest-resolver.js
const enhancedResolve = require("enhanced-resolve");

const resolver = enhancedResolve.create.sync({
  conditionNames: ["require", "node", "default", "import"],
  extensions: [".js", ".json", ".node", ".ts"],
});

module.exports = (request, options) => resolver(options.basedir, request);

@junderw As I understood, adding a package.json#main field would also resolve the issue. Is there a specific reason this has not been added? If you just haven't gotten around to it, let me know and I can create a PR for it.

from tiny-secp256k1.

junderw avatar junderw commented on June 12, 2024

This is a jest configuration issue.

Both this package and uint8array-tools are set to use require for node environments and import for browser environments.

Most likely setting your jest environment to node should fix the issue.

from tiny-secp256k1.

junderw avatar junderw commented on June 12, 2024

Jest ESM support is a separate issue. Right now it's bundling the MJS code as a CJS.

from tiny-secp256k1.

junderw avatar junderw commented on June 12, 2024

Or maybe it's a babel issue. Assuming you followed that website directions exactly.

from tiny-secp256k1.

junderw avatar junderw commented on June 12, 2024

I work on a private project that uses ts-jest instead of babel and everything works fine, btw.

from tiny-secp256k1.

Robin-Hoodie avatar Robin-Hoodie commented on June 12, 2024

I've tried running files through the ts-jest transformer now, with the same result.

Let me see if I can create a repro for this

from tiny-secp256k1.

Robin-Hoodie avatar Robin-Hoodie commented on June 12, 2024

@junderw Here's a repro https://github.com/Robin-hoodie/tiny-secp256k1-repro

from tiny-secp256k1.

bufo24 avatar bufo24 commented on June 12, 2024

I am having the same issue

from tiny-secp256k1.

junderw avatar junderw commented on June 12, 2024

This issue is not with this library. We have used the official NodeJS methods for providing cjs backwards compatibility.

Please follow the issue on the jest repository.

from tiny-secp256k1.

junderw avatar junderw commented on June 12, 2024

jestjs/jest#9771 (comment)

Try using a custom resolver.

looks like babel also has the same issue.

from tiny-secp256k1.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.