strong-tie/inbound-calls
0
1# real-require2 3[](https://npm.im/real-require)4[](https://libraries.io/npm/real-require)5[](https://github.com/pinojs/real-require/actions?query=workflow%3ACI)6 7Keep require and import consistent after bundling or transpiling.8 9## Installation10 11Just run:12 13```bash14npm install real-require15```16 17## Usage18 19The 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.20 21The current `realRequire` functions only handles webpack at the moment, wrapping the `__non_webpack__require__` implementation that webpack provides for the final bundle.22 23### Example24 25```js26// After bundling, real-require will be embedded in the bundle27const { realImport, realRequire } = require('real-require')28 29/*30 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.31 This is useful in situations where the build tool does not support skipping modules to embed.32*/33const { join } = realRequire('path')34 35async function main() {36 // Similarly, this make sure the import call is not modified by the build tools37 const localFunction = await realImport('./source.js')38 39 localFunction()40}41 42main().catch(console.error)43```44 45## Contributing46 47See [CONTRIBUTING.md](./CONTRIBUTING.md)48 49## License50 51Copyright Paolo Insogna and real-require contributors 2021. Licensed under the [MIT License](http://www.apache.org/licenses/MIT).52 