Skip to content

Export and import #121

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

Merged
merged 1 commit into from
May 13, 2020
Merged

Export and import #121

merged 1 commit into from
May 13, 2020

Conversation

anapaulalemos
Copy link
Contributor

No description provided.

@CLAassistant
Copy link

CLAassistant commented May 7, 2020

CLA assistant check
All committers have signed the CLA.

@wnleao
Copy link
Contributor

wnleao commented May 9, 2020

Hey, Ana! Could you join all commits in only 1?

@wnleao
Copy link
Contributor

wnleao commented May 9, 2020

Btw, did you check if the english version had changes? Some pt-br articles are way back... https://github.com/javascript-tutorial/en.javascript.info

@anapaulalemos
Copy link
Contributor Author

anapaulalemos commented May 9, 2020

Hey, Ana! Could you join all commits in only 1?

Of course! No problem.

Btw, did you check if the english version had changes? Some pt-br articles are way back... https://github.com/javascript-tutorial/en.javascript.info

I didn't, to be honest. But I'll check that and the above comment and return, okay?

@wnleao
Copy link
Contributor

wnleao commented May 9, 2020

Hey, Ana! Could you join all commits in only 1?

Of course! No problem.

Btw, did you check if the english version had changes? Some pt-br articles are way back... https://github.com/javascript-tutorial/en.javascript.info

I didn't, to be honest. But I'll check that and the above comment and return, okay?

No problem! Let me know when you're done and I'll review your PR.

@anapaulalemos
Copy link
Contributor Author

No problem! Let me know when you're done and I'll review your PR.

It's done. Thank you!

@wnleao
Copy link
Contributor

wnleao commented May 9, 2020

No problem! Let me know when you're done and I'll review your PR.

It's done. Thank you!

Right! I'll review it. Wouldn't you like to become a maintainer? Ask iliakan in an issue in the main repository and he will grant you permission.

@wnleao
Copy link
Contributor

wnleao commented May 9, 2020

Ana, in your commit there is a change to 1-js/01-getting-started/2-manuals-and-specifications/article.md → 1-js/01-getting-started/2-manuals-specifications/article.md. Could you remove it? I think you added it by mistake.


# Export and Import
As diretivas Export e import tem diversas variantes de sintaxe.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we leave export in lowercase aswell?

```
...Then the optimizer will automatically detect it and totally remove the other functions from the bundled code, thus making the build smaller. That is called "tree-shaking".
...Então o otimizador vai ver isso e remover as outras funções nã utilizadas nó código, tornando o build menor. Isso é chamado de "tree-shaking".
Copy link
Contributor

Choose a reason for hiding this comment

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

There're two minor typos "nã" and "nó" código.

```
...Then the optimizer will automatically detect it and totally remove the other functions from the bundled code, thus making the build smaller. That is called "tree-shaking".
...Então o otimizador vai ver isso e remover as outras funções nã utilizadas nó código, tornando o build menor. Isso é chamado de "tree-shaking".
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing the "from the bundled code" part.

2. Explicitly listing what to import gives shorter names: `sayHi()` instead of `lib.sayHi()`.
3. Explicit imports give better overview of the code structure: what is used and where. It makes code support and refactoring easier.
2. Listar explicitamente o que importar nos fornece nomes mais curtos: `sayHi()` ao invés de `say.sayHi()`.
3. Uma lista explícita do que importar fornecem uma visão geral melhor da estrutura do código: o que é usado e onde. Torna o código fácil de prover suporte e de refatorar.
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor typo: "Uma lista ... fornece" and not "fornecem".


new User('John');
```

Imports without curly braces look nicer. A common mistake when starting to use modules is to forget curly braces at all. So, remember, `import` needs curly braces for named imports and doesn't need them for the default one.
Imports sem chaves parecem mais agradáveis. Um erro comum quando se começa a usar módulos é esquecer das chaves. Então, lembre-se, `import` precisa de chaves para import nomeados e não precisa para os imports default.
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe it would be better to use "imports nomeados (named imports)". What do you think?

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 agree with that.


Usually, to avoid that and keep the code consistent, there's a rule that imported variables should correspond to file names, e.g:
Geralmente, para evitar isso e manter o código consistente, existe uma regra que as variáveis importadas deve corresponder ao nome dos arquivos, por exemplo:
Copy link
Contributor

Choose a reason for hiding this comment

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

minor typo: "variáveis importadas deve" -> "variáveis importadas devem"

@@ -306,133 +305,152 @@ import func from '/path/to/func.js';
...
```

Another solution would be to use named exports everywhere. Even if only a single thing is exported, it's still exported under a name, without `default`.
Ainda assim, algumas equipes consideram isso uma séria desvantagem dos exports default. Então, eles preferem usar sempre exports com nomes. Mesmo se apenas uma coisa é exportada, ele ainda será exportada com um nome, sem `default`.
Copy link
Contributor

Choose a reason for hiding this comment

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

should it not be "ela ainda será" ?


Now, as the actual exported functionality is scattered among the package, we can gather and "re-export" it in `auth/index.js`:
Como as funcionalidade exportadas estão espalhadas pelo pacote, podemos importá-las em `auth / index.js` e exportá-las neles:
Copy link
Contributor

Choose a reason for hiding this comment

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

minor typo: "exportá-las neles" -> "exportá-las nele"

}
```

...But what if we really need to import something conditionally? Or at the right time? Like, load a module upon request, when it's really needed?
... Mas e se realmente precisarmos importar algo condicionalmente? Ou na hora certa? Como carregar um módulo mediante solicitação, quando é realmente necessário?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you missed a comma after "Como". With a comma, the following becomes an example rather than a question How.

@javascript-translate-bot

Please make the requested changes. After it, add a comment "/done".
Then I'll ask for a new review 👻

@anapaulalemos
Copy link
Contributor Author

/done

@wnleao
Copy link
Contributor

wnleao commented May 10, 2020

Great! Nice work :) could you review a quick one: #122 I just added a missing article from the english version. And also, could you review #120 ? Thank you!

@wnleao wnleao mentioned this pull request May 10, 2020
@anapaulalemos
Copy link
Contributor Author

Great! Nice work :) could you review a quick one: #122 I just added a missing article from the english version. And also, could you review #120 ? Thank you!

Thank you! And, for sure, I'll take a look at both :)


# Export and Import
As diretivas export e import tem diversas variantes de sintaxe.
Copy link
Contributor

Choose a reason for hiding this comment

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

sorry, Ana, I missed this one: "As diretivas ... têm" <- circumflex

@javascript-translate-bot

Please make the requested changes. After it, add a comment "/done".
Then I'll ask for a new review 👻

@anapaulalemos
Copy link
Contributor Author

/done

@wnleao wnleao merged commit 817a0f1 into javascript-tutorial:master May 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants