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: import/order named not working with spread operator #3146

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

UnderKoen
Copy link

Fixes #3145

Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.17%. Comparing base (341178d) to head (7db7e10).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3146      +/-   ##
==========================================
- Coverage   95.59%   95.17%   -0.42%     
==========================================
  Files          83       83              
  Lines        3629     3630       +1     
  Branches     1282     1283       +1     
==========================================
- Hits         3469     3455      -14     
- Misses        160      175      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ljharb
Copy link
Member

ljharb commented Jan 17, 2025

We should only do this if node's cjs-module-lexer also recognizes it. Let's discuss in the issue.

Comment on lines +3652 to +3668
test({
options: [
{
named: true,
},
],
code: `
const test = {
a: 1,
browser: 2,
};

module.exports = {
...test,
platform: 'node',
};
`,
Copy link
Member

Choose a reason for hiding this comment

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

i'd like to also include a test that demonstrates that we only recognize platform as a named export from this file.

Copy link
Author

Choose a reason for hiding this comment

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

Im not that familiar with this codebase. How could I test this?

Copy link
Member

Choose a reason for hiding this comment

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

you'd want to make a fixture file with this test code in it, and then make two test cases that import this test file - one that imports platform and works, and one that imports a and/or browser and fails.

Copy link
Author

Choose a reason for hiding this comment

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

Im very sorry but can't figure it out. I added the cases but it doesn't fail? I suspect that I'm doing something wrong but cant figure out what.

Copy link
Member

Choose a reason for hiding this comment

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

Can you push up what you have? I'll take a look.

Copy link
Author

Choose a reason for hiding this comment

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

I tried looking at #3032 as it had fixture files I believe

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

Successfully merging this pull request may close these issues.

import/order with named fails when exporting uses spread operator.
2 participants