Skip to content

Commit f2078b1

Browse files
authored
Update article.md
1 parent 8c39566 commit f2078b1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

1-js/13-modules/02-import-export/article.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ export {default as User} from './user.js'; // re-export default
321321
322322
Why would that be needed? Let's see a practical use case.
323323

324-
Imagine, we're writing a "package": a folder with a lot of modules, with some of the functionality exported outside (tools like NPM allow us to publish and distribute such packages), and many modules are just "helpers", for internal use in other package modules.
324+
Imagine, we're writing a "package": a folder with a lot of modules, with some of the functionality exported outside (tools like NPM allow us to publish and distribute such packages, but we don't have to use them), and many modules are just "helpers", for internal use in other package modules.
325325

326326
The file structure could be like this:
327327
```
@@ -378,7 +378,7 @@ export {default as User} from './user.js';
378378

379379
The default export needs separate handling when re-exporting.
380380

381-
Let's say we have `user.js`, and we'd like to re-export class `User` from it:
381+
Let's say we have `user.js` with the `export default class User` and would like to re-export it:
382382

383383
```js
384384
// 📁 user.js
@@ -387,7 +387,9 @@ export default class User {
387387
}
388388
```
389389

390-
1. `export User from './user.js'` won't work. What can go wrong?... But that's a syntax error!
390+
We can come across two problems with it:
391+
392+
1. `export User from './user.js'` won't work. That would lead to a syntax error.
391393

392394
To re-export the default export, we have to write `export {default as User}`, as in the example above.
393395

@@ -399,7 +401,7 @@ export default class User {
399401
export {default} from './user.js'; // to re-export the default export
400402
```
401403

402-
Such oddities of re-exporting the default export are one of the reasons why some developers don't like them.
404+
Such oddities of re-exporting a default export are one of the reasons why some developers don't like default exports and prefer named ones.
403405
404406
## Summary
405407

0 commit comments

Comments
 (0)