Код: Выделить всё
"main": "./dist/my-lib.umd.cjs",
"module": "./dist/my-lib.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/my-lib.js",
"require": "./dist/my-lib.umd.cjs"
}
}
< /code>
И поэтому он создает пакет, который можно использовать как с помощью Node Afd, так и импорта ESM. "exports": {
// For CJS
"require": {
"types": "./dist/index.d.cts", // require + types = CJS types
"default": "./dist/index.cjs" // require = CJS code
},
// For ESM
"import": {
"types": "./dist/index.d.mts", // import + types = ESM types
"default": "./dist/index.mjs" // import = ESM code
}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... plugin-dts