canirequire › Dual (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.
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.
| Runtime | require("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).
| Versions | Format | First published |
|---|---|---|
| 3.0.0 – 5.1.0 | Dual (CommonJS + ESM) | Sep 15, 2020 |
| 0.1.0 – 2.0.3 | CommonJS | Oct 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
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
- js-yaml 5.4.1Dual
Similar popularity
- resolve-cwd 3.0.0CommonJS
- node-gyp 13.0.2CommonJS
- pluralize 8.0.0CommonJS
- camelcase-css 2.0.1CommonJS
- cross-fetch 4.1.0CommonJS
- inquirer 14.2.2ESM-only
- react-redux 9.3.0Dual
- normalize-url 9.0.1ESM-only