# Is @webcomponents/webcomponentsjs ESM-only? Can you require() it?

> @webcomponents/webcomponentsjs@2.8.0 declares a CommonJS entry, but require() fails at runtime. CommonJS on paper — require() failed in our runtime test.

Web Components Polyfills

Last verified Sep 9, 2026 against @webcomponents/webcomponentsjs@2.8.0.

@webcomponents/webcomponentsjs declares a CommonJS entry only, but require("@webcomponents/webcomponentsjs") failed on every Node.js version in our probe: ReferenceError: window is not defined. import "@webcomponents/webcomponentsjs" resolves to the same file, so it fails the same way. That usually means a missing peer dependency, a browser-only global, or a package that is not meant to be loaded directly; see the runtime table below.

## What to do

1. require("@webcomponents/webcomponentsjs") failed in our probe on every Node.js version (ReferenceError: window is not defined); check the package README for peer dependencies or setup before relying on it.
2. From ES modules use the default import: import webcomponentsjs from "@webcomponents/webcomponentsjs"; then destructure. Named imports only work when Node.js can statically detect the exports.
3. TypeScript: types are bundled; install nothing extra.

## Facts

- Latest: 2.8.0 (Mar 30, 2023)
- Module format: CommonJS
- Last CommonJS version: 2.8.0
- TypeScript types: bundled
- Node engines: not declared
- Weekly downloads: 259K
- License: BSD-3-Clause

## Runtime test results for @webcomponents/webcomponentsjs@2.8.0

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 | fails (ReferenceError) | fails (ReferenceError) |
| Node.js 20 | fails (ReferenceError) | fails (ReferenceError) |
| Node.js 22 | fails (ReferenceError) | fails (ReferenceError) |
| Node.js 24 | fails (ReferenceError) | fails (ReferenceError) |
| Node.js 26 | fails (ReferenceError) | fails (ReferenceError) |
| Bun 1.4.0 | fails (ReferenceError) | fails (ReferenceError) |

## How to import @webcomponents/webcomponentsjs

ES modules:

```js
import webcomponentsjs from "@webcomponents/webcomponentsjs";
```

CommonJS:

```js
// require("@webcomponents/webcomponentsjs") failed in our probe on every Node.js version we test (ReferenceError: window is not defined); see the runtime table.
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 declares a CommonJS entry, but require() fails at runtime. @webcomponents/webcomponentsjs declares a CommonJS entry only, but require("@webcomponents/webcomponentsjs") failed on every Node.js version in our probe: ReferenceError: window is not defined. import "@webcomponents/webcomponentsjs" resolves to the same file, so it fails the same way. That usually means a missing peer dependency, a browser-only global, or a package that is not meant to be loaded directly; see the runtime table below.

**Can I require @webcomponents/webcomponentsjs?**

Not in practice. @webcomponents/webcomponentsjs declares a CommonJS entry, but require("@webcomponents/webcomponentsjs") failed on every Node.js version in our probe: ReferenceError: window is not defined. Check the package README for peer dependencies or setup before relying on it.

**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.0 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

- [@webcomponents/webcomponentsjs on npm](https://www.npmjs.com/package/@webcomponents/webcomponentsjs)
- [Source repository](https://github.com/webcomponents/polyfills)
- [HTML version](https://canirequire.com/package/@webcomponents/webcomponentsjs/)
- [JSON version](https://canirequire.com/package/@webcomponents/webcomponentsjs.json)

---

For scripts and AI agents: any package is at https://canirequire.com/package/<name>/index.md (Markdown) or https://canirequire.com/package/<name>.json (JSON); the site index is https://canirequire.com/llms.txt. Fetch the URL directly; no search needed.
