Skip to content

Commit 6030ece

Browse files
committed
docs: reflect Node >=20.19 support for require(ESM) in CJS in README and docs/README
1 parent ac6a459 commit 6030ece

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ npm install postcss-values-parser --save-dev
2727
- Node.js >= 20.19.0
2828
- PostCSS >= 8.4.14 (peer dependency)
2929

30-
Note: This package is ESM‑only. Use `import` in Node.js. In CommonJS, load it via dynamic import:
30+
Note: This package is ESM‑only. Use `import` in Node.js. In CommonJS on Node >= 20.19.0, `require()` can load ES modules:
3131

3232
```js
33-
// CommonJS
34-
import('postcss-values-parser').then(({ parse }) => {
35-
// use parse(...)
36-
});
33+
// CommonJS (Node >= 20.19.0)
34+
const { parse } = require('postcss-values-parser');
3735
```
3836

3937
## Benefits

docs/README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,11 @@ Please see the [Exports](./Exports.md) documentation for further information.
1616

1717
Parsing is powered by [css-tree](https://github.com/csstree/csstree). Nodes in this package extend PostCSS `Node`/`Container`/`Root` so the API feels familiar, but there is no PostCSS parser involved.
1818

19-
> Note: This package is ESM‑only. Use `import` syntax in Node.js. If you must use CommonJS, load it via dynamic import:
19+
> Note: This package is ESM‑only. Use `import` syntax in Node.js. In CommonJS on Node >= 20.19.0, `require()` can load ES modules:
2020
>
2121
> ```js
22-
> // CommonJS
23-
> import('postcss-values-parser').then(({ parse }) => {
24-
> const root = parse('#fff');
25-
> });
26-
> // or
27-
> (async () => {
28-
> const { parse } = await import('postcss-values-parser');
29-
> const root = parse('#fff');
30-
> })();
22+
> // CommonJS (Node >= 20.19.0)
23+
> const { parse } = require('postcss-values-parser');
3124
> ```
3225
3326
## Nodes

0 commit comments

Comments
 (0)