canirequire

canirequireCommonJS › @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.

Latest
2.8.0 (Mar 30, 2023)
Module format
CommonJS
Last CommonJS version
2.8.0
TypeScript types
Bundled
Node engines
not declared
License
BSD-3-Clause

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.

Runtimerequire("@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).

VersionsFormatFirst published
1.0.6 – 2.8.0CommonJSAug 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

Similar popularity