- Notifications
You must be signed in to change notification settings - Fork111
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
CLAassistant commentedMay 7, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
wnleao commentedMay 9, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Hey, Ana! Could you join all commits in only 1? |
wnleao commentedMay 9, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 commentedMay 9, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Of course! No problem.
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. |
It's done. Thank you! |
wnleao commentedMay 9, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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. |
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 e Import | ||
#Exportand Import | ||
As diretivasExporte import tem diversas variantes de sintaxe. |
There was a problem hiding this comment.
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?
import {sayHi} from './say.js'; | ||
``` | ||
...Then the optimizer will automatically detect it and totally remove the other functions from the bundled code, thus making thebuildsmaller.That is called"tree-shaking". | ||
...Então o otimizador vai ver isso e remover as outras funções nã utilizadas nó código, tornando obuildmenor.Isso é chamado de"tree-shaking". |
There was a problem hiding this comment.
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.
import {sayHi} from './say.js'; | ||
``` | ||
...Then the optimizer will automatically detect it and totally remove the other functions from the bundled code, thus making thebuildsmaller.That is called"tree-shaking". | ||
...Então o otimizador vai ver isso e remover as outras funções nã utilizadas nó código, tornando obuildmenor.Isso é chamado de"tree-shaking". |
There was a problem hiding this comment.
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 toimport gives shorter names:`sayHi()`instead of`lib.sayHi()`. | ||
3.Explicit imports give better overviewof the code structure: what is used andwhere.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ícitado que importar fornecem uma visão geral melhor da estruturado código: o que é usado eonde.Torna o código fácil de prover suporte e de refatorar. |
There was a problem hiding this comment.
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".
``` | ||
Importswithout curly braces looknicer.A common mistake when starting to use modules is to forget curly braces atall.So, remember,`import`needs curly bracesfor named imports and doesn't need them for the default one. | ||
Importssem chaves parecem mais agradáveis.Um erro comum quando se começa a usar módulos é esquecer daschaves.Então, lembre-se,`import`precisa de chaves paraimport nomeados e não precisa para os importsdefault. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I agree with that.
Membros da mesma equipe podem usar nomes diferentes para importar a mesma coisa, e isso não é bom. | ||
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: |
There was a problem hiding this comment.
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"
``` | ||
Another solution would be to use namedexportseverywhere. 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 dosexportsdefault.Então, eles preferem usar sempreexports comnomes.Mesmo se apenas uma coisa é exportada, ele ainda será exportada com um nome, sem`default`. |
There was a problem hiding this comment.
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á" ?
A ideia é que os desenvolvedores que utilizarem nosso pacote não possam interferir na sua estrutura interna. Eles não devem procurar por arquivos dentro da pasta do nosso pacote. Apenas exportamos o que for necessário no`auth/index.js`e mantemos o resto escondido de olhos curiosos. | ||
Now, asthe actual exported functionality is scattered among the package, we can gather and "re-export" it in`auth/index.js`: | ||
Como asfuncionalidade exportadas estão espalhadas pelo pacote, podemos importá-las em`auth /index.js` e exportá-las neles: |
There was a problem hiding this comment.
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"
Uh oh!
There was an error while loading.Please reload this page.
``` | ||
...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? |
There was a problem hiding this comment.
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 commentedMay 9, 2020
Please make the requested changes. After it, add a comment "/done". |
/done |
#Export e Import | ||
#Export and Import | ||
As diretivas export e import tem diversas variantes de sintaxe. |
There was a problem hiding this comment.
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 commentedMay 11, 2020
Please make the requested changes. After it, add a comment "/done". |
/done |
No description provided.