Skip to content

Conversation

@rschristian
Copy link
Collaborator

Summary

Closes #783

Allows users to customize modern output file name with exports like they can with esmodules.

@changeset-bot
Copy link

changeset-bot bot commented Jan 7, 2021

🦋 Changeset detected

Latest commit: 3ccfefd

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

src/index.js Outdated
);
mainsByFormat.modern = replaceName(
(pkg.syntax && pkg.syntax.esmodules) || pkg.esmodule || 'x.modern.js',
(typeof pkg.exports === 'string' && pkg.exports) ||
Copy link
Owner

Choose a reason for hiding this comment

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

This works for the main case. I'm wondering - maybe we could walk the exports object to find matching import entries?

function walk(exports) { if (typeof exports === 'string') return exports; return walk(exports['.'] || exports.import || exports.module); } walk(pkg.exports) 
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Certainly could. I started to think about this but had reservations on whether or not users would expect all keys (or at least the ones in the spec?) to be supported. If they have a "require", would they then expect a matching output file? Not sure.

rschristian and others added 2 commits January 8, 2021 00:28
Co-authored-by: Jason Miller <developit@users.noreply.github.com>
@developit developit merged commit 86371f0 into developit:master Jun 3, 2021
@preact-bot preact-bot mentioned this pull request Jun 3, 2021
@rschristian rschristian deleted the feat/modernFileName branch June 8, 2021 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants