dualmode
v1.0.4
Published
DualMode is a build tool designed to support the use of modern npm packages built using ES modules in older applications where only `require` is available.
Downloads
31
Readme
DualMode
DualMode is a build tool designed to support the use of modern npm packages built using ES modules in older applications where only require is available.
Table of Contents
How it Works
- DualMode will transform all the
.mjsfiles in the project to the.cjsformat and put them into thecjsfolder. - An
exportproperty will be added to thepackage.jsonthat will allow the older application use the.cjsversion of your npm module
Installation
npm install --save-dev dualmodeUsage
Make sure to run the
buildcommand from the root of your project where the package.json file is located
To use DualMode, add the following script to your package.json:
{
"scripts": {
"build": "npx dualmode"
}
}Then you can run the build process using:
npm run buildThis command will use the latest version of DualMode to build your project.
Configuration
You can customize the build process by creating a dualmode.config.json file in your project root. You can pass any esbuild.build parameter via the esbuild property.
Here's an example configuration:
{
"esbuild": {},
"moduleFileNameWithoutExtension": "index"
}DualMode uses esbuild under the hood. For more detailed information about the available options, you can refer to the esbuild documentation.
License
This project is licensed under the ISC License.
