mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2024-12-05 02:10:18 +00:00
feat(docs): Add information about ESM modules format in Node.js apps (#275)
This commit is contained in:
parent
ef9fb2fbbd
commit
25f369a25a
20
README.md
20
README.md
@ -44,6 +44,26 @@ Adding the Fluence JS client for your web application is very easy.
|
|||||||
|
|
||||||
### Node.js Apps
|
### Node.js Apps
|
||||||
|
|
||||||
|
**Prerequisites:**
|
||||||
|
|
||||||
|
The Fluence JS Client only supports the ESM format. This implies that a few preliminary steps are required if your project is not already using ESM:
|
||||||
|
|
||||||
|
- Add `"type": "module"` to your package.json.
|
||||||
|
- Replace `"main": "index.js"` with `"exports": "./index.js"` in your package.json.
|
||||||
|
- Remove `'use strict';` from all JavaScript files.
|
||||||
|
- Replace all `require()`/`module.export` with `import`/`export`.
|
||||||
|
- Use only full relative file paths for imports: `import x from '.';` → `import x from './index.js';`.
|
||||||
|
|
||||||
|
If you are using TypeScript:
|
||||||
|
|
||||||
|
- Make sure you are using TypeScript 4.7 or later.
|
||||||
|
- Add [`"module": "ESNext", "target": "ESNext", "moduleResolution": "nodenext"`](https://www.typescriptlang.org/tsconfig#module) to your tsconfig.json.
|
||||||
|
- Use only full relative file paths for imports: `import x from '.';` → `import x from './index.js';`.
|
||||||
|
- Remove `namespace` usage and use `export` instead.
|
||||||
|
- You must use a `.js` extension in relative imports even though you're importing `.ts` files.
|
||||||
|
|
||||||
|
**Installation:**
|
||||||
|
|
||||||
1. Install the following packages:
|
1. Install the following packages:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user