canirequire

canirequireDual (CommonJS + ESM) › postcss-js

Is postcss-js ESM-only? Can you require() it?

PostCSS for CSS-in-JS and styles in JS objects

Last verified Sep 9, 2026 against postcss-js@5.1.0. JSON

Dual (CommonJS + ESM) Dual package — both require() and import work

postcss-js publishes both a CommonJS entry and a native ESM entry (ESM added in 3.0.0). require("postcss-js") and import "postcss-js" both work on every supported Node.js version and in Bun.

Latest
5.1.0 (Feb 13, 2026)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
5.1.0
Native ESM since
3.0.0
TypeScript types
Bundled
Node engines
^20 || ^22 || >= 24
Weekly downloads
33.1M
License
MIT

Does postcss-js@5.1.0 actually load? Runtime test results

Installed and executed on Sep 9, 2026 with require("postcss-js") from a CommonJS file and import "postcss-js" from an ES module.

Runtimerequire("postcss-js")import "postcss-js"
Node.js 18✓ works✓ works
Node.js 20✓ works✓ works
Node.js 22✓ works✓ works
Node.js 24✓ works✓ works
Node.js 26✓ works✓ works
Bun 1.4✓ works✓ works

How to import postcss-js

ES modules (import)

import postcssJs from "postcss-js";

CommonJS (require)

const postcssJs = require("postcss-js");

Module format by version

Derived from the type, main and exports fields of every stable release on npm (24 versions; the newest 24 shown).

VersionsFormatFirst published
3.0.0 – 5.1.0Dual (CommonJS + ESM)Sep 15, 2020
0.1.0 – 2.0.3CommonJSOct 15, 2015

Frequently asked

Is postcss-js ESM-only?

postcss-js@5.1.0 ships CommonJS and ESM builds. postcss-js publishes both a CommonJS entry and a native ESM entry (ESM added in 3.0.0). require("postcss-js") and import "postcss-js" both work on every supported Node.js version and in Bun.

Can I require postcss-js?

Yes. postcss-js ships a CommonJS entry, so require("postcss-js") works on every Node.js version, alongside the native ESM entry for import.

Does postcss-js work in Bun?

Yes. import "postcss-js" loaded successfully in Bun 1.4 on Sep 9, 2026.

Does postcss-js ship TypeScript types?

Yes. postcss-js bundles its own type declarations; no @types package is needed.

Links

Other dual (commonjs + esm) packages

Similar popularity