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

ExportsFieldPlugin is skipped when dependency is aliased #424

Closed
ataromoku opened this issue Jun 7, 2024 · 4 comments
Closed

ExportsFieldPlugin is skipped when dependency is aliased #424

ataromoku opened this issue Jun 7, 2024 · 4 comments

Comments

@ataromoku
Copy link

Hi,

We encountered an issue where enhanced-resolver doesn't handle the exports field in package.json if the alias is used.


Steps to reproduce

  1. NPM Install enhanced-resolver and @brightspace-ui/lms-context-provider
  2. Excecute the code below
const { CachedInputFileSystem, ResolverFactory } = require("enhanced-resolve");
const path = require('path');
const fs = require('fs');

const myResolver = ResolverFactory.createResolver({
  alias: {
     '@brightspace-ui': path.resolve(__dirname, 'node_modules', '@brightspace-ui'),
  },
  fileSystem: new CachedInputFileSystem(fs, 2000)
});

myResolver.resolve({}, __dirname, '@brightspace-ui/lms-context-provider/client.js', {}, (err, filepath) => {
  if (err) console.error(err);
  else console.log(filepath);
});

Expected

C:\test\webpack-resolver-issue\node_modules\@brightspace-ui\lms-context-provider\src\client\client.js

Actual

details: "resolve '@brightspace-ui/lms-context-provider/client.js' in 'C:\\test\\webpack-resolver-issue'\n" +
    '  Parsed request is a module\n' +
    '  using description file: C:\\test\\webpack-resolver-issue\\package.json (relative path: .)\n' +
    "    aliased with mapping '@brightspace-ui': 'C:\\test\\webpack-resolver-issue\\node_modules\\@brightspace-ui' to 'C:\\test\\webpack-resolver-issue\\node_mo
dules\\@brightspace-ui/lms-context-provider/client.js'\n" +
    '      using description file: C:\\test\\webpack-resolver-issue\\package.json (relative path: .)\n' +
    '        using description file: C:\\test\\webpack-resolver-issue\\node_modules\\@brightspace-ui\\lms-context-provider\\package.json (relative path: ./clien
t.js)\n' +
    '          no extension\n' +
    "            C:\\test\\webpack-resolver-issue\\node_modules\\@brightspace-ui\\lms-context-provider\\client.js doesn't exist\n" +
    '          .js\n' +
    "            C:\\test\\webpack-resolver-issue\\node_modules\\@brightspace-ui\\lms-context-provider\\client.js.js doesn't exist\n" +
    '          .json\n' +
    "            C:\\test\\webpack-resolver-issue\\node_modules\\@brightspace-ui\\lms-context-provider\\client.js.json doesn't exist\n" +
    '          .node\n' +
    "            C:\\test\\webpack-resolver-issue\\node_modules\\@brightspace-ui\\lms-context-provider\\client.js.node doesn't exist\n" +
    '          as directory\n' +
    "            C:\\test\\webpack-resolver-issue\\node_modules\\@brightspace-ui\\lms-context-provider\\client.js doesn't exist"

Notes

If we use the browser field instead of the exports, we get the expected result.

@alexander-akait
Copy link
Member

Intresting...

@vankop
Copy link
Member

vankop commented Jun 11, 2024

@alexander-akait
Copy link
Member

@vankop I think we should fix it

@alexander-akait
Copy link
Member

Let's close this in favor of #413, yeah, the title is different, but it works as exports should work, we don't allow to replace/alias when the exports field is provided, so we can do it only under a new option

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

No branches or pull requests

3 participants