canirequire

canirequireCommonJS › ethereum-waffle

Is ethereum-waffle ESM-only? Can you require() it?

Sweeter, faster and simpler than truffle.

Latest version 4.0.10, published Feb 15, 2023. JSON

CommonJS CommonJS — require() works on every Node.js version

ethereum-waffle ships CommonJS only. require("ethereum-waffle") works everywhere. import "ethereum-waffle" 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.

It also declares a "module" field, so bundlers such as webpack, Vite and esbuild pick up an ESM build for tree-shaking.

Latest
4.0.10 (Feb 15, 2023)
Module format
CommonJS
Last CommonJS version
4.0.10
TypeScript types
Bundled
Node engines
>=10.0
Weekly downloads
56K
License
MIT

Does ethereum-waffle@4.0.10 actually load? Runtime test results

Runtime probe pending for this version. The values below are what package.json declares; they are refreshed once the probe runs.

Runtimerequire("ethereum-waffle")import "ethereum-waffle"
Node.js 18✓ expected✓ expected
Node.js 20✓ expected✓ expected
Node.js 22✓ expected✓ expected
Node.js 24✓ expected✓ expected
Node.js 26✓ expected✓ expected
Bun 1.4pendingpending

Install failed in our sandbox: PROBE_TIMEOUT The rows above show what package.json declares.

How to import ethereum-waffle

ES modules (import)

import ethereumWaffle from "ethereum-waffle";

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 ethereumWaffle = require("ethereum-waffle");

Module format by version

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

VersionsFormatFirst published
1.0.3 – 4.0.10CommonJSNov 27, 2018

Frequently asked

Is ethereum-waffle ESM-only?

ethereum-waffle@4.0.10 is a CommonJS package. ethereum-waffle ships CommonJS only. require("ethereum-waffle") works everywhere. import "ethereum-waffle" 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 ethereum-waffle with ES module syntax?

Yes. import ethereumWaffle from "ethereum-waffle" 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 ethereum-waffle ship TypeScript types?

Yes. ethereum-waffle bundles its own type declarations; no @types package is needed.

Links

Other commonjs packages

Similar popularity