Skip to content

Commit

Permalink
docs: @putout/plugin-nodejs: group-require-by-id: ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Dec 22, 2024
1 parent 41a90ed commit 2d9101e
Showing 1 changed file with 32 additions and 31 deletions.
63 changes: 32 additions & 31 deletions packages/plugin-nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,37 +350,6 @@ const args = minimist({
});
```
## group-require-by-id
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/ff39c5d912d836a25b96772d8045dacb/fa8d8e1ebf8ac5f19a536247536f4bccf4fdac3d). For **ESM** use [`group-imports-by-sources`](https://github.com/coderaiser/putout/tree/master/packages/plugin-group-imports-by-source#readme).
### ❌ Example of incorrect code
```js
const ss = require('../../bb/ss');
const d = require('../hello');
const react = require('react');
const {lodash} = require('lodash');
const fs = require('node:fs');
const b = require('./ss');
const m = require(x);
const c = 5;
```
### ✅ Example of correct code
```js
const fs = require('node:fs');
const react = require('react');
const {lodash} = require('lodash');
const ss = require('../../bb/ss');
const d = require('../hello');

const b = require('./ss');
const m = require(x);
const c = 5;
```
### exports
### ❌ Example of incorrect code
Expand Down Expand Up @@ -415,6 +384,38 @@ const __filename = fileURLToPath(import.meta.url);
await readFile(__filename);
```
## group-require-by-id
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/ff39c5d912d836a25b96772d8045dacb/fa8d8e1ebf8ac5f19a536247536f4bccf4fdac3d). For **ESM** use [`esm/group-imports-by-sources`](https://github.com/coderaiser/putout/tree/master/packages/plugin-esm#group-imports-by-source).
### ❌ Example of incorrect code
```js
const ss = require('../../bb/ss');
const d = require('../hello');
const react = require('react');
const {lodash} = require('lodash');
const fs = require('node:fs');
const b = require('./ss');
const m = require(x);
const c = 5;
```
### ✅ Example of correct code
```js
const fs = require('node:fs');
const react = require('react');
const {lodash} = require('lodash');
const ss = require('../../bb/ss');
const d = require('../hello');

const b = require('./ss');
const m = require(x);
const c = 5;
```
## convert-esm-to-commonjs
> **CommonJS** is a module system supported in Node, it provides a `require` function, which can be used to access the `exports` object exposed by another file.
Expand Down

0 comments on commit 2d9101e

Please sign in to comment.