# dualmodule

> A way to test dual modules in Node.js

Latest version **0.1.0** (published 2020-03-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install dualmodule
pnpm add dualmodule
yarn add dualmodule
bun add dualmodule
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2020-03-09 |
| First published | 2019-10-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Andrea Giammarchi |
| Maintainers | webreflection |
| Keywords | ESM, CJS, dual, modules, no, mjs |

## Links

- npm: https://www.npmjs.com/package/dualmodule
- npm.io page: https://npm.io/package/dualmodule

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2020-03-09
- 0.0.13 — 2020-03-04
- 0.0.12 — 2019-11-23
- 0.0.11 — 2019-11-23
- 0.0.10 — 2019-11-23
- 0.0.9 — 2019-10-24
- 0.0.8 — 2019-10-24
- 0.0.7 — 2019-10-24
- 0.0.6 — 2019-10-24
- 0.0.5 — 2019-10-24
- 0.0.4 — 2019-10-24
- 0.0.3 — 2019-10-24
- 0.0.2 — 2019-10-24
- 0.0.1 — 2019-10-23
- 0.0.0 — 2019-10-23

## README

# Node.js Dual Modules

The minimal amount of effort needed to publish modules, for both ESM and CJS, without ever needing to write an `.mjs`, or `.cjs` file.

## Test It !

You need node 13.10 or higher, and a test folder, such as `~/test/node-modules` to perform this test:

```sh
mkdir -p ~/test/node-modules
cd ~/test/node-modules
npm i dualmodule
# test CommonJS
node -e 'console.log(require("dualmodule"))'; # read "CJS"
# test ESM
node --input-type=module -e 'import $ from "dualmodule"; console.log($)';
```

If you are in node < 13.10 you'll see an _ExperimentalWarning_, but the output is `ESM`.

If you are in node >= 13.10 you won't see the warning, just the `ESM` output.

If you'd like to test through any `file.js` in that folder, and you want to test the _ESM_ version of the module:

```sh
echo '{"type":"module"}' > ~/test/node-modules/package.json
echo 'import $ from "dualmodule"; console.log($)' > test.js
node test.js # read "ESM"
```

And you are good to go 🎉

---
_Source: https://npm.io/package/dualmodule · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
