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

asar-node does not work with package.json exports field #5

Open
RhodeHummel opened this issue Jul 7, 2022 · 2 comments
Open

asar-node does not work with package.json exports field #5

RhodeHummel opened this issue Jul 7, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@RhodeHummel
Copy link

When trying to import a module defined in a package.json exports field asar-node fails to find the module.

Example:

// throws Error: Cannot find module '@my-package/server-code'
const serverCode = require('@my-package/server-code');

package.json

{
   "main": "dist/default.js",
   "exports": {
      ".": "./dist/default.js",
      "./server-code": "./dist/server-code.js"
   }
}

See: https://nodejs.org/api/modules.html#all-together

@toyobayashi toyobayashi added the enhancement New feature or request label Jul 9, 2022
@toyobayashi
Copy link
Owner

I will look into how to implement it when I get some time.

asar-node/lib/module.js

Lines 221 to 224 in 571dcad

// if (!absoluteRequest) {
// const exportsResolved = resolveExports(curPath, request)
// if (exportsResolved) { return exportsResolved }
// }

@toyobayashi
Copy link
Owner

I'm sorry to say, it seems so complicated (out of my ability now) to reimplement Node.js official resolution algorithm in asar-node. PR that add basic support to this feature is welcome.

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

No branches or pull requests

2 participants