Skip to content

Dynamic imports #244

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
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Dorin David <[email protected]>
  • Loading branch information
longo-andrea and Dorin-David authored Mar 7, 2021
commit f35a2be8f40cbc2ef533753d9de3741808ea86e8
6 changes: 3 additions & 3 deletions 1-js/13-modules/03-modules-dynamic-imports/article.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dynamic imports

Le istruzioni di export ed importa che abbiamo visto nei capitolo precedenti, sono detti "statici". La sintassi è veramente semplice.
Le istruzioni di export ed import che abbiamo visto nei capitolo precedenti sono detti "statici". La sintassi è veramente semplice.

Come prima cosa, non possiamo generare dinamicamente parametri di `import`.

Expand All @@ -24,7 +24,7 @@ if(...) {

Questo accade perché `import`/`export` mirano a fornire uno scheletro per la struttura del codice. Questa è una buona cosa, poiché la struttura del codice può essere analizzata, i moduli possono essere raccolti and impacchettati in un singolo file (grazie ad alcuni strumenti), gli export inutilizzati possono essere rimossi ("tree-shaken"). Questo è possibile solamente perché la struttura degli imports/exports è semplice e pre-fissata.

Ma come possiamo importare un modulo dinamicamente, al volo?
Ma come possiamo importare un modulo dinamicamente, secondo necessità?

## L'espressione di import()

Expand Down Expand Up @@ -55,7 +55,7 @@ export function bye() {
}
```

...Allora il dyamic import, può essere scritto cosi:
...Allora il dyamic import può essere scritto così:

```js
let {hi, bye} = await import('./say.js');
Expand Down