-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
## Importing ESM modules | ||
|
||
Here is how you import modules without a packager. | ||
|
||
### Find ESM for a package | ||
|
||
If you download packages via `npm` check the `node_modules/<name>/dist` directory for files with | ||
- extension `.es.js` | ||
- extension `.esm.js` | ||
|
||
### Import ESM module | ||
|
||
Now there are two variants depending on the module having a default export or not: | ||
|
||
1. `import * as Example from "./example.js";` | ||
2. `import { Example } from "./example.js";` | ||
|
||
Check the `export` statement in the module wether it has `as default` or not. If yes, use variant #1. |