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

Fix exports walk (#852) #853

Merged
merged 3 commits into from
Oct 6, 2021
Merged

Fix exports walk (#852) #853

merged 3 commits into from
Oct 6, 2021

Conversation

developit
Copy link
Owner

Fixes #852

@changeset-bot
Copy link

changeset-bot bot commented Jun 12, 2021

🦋 Changeset detected

Latest commit: 9a9b45c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
microbundle Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Collaborator

@rschristian rschristian left a comment

Choose a reason for hiding this comment

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

This does start to make me worry that #784 was a bad idea, due to the amount of possible combinations that we can't reasonably cover, requiring users to fix filenames on their end.

src/index.js Outdated
@@ -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);

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);

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
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
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.

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... 🙇

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.

@developit developit merged commit 5e93a0e into master Oct 6, 2021
@developit developit deleted the fix-exports-walk-fail branch October 6, 2021 13:59
@preact-bot preact-bot mentioned this pull request Oct 6, 2021
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

Successfully merging this pull request may close these issues.

Error while walking package exports
4 participants