question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

import/export - Multiple exports triggered when duplication isn't relevant

See original GitHub issue

I get the error Multiple exports of name 'List' from both lines of components/pages/index.js in following example:

// components/pages/index.js
export * as Messages from "./messages";
export * as Users from "./users";

// components/pages/messages/index.js
export List from "./list";
export Show from "./show";

// components/pages/users/index.js
export Edit from "./edit";
export List from "./list";

// components/pages/messages/list.js => React Component
// components/pages/messages/show.js => React Component
// components/pages/users/edit.js => React Component
// components/pages/users/list.js => React Component

I understand that if I get it once, I’ll get it twice, but I don’t think it should be happening at all. The code itself works when I access my components (Pages.Users.List) leading me to believe this is a bug in the rule. I also made sure to update to the latest version (2.20.1) before submitting this

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:18 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
tompratscommented, Aug 21, 2020

I started to attempt a fix today and ran into an issue with the current ecmaVersion being too old for the syntax. But after I updated that, I found out the issue has already been fixed! Potentially here. Below is a test specifically for it that I can add, but I don’t know if there are any further repercussions for updating the ecmaVersion

--- a/tests/src/rules/export.js
+++ b/tests/src/rules/export.js
@@ -35,6 +35,12 @@ ruleTester.run('export', rule, {
         export { A, B };
       `,
     }),
+    test({
+      code: `
+        export * as A from './named-export-collision/a';
+        export * as B from './named-export-collision/b';
+      `,
+    }),
   ],

   invalid: [
diff --git a/tests/src/utils.js b/tests/src/utils.js
index 0f45e7b..0892482 100644
--- a/tests/src/utils.js
+++ b/tests/src/utils.js
@@ -37,7 +37,7 @@ export function test(t) {
   }, t, {
     parserOptions: Object.assign({
       sourceType: 'module',
-      ecmaVersion: 9,
+      ecmaVersion: 11,
     }, t.parserOptions),
   })
 }

Long story short, this is fixed on version 2.22.0. Thanks @ljharb!

1reaction
danrivettcommented, Jun 20, 2020

Also ran into this issue with the following code:

export * as WorkerPhoneCreated from './phone/created';
export * as WorkerPhoneUpdated from './phone/updated';

Both the following imported files contain an EventType export, and should be referenced as WorkerPhoneCreated.EventType and WorkerPhoneUpdated.EventType respectively and so I think this “multiple exports” error is a false positive if I’ve understood correctly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple exports triggered when duplication isn't relevant ...
I get the error Multiple exports of name 'List' from both lines of components/pages/index.js in following example: ...
Read more >
Django import-export duplicating rows when importing same ...
I upload a csv file with a header row and a data row. I confirm the table has only one row. Then I...
Read more >
Common Issues with the SQL Server Import and Export Wizard
The SQL Server Import and Export Wizard is a useful tool for copying data from one data source (e.g. a SQL Server database...
Read more >
Topic: Import of site creates menus with duplicate menu items
In creating an import and then exporting to a brand new mirror site, I have found that all of the menus created on...
Read more >
Solutions to common product CSV import problems
Troubleshooting product CSV files. Identify missing fields or headers, illegal formatting or identifier duplications before contacting support.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found