Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Reorder exports map #2148

Merged
merged 1 commit into from
Jan 31, 2022
Merged

Reorder exports map #2148

merged 1 commit into from
Jan 31, 2022

Conversation

heathernfran
Copy link
Contributor

@heathernfran heathernfran commented Jan 31, 2022

Description

https://github.com/Shopify/web/issues/56636

Webpack 5 can resolve exports from package.json. Reordering the exports map ensures that when libraries ship with only commonjs, esm compiling will take precedence.

Type of change

  • Patch: Bug (non-breaking change which fixes an issue)

Checklist

  • I have added a changelog entry, prefixed by the type of change noted above (Documentation fix and Test update does not need a changelog as we do not publish new version)

@heathernfran heathernfran marked this pull request as ready for review January 31, 2022 19:15
@heathernfran heathernfran requested a review from a team as a code owner January 31, 2022 19:15
@heathernfran heathernfran requested review from vsumner and a team January 31, 2022 19:15
Copy link
Collaborator

@vsumner vsumner left a comment

Choose a reason for hiding this comment

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

Love the tests!

Copy link
Member

@BPScott BPScott left a comment

Choose a reason for hiding this comment

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

Changes to package.json files look good. I think this needs a rebase and an adjustment of the changelogs as @vsumner has done a release this morning.

The tests doesn't seem like they're testing what we'd hope, see inline comments

packages/koa-shopify-webhooks/CHANGELOG.md Show resolved Hide resolved
});

it('specifies esnext as the first expected export', () => {
expect(packageJSON.exports['.'].esnext).toBe(
Copy link
Member

@BPScott BPScott Jan 31, 2022

Choose a reason for hiding this comment

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

This seems like it asserts the value of a specific key instead of anything to do with the ordering. It also seems to only check the . export key rather than all keys.

I would expect that something like the following would cause this test to fail, but right now I think this would pass.

exports: {
  "./foo" : { 'require': './foo.js', esnext: './foo.esnext' }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this test is no longer needed, since the other test now includes checking that esnext is first.

@@ -139,6 +139,18 @@ packages.forEach(
it('specifies the expected types', () => {
expect(packageJSON.types).toBe(expectedPackageJSON.types);
});

it('specifies the expected exports', () => {
Copy link
Member

Choose a reason for hiding this comment

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

It is possible for packages to have an exports key that does not contain "." - e.g. graphql-persisted, so I don't think this test is correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, updated the test to check for ordered keys in exports map 👍

Copy link
Contributor

@dahukish dahukish left a comment

Choose a reason for hiding this comment

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

Thanks for this @heathernfran. Just need to address @BPScott testing comments.

@@ -9,6 +9,7 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

### Changed

- Reorder exports map to prioritize the `esnext` condition. [[#2148](https://github.com/Shopify/quilt/pull/2148)]
- Clean test output. [[#2091](https://github.com/Shopify/quilt/pull/2091)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This hasn't been released, right?

Copy link
Member

Choose a reason for hiding this comment

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

Looks like it hasn't - the last change was just in test files, which are ignored when determining what to release

Comment on lines 12 to +13
- Updated puppeteer to 13.1.3 ([#2149](https://github.com/Shopify/quilt/pull/2149))
- Reorder exports map to prioritize the `esnext` condition. [[#2148](https://github.com/Shopify/quilt/pull/2148)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix from earlier merge conflict

@@ -139,6 +139,18 @@ packages.forEach(
it('specifies the expected types', () => {
expect(packageJSON.types).toBe(expectedPackageJSON.types);
});

it('specifies esnext, import, and require as the ordered keys in the exports map', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

Copy link
Contributor

@dahukish dahukish left a comment

Choose a reason for hiding this comment

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

:shipit:

Copy link
Member

@BPScott BPScott left a comment

Choose a reason for hiding this comment

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

Fantastic!

@heathernfran heathernfran merged commit 8b3eefc into main Jan 31, 2022
@heathernfran heathernfran deleted the exports-fields branch January 31, 2022 23:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants