When using certain build systems (TSC, for example), transpilation of ESM to CommonJS will expect there to always be a default property.
import copy from 'fast-copy';
// becomes
const copy = require('fast-copy').default;
This causes it to fail because there is no default property with the CommonJS usage (it is simply module.exports = copy;). This was raised in #37 .
Change
Add a circular reference manually as the default property.
copy.default = copy;
This manual forging of an ESM-like module allows those transpilers to work as expected without forcing a breaking change of normal CommonJS usage of the library.
Reason for change
When using certain build systems (TSC, for example), transpilation of ESM to CommonJS will expect there to always be a
default
property.This causes it to fail because there is no
default
property with the CommonJS usage (it is simplymodule.exports = copy;
). This was raised in #37 .Change
Add a circular reference manually as the default property.
This manual forging of an ESM-like module allows those transpilers to work as expected without forcing a breaking change of normal CommonJS usage of the library.