real-require
Keep require and import consistent after bundling or transpiling.
Installation
Just run:
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
const { realImport, realRequire } = require('real-require')
const { join } = realRequire('path')
async function main() {
const localFunction = await realImport('./source.js')
localFunction()
}
main().catch(console.error)
Contributing
See CONTRIBUTING.md
License
Copyright Paolo Insogna and real-require contributors 2021. Licensed under the MIT License.