# real-require

> Keep require and import consistent after bundling or transpiling

Latest version **1.0.0** (published 2026-03-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install real-require
pnpm add real-require
yarn add real-require
bun add real-require
```

## Health

**Score 45/100 (D)** — status: active.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2026-03-14 |
| First published | 2021-11-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Paolo Insogna |
| Maintainers | matteo.collina, jsumners, watson, shogun_panda |

## Links

- npm: https://www.npmjs.com/package/real-require
- Repository: https://github.com/pinojs/real-require
- Issues: https://github.com/pinojs/real-require/issues
- npm.io page: https://npm.io/package/real-require

## Recent versions

- 1.0.0 (latest) — 2026-03-14
- 0.2.0 — 2022-07-25
- 0.1.0 — 2021-11-05

## README

# real-require

Keep require and import consistent after bundling or transpiling.

## Installation

Just run:

```bash
npm install real-require
```

## Usage

The package provides two drop-ins functions, `realRequire` and `realImport`,
which can be used in scenarios where tools like transpilers or bundlers change
the native `require` or `await import` calls.

The current `realRequire` functions only handles webpack at the moment, wrapping
the `__non_webpack__require__` implementation that webpack provides for the
final bundle.

### Example

```js
// After bundling, real-require will be embedded in the bundle
const { realImport, realRequire } = require('real-require')

/*
  By using realRequire, at build time the module will not be embedded and at runtime it will try to load path from the local filesytem.
  This is useful in situations where the build tool does not support skipping modules to embed.
*/
const { join } = realRequire('path')

async function main() {
  // Similarly, this make sure the import call is not modified by the build tools
  const localFunction = await realImport('./source.js')

  localFunction()
}

main().catch(console.error)
```

## Contributing

See [CONTRIBUTING.md](./CONTRIBUTING.md)

## License

Copyright Paolo Insogna and real-require contributors 2021. Licensed under the [MIT License](http://www.apache.org/licenses/MIT).

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