EcmaScript module syntax is the standard way to import and export values between files in JavaScript. The
import
statement can be used to reference a value exposed by theexport
statement in another file.CommonJS is a module system supported in Node, it provides a
require
function, which can be used to access theexports
object exposed by another file.(c) parceljs
🐊Putout plugin adds ability to convert EcmaScript Modules to CommonJS.
npm i @putout/plugin-convert-esm-to-commonjs
{
"rules": {
"convert-esm-to-commonjs": "on"
}
}
import hello from 'world';
const hello = require('world');
MIT