Giter VIP home page Giter VIP logo

Comments (13)

k-g-a avatar k-g-a commented on August 19, 2024

Thanks for the issue! Did not think of it, because we do export package.json's from our own packages. I'll fix it withing a day.

from jest-node-exports-resolver.

piranna avatar piranna commented on August 19, 2024

Great, thanks :-D

from jest-node-exports-resolver.

k-g-a avatar k-g-a commented on August 19, 2024

It's actually not so easy to fix :) using require.resolve(PACKAGE_NAME) directly against a package with no "main" field specified (i.e. @babel/runtime) results in ERR_PACKAGE_PATH_NOT_EXPORTED error. So I'm going to combine both approaches. Could you please reference the package you're getting in trouble with so I could test solutions with it?

from jest-node-exports-resolver.

piranna avatar piranna commented on August 19, 2024

It's actually not so easy to fix :) using require.resolve(PACKAGE_NAME) directly against a package with no "main" field specified (i.e. @babel/runtime) results in ERR_PACKAGE_PATH_NOT_EXPORTED error.

Looks strange, specially since require() uses require.resolve() internally...

Could you please reference the package you're getting in trouble with so I could test solutions with it?

It's currently a private one, but I can give you access to it.

from jest-node-exports-resolver.

k-g-a avatar k-g-a commented on August 19, 2024

Just released v1.0.3 with fallback to require.resolve() in case of non-exported package.json, could you please check if the problem is fixed?

from jest-node-exports-resolver.

k-g-a avatar k-g-a commented on August 19, 2024

Closing for now. Feel free to reopen if problem isn't fixed for your setup.

from jest-node-exports-resolver.

piranna avatar piranna commented on August 19, 2024

Hi @k-g-a, it seems at least for jest internal resolution of environment setup is not working. Must to admit, it's NOT the same use case I faced before, I'll try it later.

Could not retrieve package.json neither through require (package.json itself is not within "exports" field), nor through require.resolve (package.json does not specify "main" field) - falling back to default resolver logic
Failed to find package.json for @mafalda/mafalda-api
 Validation Error:

  Module @mafalda/mafalda-api/expect in the setupFilesAfterEnv option was not found.
         <rootDir> is: /home/piranna/github/Mafalda/Mafalda

  Configuration Documentation:
  https://jestjs.io/docs/configuration

from jest-node-exports-resolver.

k-g-a avatar k-g-a commented on August 19, 2024

Hi!
Could you please try to replace requestPath with plain incoming request in findMainPackageJson(requestPath, packageName) at 57 line? If it works, I'll publish it as a fix.

But it's quite strange you face that error, because './package.json' is exported from your mafalda/mafalda-api pakcage.json's exports, so packageJson = require(${packageName}/package.json); should do it's work.

from jest-node-exports-resolver.

piranna avatar piranna commented on August 19, 2024

With package.json entry it works, and both without it I get in latest published version or with your proposed change this error:

Could not retrieve package.json neither through require (package.json itself is not within "exports" field), nor through require.resolve (package.json does not specify "main" field) - falling back to default resolver logic

from jest-node-exports-resolver.

k-g-a avatar k-g-a commented on August 19, 2024

As far as I get it: everything works as expected if the package.json is exported, but neither 1.0.0 nor 1.0.3 work if not?

from jest-node-exports-resolver.

piranna avatar piranna commented on August 19, 2024

Yes, that's it.

from jest-node-exports-resolver.

piranna avatar piranna commented on August 19, 2024

With latest version, I can't import https://github.com/Mafalda-SFU/FsSet too without adding the package.json entry.

(Yes, ./ entry should be ., I have it already fixed)

from jest-node-exports-resolver.

piranna avatar piranna commented on August 19, 2024

This also fails when the value of exports field is a string instead of a mapping object.

from jest-node-exports-resolver.

Related Issues (11)

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.