canirequire › CommonJS › @webcomponents/webcomponentsjs
Is @webcomponents/webcomponentsjs ESM-only? Can you require() it?
Web Components Polyfills
Last verified Sep 9, 2026 against @webcomponents/webcomponentsjs@2.8.0. JSON
CommonJS CommonJS — require() works on every Node.js version
@webcomponents/webcomponentsjs ships CommonJS only. require("@webcomponents/webcomponentsjs") works everywhere. import "@webcomponents/webcomponentsjs" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.
Does @webcomponents/webcomponentsjs@2.8.0 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("@webcomponents/webcomponentsjs") from a CommonJS file and import "@webcomponents/webcomponentsjs" from an ES module.
| Runtime | require("@webcomponents/webcomponentsjs") | import "@webcomponents/webcomponentsjs" |
|---|---|---|
| Node.js 18 | ✗ failsReferenceError | ✗ failsReferenceError |
| Node.js 20 | ✗ failsReferenceError | ✗ failsReferenceError |
| Node.js 22 | ✗ failsReferenceError | ✗ failsReferenceError |
| Node.js 24 | ✗ failsReferenceError | ✗ failsReferenceError |
| Node.js 26 | ✗ failsReferenceError | ✗ failsReferenceError |
| Bun 1.4 | ✗ failsReferenceError | ✗ failsReferenceError |
A failing require() on a CommonJS package usually means the package needs a browser/DOM global, a peer dependency, or a native binary that is not available in a bare Node.js process.
How to import @webcomponents/webcomponentsjs
ES modules (import)
import webcomponentsjs from "@webcomponents/webcomponentsjs";Named imports from a CommonJS package only work when Node.js can statically detect them. If a named import fails, use the default import and destructure.
CommonJS (require)
const webcomponentsjs = require("@webcomponents/webcomponentsjs");Module format by version
Derived from the type, main and exports fields of every stable release on npm (65 versions; the newest 60 shown).
| Versions | Format | First published |
|---|---|---|
| 1.0.6 – 2.8.0 | CommonJS | Aug 7, 2017 |
Frequently asked
Is @webcomponents/webcomponentsjs ESM-only?
@webcomponents/webcomponentsjs@2.8.0 is a CommonJS package. @webcomponents/webcomponentsjs ships CommonJS only. require("@webcomponents/webcomponentsjs") works everywhere. import "@webcomponents/webcomponentsjs" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.
Can I import @webcomponents/webcomponentsjs with ES module syntax?
Yes. import webcomponentsjs from "@webcomponents/webcomponentsjs" works in Node.js and Bun because they support importing CommonJS modules. Named imports work only when Node.js can statically detect the exports.
Does @webcomponents/webcomponentsjs work in Bun?
Importing @webcomponents/webcomponentsjs failed in Bun 1.4 on Sep 9, 2026: ReferenceError: window is not defined
Does @webcomponents/webcomponentsjs ship TypeScript types?
Yes. @webcomponents/webcomponentsjs bundles its own type declarations; no @types package is needed.
Links
Other commonjs packages
- debug 4.4.3CommonJS
- semver 7.8.5CommonJS
- ms 2.1.3CommonJS
- picomatch 4.0.7CommonJS
- ajv 8.20.0CommonJS
- source-map 0.8.0CommonJS
- react-is 19.2.8CommonJS
- readable-stream 4.7.0CommonJS
Similar popularity
- @babel/plugin-external-helpers 8.0.1ESM-only
- @antfu/eslint-config 9.5.1ESM-only
- @storybook/preset-create-react-app 10.6.0ESM-only
- @rollup/plugin-url 8.0.2Dual
- @size-limit/preset-small-lib 13.0.3ESM-only
- @ant-design/web3-common 1.23.0Dual
- @ant-design/web3-icons 1.16.0Dual
- @alifd/next 1.27.34CommonJS