Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix exports walk (#852)
Fixes #852
  • Loading branch information
developit authored Jun 12, 2021
commit 585e77d719a9862fbfdfeee641b7e83bcf04c18f
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ function replaceName(filename, name) {
}

function walk(exports) {
if (!exports) return null;
if (typeof exports === 'string') return exports;
return walk(exports['.'] || exports.import || exports.module);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I found a regression when declaring modern exports using default conditional export, such as:

"exports": {
    ".": {
      "import": "dist/index.js",
      "require": "dist/index.cjs",
      "default": "dist/index.modern.js"
    }
  }

The modern module is not being generated in version >= 0.13.2 while it is being generated in v0.13.1. Probably, we can also add exports.default inside the walk recursion method. wdyt @developit ? 🙇

Suggested change
return walk(exports['.'] || exports.import || exports.module);
return walk(exports['.'] || exports.import || exports.module || exports.default);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any update regarding this fix? 🙇

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jeffryang24 - no update, just haven't gotten around to it yet.

Copy link
Copy Markdown
Owner Author

@developit developit Jul 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could add .default as you suggest, but really this needs to also be checking the extension based on pkg.type, otherwise it will potentially return a CommonJS entry filename for the modern filename.

I have a fairly large overhaul of this logic that uses a complete Package Exports implementation to determine names, but I haven't had a chance to get tests passing for it yet.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see... got it... Currently, I've reverted back to 0.13.1 to fix this regression issue. Thanks for your explanation... 🙇

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeffryang24 thanks, I also reverted to 0.13.1 and that makes it work for me for the moment.

}
Expand Down