{"id":469499,"date":"2025-08-04T15:00:44","date_gmt":"2025-08-04T15:00:44","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=469499"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=469499","title":{"rendered":"<span>\u041f\u043e\u043a\u0430, dual packaging: \u0432 \u043a\u0430\u043a\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c npm-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0423\u0436\u0435 10 \u043b\u0435\u0442 \u0432 JS-\u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0432\u043e\u044e\u044e\u0442 \u0434\u0432\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u043c\u043e\u0434\u0443\u043b\u0435\u0439: CommonJS \u0438 ES Modules. \u0427\u0442\u043e\u0431\u044b \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043b\u044e\u0448\u043a\u0438 ESM, \u0438 \u043d\u0435 \u0440\u0430\u0441\u043f\u0443\u0433\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, npm-\u043f\u0430\u043a\u0435\u0442\u044b \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 dual packaging: \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442 \u043a\u043e\u0434 \u0432 \u043e\u0431\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0430. \u042d\u0442\u043e \u0440\u0435\u0448\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u044b\u0445:<\/p>\n<ol>\n<li>\n<p>\u041c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0430\u0448 \u043a\u043e\u0434 2 \u0440\u0430\u0437\u0430 (\u0430 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c).<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u0432\u043e\u0439\u043d\u0443\u044e \u0441\u0431\u043e\u0440\u043a\u0443 \u043d\u0435 \u0441\u0443\u043f\u0435\u0440 \u0441\u043b\u043e\u0436\u043d\u043e, \u043d\u043e \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0435\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041c\u044b \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u043c \u0432 2 \u0440\u0430\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u0434\u0430 (\u0438 \u043f\u043e\u0442\u043e\u043c \u0436\u0430\u043b\u0443\u0435\u043c\u0441\u044f \u043d\u0430 \u0436\u0438\u0440\u044b\u0435 node_modules)<\/p>\n<\/li>\n<li>\n<p>dual package hazard \u2014 \u0435\u0441\u043b\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438 \u0447\u0435\u0440\u0435\u0437 import, \u0438 \u0447\u0435\u0440\u0435\u0437 require, \u043e\u043d\u0430 \u0437\u0430\u0434\u0432\u043e\u0438\u0442\u0441\u044f \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u043e\u043c\u0430\u0442\u044c instanceof \/ \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \/ Symbol().<\/p>\n<\/li>\n<\/ol>\n<p>\u0417\u0430\u0431\u0430\u0432\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u043b \u0432 2021 \u0433\u043e\u0434\u0443 \u2014 sindresorhus, \u0432\u0435\u043b\u0438\u043a\u0438\u0439 \u043e\u043f\u0435\u043d\u0441\u043e\u0440\u0441\u0435\u0440 (\u043a\u0440\u043e\u043c\u0435 \u0448\u0443\u0442\u043e\u043a), \u0440\u0435\u0448\u0438\u043b <a href=\"https:\/\/github.com\/sindresorhus\/meta\/discussions\/15\" rel=\"noopener noreferrer nofollow\">\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0441\u0432\u043e\u0438 \u043f\u0430\u043a\u0435\u0442\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0432 ESM.<\/a> \u041f\u043e\u0442\u043e\u043c \u0432\u0441\u0435 \u0441\u043c\u0435\u044e\u0442\u0441\u044f \u043d\u0430\u0434 \u043d\u0438\u043c, \u0445\u0430-\u0445\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435, <a href=\"https:\/\/www.npmjs.com\/package\/is-docker?activeTab=versions\" rel=\"noopener noreferrer nofollow\">\u043d\u0430\u0440\u043e\u0434 \u0441\u0438\u0434\u0438\u0442 \u043d\u0430 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u0435\u0433\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438\u0437 2020<\/a>. \u041c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u044d\u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0438\u0441\u043a\u0440\u0435\u0434\u0438\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0432\u0441\u0451 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 esm-only, \u043d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c-\u0442\u043e \u0421\u0438\u043d\u0434\u0440\u0435 \u0431\u044b\u043b \u043f\u0440\u0430\u0432, \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u043f\u0435\u0448\u0438\u043b \u0438 \u043b\u044e\u0434\u0435\u0439 \u043d\u0430\u0441\u043c\u0435\u0448\u0438\u043b.<\/p>\n<p>\u041f\u0440\u043e\u0448\u043b\u043e \u0435\u0449\u0435 4 \u0433\u043e\u0434\u0430, \u043f\u043e\u0440\u0430 \u0435\u0449\u0435 \u0440\u0430\u0437 \u043f\u043e\u0434\u043e\u0439\u0442\u0438 \u043a \u0432\u043e\u043f\u0440\u043e\u0441\u0443, \u043a\u0430\u043a \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c npm-\u043f\u0430\u043a\u0435\u0442\u044b \u2014 \u0432 esm, \u0432 cjs, \u0438\u043b\u0438 \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u043e\u0431\u0430? \u041c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c:<\/p>\n<ol>\n<li>\n<p>\u041a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0440\u0435\u0448\u0430\u0435\u0442 dual packaging, \u0438 \u0435\u0441\u0442\u044c \u043b\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0448\u0435?<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0430\u0432\u0434\u0430 \u043b\u0438 \u0443 ESM \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430?<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u0447\u0435\u0433\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 CJS?<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 \u0432\u0430\u0441 \u0436\u0434\u0435\u0442 \u0448\u043f\u0430\u0440\u0433\u0430\u043b\u043e\u0447\u043a\u0430 \u2014 \u043a\u043e\u0433\u0434\u0430 \u043a\u0430\u043a\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0432\u044b\u0431\u0440\u0430\u0442\u044c?<\/p>\n<\/li>\n<\/ol>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0435\u0441\u044c \u043e\u043f\u0435\u043d\u0441\u043e\u0440\u0441\u043e\u043c \u2014 \u043d\u0435 \u0443\u0431\u0435\u0433\u0430\u0439\u0442\u0435! \u0412\u043e\u043f\u0440\u043e\u0441 \u0430\u043a\u0442\u0443\u0430\u043b\u0435\u043d \u0438 \u0434\u043b\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 (\u0445\u043e\u0442\u044f \u0431\u044b \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043e\u0442\u043a\u0443\u0434\u0430 \u0443 \u0432\u0430\u0441 \u0432 node_modules 2 \u0413\u0431). \u041f\u043e\u0435\u0445\u0430\u043b\u0438!<\/p>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 dual packaging?<\/h3>\n<p>\u041e\u0442\u043a\u0443\u0434\u0430 \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0437\u044f\u043b\u0430\u0441\u044c \u0441\u0445\u0435\u043c\u0430 \u0441 \u0434\u0432\u0443\u043c\u044f \u0441\u0431\u043e\u0440\u043a\u0430\u043c\u0438? \u0412 JS \u043d\u0435 \u0431\u044b\u043b\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0438 \u0432 \u0440\u0430\u0439\u043e\u043d\u0435 2011, \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0432\u0437\u0440\u044b\u0432\u043e\u043c \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434\u0430 \u043d\u0430\u0447\u0430\u043b\u0438 \u0440\u0430\u0441\u0442\u0438 \u043a\u0430\u043a \u0433\u0440\u0438\u0431\u044b userland \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u2014 AMD! CommonJS! UMD! \u0418\u0437 \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u043f\u043e\u0431\u0435\u0434\u0438\u043b CJS (<code>require \/ module.exports<\/code>), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0432 nodejs. \u0412 2015 JS \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 ESM (<code>import \/ export<\/code>) \u2014 \u043d\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 userland \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0412 2019 nodejs \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043b\u0430 ES modules, \u043d\u043e \u0438\u0445 \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0437 CJS-\u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u043e\u0441\u044c (\u0434\u0430 \u0438 \u0435\u0449\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f) \u043c\u043d\u043e\u0433\u043e.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, ESM \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0442\u0443\u043b\u0438\u043d\u0433\u0435, \u043d\u043e \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 nodejs. \u0427\u0442\u043e\u0431\u044b \u043d\u0438\u043a\u043e\u0433\u043e \u043d\u0435 \u043e\u0431\u0438\u0434\u0435\u0442\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043b\u044e\u0448\u043a\u0438 ESM, \u043c\u044b \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u043d\u0430 npm \u0434\u0432\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u043d\u0430\u0448\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u0440\u0430\u0437\u0440\u0443\u043b\u0438\u043c\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 package.json:<\/p>\n<pre><code class=\"json\">{     \"module\": \".\/esm\/index.esm\",     \"main\": \".\/cjs\/index.cjs\",     \"exports\": {         \".\": {             \"import\": \".\/esm\/index.esm\",             \"require\": \".\/cjs\/index.cjs\",         }     } } <\/code><\/pre>\n<p>\u0414\u0430, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u044d\u0442\u043e \u0440\u0435\u0448\u0430\u0435\u0442, \u043d\u043e \u0443\u0434\u0432\u0430\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u043d\u0430\u0448\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u041c\u043e\u0436\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0438\u0445\u043d\u0443\u0442\u044c \u043e\u0431\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0432 \u043e\u0434\u0438\u043d \u0444\u0430\u0439\u043b?<\/p>\n<pre><code>export const hello = 'hello'; if (typeof module !== 'undefined') {     module.exports.hello = hello; } <\/code><\/pre>\n<p>\u042d\u0442\u043e \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e nodejs &#171;\u043a\u0440\u0430\u0441\u0438\u0442&#187; \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 cjs \/ esm \u0446\u0432\u0435\u0442 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f <code>.cjs \/ .esm<\/code> \u0438\u043b\u0438 <code>type<\/code> \u0432 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u043c <code>package.json<\/code>. \u0412 cjs-\u0444\u0430\u0439\u043b\u0435 \u0442\u043e\u043a\u0435\u043d <code>export<\/code> \u0432\u044b\u0437\u043e\u0432\u0435\u0442 SyntaxError, \u0432 esm \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>module<\/code>. \u041e\u0431\u0435\u0440\u043d\u0443\u0442\u044c <code>export<\/code> \u0432 <code>try \/ catch<\/code> \u0442\u043e\u0436\u0435 \u043d\u0435 \u0432\u044b\u0439\u0434\u0435\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e <code>export<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0444\u0430\u0439\u043b\u0430. \u0412 \u043e\u0431\u0449\u0435\u043c, dual packaging \u2014 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0431\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0430.<\/p>\n<h3>\u0427\u0435\u043c ESM \u043b\u0443\u0447\u0448\u0435 CJS<\/h3>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0437\u0430\u0439\u0434\u0435\u043c \u0441 \u0434\u0443\u0440\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b. \u041c\u043e\u0436\u0435\u0442, ESM \u043d\u0438\u0447\u0435\u043c \u043d\u0435 \u043b\u0443\u0447\u0448\u0435 CJS, \u0438 \u0432\u0441\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b\u0438 <em>\u0445\u0438\u043f\u0441\u0442\u0435\u0440\u044b,<\/em> \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c? \u042d\u0441\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b (\u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \/ \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u043b\u0443\u0447\u0448\u0435 \u043c\u0435\u0441\u0442\u0435\u0447\u043a\u043e\u0432\u043e\u0439 \u043f\u043e\u0434\u0435\u043b\u043a\u0438 \/ \u043d\u043e\u0432\u043e\u0435 \u043b\u0443\u0447\u0448\u0435 \u0441\u0442\u0430\u0440\u043e\u0433\u043e) \u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u0447\u0442\u0438 \u0432 \u043b\u044e\u0431\u043e\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0432 2025 (<a href=\"https:\/\/caniuse.com\/mdn-html_elements_script_type_module\" rel=\"noopener noreferrer nofollow\">caniuse<\/a>) ESM \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438. \u0417\u043d\u0430\u0447\u0438\u0442, ESM-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u0431\u0435\u0437 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438 \u0431\u0435\u0437 \u0431\u0430\u043d\u0434\u043b\u0435\u0440\u0430, \u0447\u0435\u0440\u0435\u0437 jsdelivr \/ unpkg. \u041d\u043e \u044d\u0442\u043e \u043f\u043e\u043a\u0430 \u043c\u0430\u0440\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e, \u0435\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<\/li>\n<li>\n<p>ESM \u043b\u0435\u0433\u043a\u043e \u0442\u0440\u0438\u0448\u0435\u0439\u043a\u0430\u0435\u0442\u0441\u044f, CJS \u2014 \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043b\u044f \u0431\u0430\u043d\u0434\u043b\u0435\u0440\u0430 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u0432\u044b\u0440\u044f\u043d\u0438\u0435 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 <code>exports<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f CJS \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043f\u0438\u0445\u0438\u0432\u0430\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043d\u044b\u0439 \u0431\u0430\u043d\u0434\u043b &#171;\u0440\u0430\u043d\u0442\u0430\u0439\u043c&#187; \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>require<\/code> \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>exports<\/code><\/p>\n<\/li>\n<\/ol>\n<p>\u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442! \u0412\u043e\u0437\u044c\u043c\u0435\u043c \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u0443\u044e &#171;\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443&#187; \u0438\u0437 \u0434\u0432\u0443\u0445 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442, \u043d\u043e \u0432 &#171;\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438&#187; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443:<\/p>\n<pre><code>\/\/ lib.cjs, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 cjs-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 module.exports.hello = 'hello'; module.exports.world = 'world';  \/\/ lib.mjs, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 esm-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 export const hello = 'hello'; export const world = 'world';  \/\/ user.mjs, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 import { world } from 'lib'; console.log(world); <\/code><\/pre>\n<p>\u041c\u044b \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043f\u043e\u0435\u0445\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e world, \u0430 hello \u043e\u0442\u0440\u0435\u0437\u0430\u043b\u0441\u044f. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u0430\u0447\u0430\u043b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432 \u0443\u043c\u0435. \u0414\u043b\u044f ESM \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e: \u0441\u0446\u0435\u043f\u043b\u044f\u0435\u043c \u0444\u0430\u0439\u043b\u044b, \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0442\u043e\u043a\u0435\u043d\u044b <code>import \/ export<\/code><\/p>\n<pre><code>\/\/ \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f\u0430 const hello = 'hello'; const world = 'world'; console.log(world); <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u0440\u0435\u0437\u0430\u0435\u043c \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0432\u044b \u0432\u0435\u043b\u0438\u043a\u043e\u043b\u0435\u043f\u043d\u044b! \u0414\u043b\u044f CJS \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435: \u043f\u043e\u0434\u043f\u0438\u0445\u043d\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 <code>exports<\/code>&#8230;<\/p>\n<pre><code>\/\/ \u0440\u0430\u043d\u0442\u0430\u0439\u043c const exports = {}; \/\/ lib exports.hello = 'hello'; exports.world = 'world'; \/\/ user const { world } = exports; console.log(world); <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u0438\u043d\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f exports, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0435\u0433\u043e \u043f\u043e\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0442\u0441\u044f, \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u0437 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0439. \u041f\u043e\u0442\u043d\u043e!<\/p>\n<p>\u041d\u043e \u043e\u043a\u0435\u0439, \u044f \u043d\u0435 \u0433\u0435\u043d\u0438\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u043f\u0440\u043e\u0433\u043d\u0430\u0432 \u043d\u0430\u0448\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0447\u0435\u0440\u0435\u0437 \u0441\u0430\u043c\u044b\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0431\u0430\u043d\u0434\u043b\u0435\u0440\u044b. \u0412\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code>\/\/ vite var r={},l;function o(){return l||(l=1,r.hello=\"hello\",r.world=\"world\"),r}var e=o();console.log(e.world); \/\/ vite + terser var l,o={};var r=(l||(l=1,o.hello=\"hello\",o.world=\"world\"),o);console.log(r.world); \/\/ webpack (()=&gt;{var r={346:r=&gt;{r.exports.z=\"world\"}},o={};function t(e){var s=o[e];if(void 0!==s)return s.exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(()=&gt;{\"use strict\";var r=t(346);console.log(r.z)})()})(); \/\/ esbuild (()=&gt;{var h=Object.create;var s=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var c=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var g=(l,o)=&gt;()=&gt;(o||l((o={exports:{}}).exports,o),o.exports);var i=(l,o,r,p)=&gt;{if(o&amp;&amp;typeof o==\"object\"||typeof o==\"function\")for(let e of x(o))!f.call(l,e)&amp;&amp;e!==r&amp;&amp;s(l,e,{get:()=&gt;o[e],enumerable:!(p=m(o,e))||p.enumerable});return l};var n=(l,o,r)=&gt;(r=l!=null?h(c(l)):{},i(o||!l||!l.__esModule?s(r,\"default\",{value:l,enumerable:!0}):r,l));var t=g((b,d)=&gt;{d.exports.hello=\"hello\";d.exports.world=\"world\"});var w=n(t(),1);console.log(w.world);})(); <\/code><\/pre>\n<p><code>hello<\/code> \u043e\u0442\u0440\u0435\u0437\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e webpack. \u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043a\u043e\u0434 \u0432\u0435\u0437\u0434\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e <em>\u043c\u0435\u0440\u0437\u043a\u0438\u0439<\/em> \u0437\u0430 \u0441\u0447\u0435\u0442 cjs-\u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0430 (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 esbuild).<\/p>\n<p>Fun fact: \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c lib.cjs \u0432 \u0432\u0438\u0434\u0435 <code>module.exports = { hello: 'hello', world: 'world' }<\/code>, webpack \u0442\u043e\u0436\u0435 \u043f\u0440\u043e\u0438\u0433\u0440\u0430\u0435\u0442: <code>(()=&gt;{var r={346:r=&gt;{r.exports={hello:\"hello\",world:\"world\"}}},o={};function e(t){var l=o[t];if(void 0!==l)return l.exports;var s=o[t]={exports:{}};return r[t](s,s.exports,e),s.exports}(()=&gt;{\"use strict\";var r=e(346);console.log(r.world)})()})();<\/code><\/p>\n<p>\u0414\u043b\u044f \u0447\u0438\u0441\u0442\u043e\u0442\u044b \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u043c \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0435 \u0441 esm-\u0441\u0431\u043e\u0440\u043a\u043e\u0439. \u0412\u0441\u0435 \u043c\u043e\u043b\u043e\u0434\u0446\u044b, \u0432\u0441\u0435 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0438\u0441\u044c! \u0420\u0430\u043d\u0442\u0430\u0439\u043c \u0442\u043e\u0436\u0435 \u0438\u0441\u0447\u0435\u0437, \u0438 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u0441\u0442\u0430\u043b \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u043c:<\/p>\n<ul>\n<li>\n<p>vite: <code>const o=\"world\";console.log(o);<\/code><\/p>\n<\/li>\n<li>\n<p>vite + terser <code>console.log(\"world\");<\/code><\/p>\n<\/li>\n<li>\n<p>webpack <code>(()=&gt;{\"use strict\";console.log(\"world\")})();<\/code><\/p>\n<\/li>\n<li>\n<p>esbuild: <code>(()=&gt;{var o=\"world\";console.log(o);})();<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0431\u0430\u043d\u0434\u043b\u0435\u0440<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0442\u0440\u0438-\u0448\u0435\u0439\u043a\u0438\u043d\u0433 cjs<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0440\u0430\u0437\u043c\u0435\u0440 cjs<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0440\u0430\u0437\u043c\u0435\u0440 esm<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">vite<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043d\u0435\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">106<\/p>\n<\/td>\n<td>\n<p align=\"left\">32<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">vite+terser<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043d\u0435\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">84<\/p>\n<\/td>\n<td>\n<p align=\"left\">22<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">webpack<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0434\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">222<\/p>\n<\/td>\n<td>\n<p align=\"left\">44<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">esbuild<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043d\u0435\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">635<\/p>\n<\/td>\n<td>\n<p align=\"left\">41<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041b\u0435\u0433\u0435\u043d\u0434\u0430 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0430! CJS-\u043a\u043e\u0434 \u0442\u0440\u0438\u0448\u0435\u0439\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044e \u043b\u0435\u0432\u043e\u0439 \u043f\u044f\u0442\u043a\u0438 \u0431\u0430\u043d\u0434\u043b\u0435\u0440\u0430 \u0438 \u043c\u0443\u0441\u043e\u0440\u0438\u0442 \u0432 \u0431\u0430\u043d\u0434\u043b\u0435. \u041d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0440\u0435\u0448\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u043c\u0438-\u0442\u043e \u043f\u043b\u0430\u0433\u0438\u043d\u0430\u043c\u0438, \u043d\u043e \u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043b\u0430\u0433\u0438\u043d\u044b \u2014 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<h3>\u041a\u043e\u0433\u0434\u0430 CJS \u043d\u0435 \u0445\u0443\u0436\u0435 ESM<\/h3>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u043b\u044e\u0441\u044b ESM \u043e\u0442\u043d\u043e\u0441\u0438\u043b\u0438\u0441\u044c \u043a \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0443 \u2014 \u043e\u043d\u0438 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 ESM, \u0438 \u0431\u0430\u043d\u0434\u043b\u043e\u043c \u043a\u043e\u0434 \u0435\u0434\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0443\u0434\u0430. \u0417\u043d\u0430\u0447\u0438\u0442, \u0435\u0441\u043b\u0438 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0430\u043a\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f nodejs (\u043c\u0438\u0434\u043b\u0432\u0430\u0440 express \/ \u043f\u043b\u0430\u0433\u0438\u043d stylelint \/ \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0439\u0442\u0435 \u0441\u0430\u043c\u0438), CJS \u043d\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u0438 ESM \u043d\u0435 \u043d\u0443\u0436\u0435\u043d!<\/p>\n<p>\u0421 \u043d\u0430\u0442\u044f\u0436\u0435\u0447\u043a\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u043b\u044e\u0441\u044b ESM \u043d\u0435 \u0442\u0430\u043a \u0432\u0430\u0436\u043d\u044b, \u043a\u043e\u0433\u0434\u0430 \u0442\u0440\u0438-\u0448\u0435\u0439\u043a\u0438\u043d\u0433 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0430\u043a\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 <em>\u043e\u0434\u043d\u043e\u0439<\/em> \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430 \u043d\u0435\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, date-fns \u0438\u043b\u0438 lodash), \u043d\u043e <em>\u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438<\/em> \u043a\u0430\u0436\u0434\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0436\u0438\u0432\u0435\u0442 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u044d\u043d\u0442\u0440\u0438\u043f\u043e\u0439\u043d\u0442\u0435 (\u0434\u0430: <code>import addDays from 'date-fns\/addDays'<\/code>, \u043d\u0435\u0442: <code>import { addDays } from 'date-fns'<\/code>). \u041d\u0430\u0442\u044f\u0436\u0435\u0447\u043a\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e cjs-\u0440\u0430\u043d\u0442\u0430\u0439\u043c \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u0441\u044f.<\/p>\n<p>\u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u0435\u0439\u0441\u0430\u0445 (\u043f\u0430\u043a\u0435\u0442 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0438 \u0442\u0440\u0438-\u0448\u0435\u0439\u043a\u0438\u043d\u0433 \u043d\u0443\u0436\u0435\u043d) ESM \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442.<\/p>\n<h3>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 ESM \u0432 nodejs<\/h3>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 node 10 \u2014 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0432\u0435\u0440\u0441\u0438\u044f, \u0433\u0434\u0435 ESM \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u2014 \u0443\u0448\u043b\u0430 \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0432 2020 \u0433\u043e\u0434\u0443, \u0438 \u0443\u0436\u0435 \u0434\u0430\u0432\u043d\u043e \u043f\u043e\u0440\u0430 \u043f\u0435\u0440\u0435\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f. \u041d\u043e \u0435\u0441\u0442\u044c \u043d\u044e\u0430\u043d\u0441.<\/p>\n<p>\u0412 \u0441\u043f\u0435\u043a\u0435 ES Modules \u0437\u0430\u0440\u044b\u0442\u0430 \u0441\u0432\u0438\u043d\u044c\u044f \u2014 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Operators\/await#top_level_await\" rel=\"noopener noreferrer nofollow\">top-level await<\/a>. \u041d\u0435 \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u0442\u044c, \u0437\u0430\u0447\u0435\u043c \u0435\u0433\u043e \u0442\u0443\u0434\u0430 \u0432\u043a\u043b\u044e\u0447\u0438\u043b\u0438, \u043d\u043e \u0444\u0430\u043a\u0442 \u2014 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 <code>import { f } from '.\/some-module'<\/code> \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c, \u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043e\u0436\u0434\u0430\u0442\u044c \u0432\u0441\u0435 await \u0432 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0435. \u041a\u0430\u043a \u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 <code>require(esm)<\/code>, \u0447\u0442\u043e\u0431\u044b \u044f \u043c\u043e\u0433 \u043f\u043e\u0442\u0438\u0445\u043e\u043d\u044c\u043a\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c esm-\u043f\u0430\u043a\u0435\u0442\u0438\u043a\u0438 \u0432 \u0441\u0432\u043e\u0439 cjs-\u043a\u043e\u0434? node 12 \u0434\u0430\u0451\u0442 \u0440\u0435\u0448\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442: \u043d\u0438\u043a\u0430\u043a, <code>require(esm)<\/code> \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u041d\u043e \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0432 node 22 (\u0441 \u0431\u0435\u043a\u043f\u043e\u0440\u0442\u043e\u043c \u0432 node 20) \u044d\u0442\u0430 \u043d\u0435\u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0430, \u0438 esm-\u043c\u043e\u0434\u0443\u043b\u0438 <em>\u0431\u0435\u0437 top-level await<\/em> \u043c\u043e\u0436\u043d\u043e <code>require<\/code>. \u0415\u0449\u0435 \u0440\u0430\u0437, \u0435\u0441\u043b\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u0430\u0448\u0438\u0445 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u0439:<\/p>\n<ul>\n<li>\n<p>\u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 esm (\u0438 \u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 cjs) \u2014 esm-only \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 node &gt;= 12<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 cjs (\u0438\u043b\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 cjs) \u2014 esm-only \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 node &gt;= 20<\/p>\n<\/li>\n<\/ul>\n<p>\u0418 \u043e\u0441\u043e\u0431\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439: \u0447\u0438\u0441\u0442\u044b\u0435 CLI \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 <code>npx my-lib<\/code> \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043a\u043e\u0434, \u0438 \u0442\u043e\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 node &gt;= 12.<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/v0\/uv\/fh\/v0uvfhkha7yaxha6irrx0wwgcf0.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/v0\/uv\/fh\/v0uvfhkha7yaxha6irrx0wwgcf0.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/v0\/uv\/fh\/v0uvfhkha7yaxha6irrx0wwgcf0.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0412 \u0430\u043f\u0440\u0435\u043b\u0435 2025 node 18, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0431\u0435\u0437 <code>require(esm)<\/code>, \u0434\u043e\u0448\u043b\u0430 \u0434\u043e EOL. \u0412\u0441\u0435, \u0443 \u043a\u043e\u0433\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f nodejs, \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u043e\u0432\u0430\u0442\u044c esm-only \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0412\u0441\u0435, \u0443 \u043a\u043e\u0433\u043e \u043a\u043e\u0434 \u043d\u0430 esm, \u043e\u043c\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0443\u0436\u0435 4 \u0433\u043e\u0434\u0430. \u041d\u0443 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c esm-only. \u0413\u043b\u0430\u0432\u043d\u043e\u0435 top-level await \u043d\u0435 \u0434\u0435\u043b\u0430\u0439\u0442\u0435.<\/p>\n<h3>\u0410 \u0432\u0434\u0440\u0443\u0433 \u043a\u043e\u043c\u0443-\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043d\u0430\u0434\u043e CommonJS<\/h3>\n<p>\u041d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0432\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0435 \u043e\u0433\u0440\u043e\u043c\u043d\u0443\u044e \u043a\u043e\u0434\u043e\u0432\u0443\u044e \u0431\u0430\u0437\u0443 \u043d\u0430 CommonJS \u043d\u0430 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 node. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0443 \u0432\u0430\u0441 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c esm-only \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443. \u0412\u0435\u0434\u044c \u043e\u0434\u043d\u043e \u0434\u0435\u043b\u043e \u2014 \u043e\u0442\u043e\u0440\u0432\u0430\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u0430\u043c\u0438 \u043f\u043e\u0447\u0438\u043d\u0438\u0442\u044c, \u0430 \u0434\u0440\u0443\u0433\u043e\u0435 \u2014 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u0432 \u0431\u0435\u0437\u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u0435\u0440\u0442\u043e\u0447\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0434\u043f\u0438\u0445\u0438\u0432\u0430\u0435\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0432 <code>globalThis<\/code>, \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u0435\u0440\u0437\u043a\u043e, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<pre><code>\/\/ index.cjs import(\".\/lib.mjs\")     .then(lib =&gt; globalThis.lib = lib)     .then(() =&gt; import('.\/app.cjs')); \/\/ app.cjs console.log(globalThis.lib.hello); <\/code><\/pre>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043c\u043e\u0436\u043d\u043e \u0433\u0434\u0435-\u0442\u043e \u0441\u0431\u043e\u043a\u0443 \u0441\u0434\u0435\u043b\u0430\u0442\u044c <code>npx esbuild node_modules\/lib\/index.mjs --bundle --format=cjs<\/code>, \u0438 \u0431\u0430\u043c\u0441, \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c cjs-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430. \u0414\u0430\u043b\u044c\u0448\u0435 \u043f\u043e\u0434\u043f\u0438\u0445\u043d\u0443\u0442\u044c \u0435\u0435 \u0432 \u043a\u043e\u0434 \u2014 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u0414\u0430, \u044d\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u044e\u0437\u0435\u0440\u0444\u0440\u0435\u043d\u0434\u043b\u0438, \u043d\u043e \u043f\u0438\u0445\u0430\u0442\u044c 90% \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e 10%, \u0442\u043e\u0436\u0435 \u0442\u0430\u043a \u0441\u0435\u0431\u0435. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u0434\u043b\u044f \u043d\u043e\u0432\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a: \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442\u0435\u0441\u044c \u0432 esm-only, \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0436\u0430\u043b\u0443\u0435\u0442\u0441\u044f \u2014 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0435 \u0435\u043c\u0443 \u044d\u0442\u0438 \u0444\u0438\u043a\u0441\u044b, \u0435\u0441\u043b\u0438 \u0436\u0430\u043b\u0443\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e \u2014 \u0434\u0435\u043b\u0430\u0435\u0442\u0435 dual packaging.<\/p>\n<h3>\u0418\u0442\u043e\u0433\u043e<\/h3>\n<p>\u0420\u0435\u0431\u044f\u0442\u0430, <em>\u0443\u0436\u0435 \u043f\u043e\u0440\u0430<\/em> \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 esm-only. \u0418\u043b\u0438 \u0432 cjs-only, \u0435\u0441\u043b\u0438 \u0434\u0435\u043b\u0430\u0435\u0442\u0435 nodejs-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443. \u0421\u0435\u0433\u043c\u0435\u043d\u0442 dual packaging \u043e\u0447\u0435\u043d\u044c \u0443\u0437\u043a\u0438\u0439, \u0438 \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0443\u0436\u0430\u0442\u044c\u0441\u044f. \u0412\u043e\u0442 \u0432\u0430\u043c \u0448\u043f\u0430\u0440\u0433\u0430\u043b\u043e\u0447\u043a\u0430:<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/7p\/uj\/0l\/7puj0lwpfihmxua2vvgiskxdnjm.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/7p\/uj\/0l\/7puj0lwpfihmxua2vvgiskxdnjm.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/7p\/uj\/0l\/7puj0lwpfihmxua2vvgiskxdnjm.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/933754\/\"> https:\/\/habr.com\/ru\/articles\/933754\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0423\u0436\u0435 10 \u043b\u0435\u0442 \u0432 JS-\u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0432\u043e\u044e\u044e\u0442 \u0434\u0432\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u043c\u043e\u0434\u0443\u043b\u0435\u0439: CommonJS \u0438 ES Modules. \u0427\u0442\u043e\u0431\u044b \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043b\u044e\u0448\u043a\u0438 ESM, \u0438 \u043d\u0435 \u0440\u0430\u0441\u043f\u0443\u0433\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, npm-\u043f\u0430\u043a\u0435\u0442\u044b \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 dual packaging: \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442 \u043a\u043e\u0434 \u0432 \u043e\u0431\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0430. \u042d\u0442\u043e \u0440\u0435\u0448\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u044b\u0445:<\/p>\n<ol>\n<li>\n<p>\u041c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0430\u0448 \u043a\u043e\u0434 2 \u0440\u0430\u0437\u0430 (\u0430 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c).<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u0432\u043e\u0439\u043d\u0443\u044e \u0441\u0431\u043e\u0440\u043a\u0443 \u043d\u0435 \u0441\u0443\u043f\u0435\u0440 \u0441\u043b\u043e\u0436\u043d\u043e, \u043d\u043e \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0435\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041c\u044b \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u043c \u0432 2 \u0440\u0430\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u0434\u0430 (\u0438 \u043f\u043e\u0442\u043e\u043c \u0436\u0430\u043b\u0443\u0435\u043c\u0441\u044f \u043d\u0430 \u0436\u0438\u0440\u044b\u0435 node_modules)<\/p>\n<\/li>\n<li>\n<p>dual package hazard \u2014 \u0435\u0441\u043b\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438 \u0447\u0435\u0440\u0435\u0437 import, \u0438 \u0447\u0435\u0440\u0435\u0437 require, \u043e\u043d\u0430 \u0437\u0430\u0434\u0432\u043e\u0438\u0442\u0441\u044f \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u043e\u043c\u0430\u0442\u044c instanceof \/ \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \/ Symbol().<\/p>\n<\/li>\n<\/ol>\n<p>\u0417\u0430\u0431\u0430\u0432\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u043b \u0432 2021 \u0433\u043e\u0434\u0443 \u2014 sindresorhus, \u0432\u0435\u043b\u0438\u043a\u0438\u0439 \u043e\u043f\u0435\u043d\u0441\u043e\u0440\u0441\u0435\u0440 (\u043a\u0440\u043e\u043c\u0435 \u0448\u0443\u0442\u043e\u043a), \u0440\u0435\u0448\u0438\u043b <a href=\"https:\/\/github.com\/sindresorhus\/meta\/discussions\/15\" rel=\"noopener noreferrer nofollow\">\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0441\u0432\u043e\u0438 \u043f\u0430\u043a\u0435\u0442\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0432 ESM.<\/a> \u041f\u043e\u0442\u043e\u043c \u0432\u0441\u0435 \u0441\u043c\u0435\u044e\u0442\u0441\u044f \u043d\u0430\u0434 \u043d\u0438\u043c, \u0445\u0430-\u0445\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435, <a href=\"https:\/\/www.npmjs.com\/package\/is-docker?activeTab=versions\" rel=\"noopener noreferrer nofollow\">\u043d\u0430\u0440\u043e\u0434 \u0441\u0438\u0434\u0438\u0442 \u043d\u0430 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u0435\u0433\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438\u0437 2020<\/a>. \u041c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u044d\u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0438\u0441\u043a\u0440\u0435\u0434\u0438\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0432\u0441\u0451 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 esm-only, \u043d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c-\u0442\u043e \u0421\u0438\u043d\u0434\u0440\u0435 \u0431\u044b\u043b \u043f\u0440\u0430\u0432, \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u043f\u0435\u0448\u0438\u043b \u0438 \u043b\u044e\u0434\u0435\u0439 \u043d\u0430\u0441\u043c\u0435\u0448\u0438\u043b.<\/p>\n<p>\u041f\u0440\u043e\u0448\u043b\u043e \u0435\u0449\u0435 4 \u0433\u043e\u0434\u0430, \u043f\u043e\u0440\u0430 \u0435\u0449\u0435 \u0440\u0430\u0437 \u043f\u043e\u0434\u043e\u0439\u0442\u0438 \u043a \u0432\u043e\u043f\u0440\u043e\u0441\u0443, \u043a\u0430\u043a \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c npm-\u043f\u0430\u043a\u0435\u0442\u044b \u2014 \u0432 esm, \u0432 cjs, \u0438\u043b\u0438 \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u043e\u0431\u0430? \u041c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c:<\/p>\n<ol>\n<li>\n<p>\u041a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0440\u0435\u0448\u0430\u0435\u0442 dual packaging, \u0438 \u0435\u0441\u0442\u044c \u043b\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0448\u0435?<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0430\u0432\u0434\u0430 \u043b\u0438 \u0443 ESM \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430?<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u0447\u0435\u0433\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 CJS?<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 \u0432\u0430\u0441 \u0436\u0434\u0435\u0442 \u0448\u043f\u0430\u0440\u0433\u0430\u043b\u043e\u0447\u043a\u0430 \u2014 \u043a\u043e\u0433\u0434\u0430 \u043a\u0430\u043a\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0432\u044b\u0431\u0440\u0430\u0442\u044c?<\/p>\n<\/li>\n<\/ol>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0435\u0441\u044c \u043e\u043f\u0435\u043d\u0441\u043e\u0440\u0441\u043e\u043c \u2014 \u043d\u0435 \u0443\u0431\u0435\u0433\u0430\u0439\u0442\u0435! \u0412\u043e\u043f\u0440\u043e\u0441 \u0430\u043a\u0442\u0443\u0430\u043b\u0435\u043d \u0438 \u0434\u043b\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 (\u0445\u043e\u0442\u044f \u0431\u044b \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043e\u0442\u043a\u0443\u0434\u0430 \u0443 \u0432\u0430\u0441 \u0432 node_modules 2 \u0413\u0431). \u041f\u043e\u0435\u0445\u0430\u043b\u0438!<\/p>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 dual packaging?<\/h3>\n<p>\u041e\u0442\u043a\u0443\u0434\u0430 \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0437\u044f\u043b\u0430\u0441\u044c \u0441\u0445\u0435\u043c\u0430 \u0441 \u0434\u0432\u0443\u043c\u044f \u0441\u0431\u043e\u0440\u043a\u0430\u043c\u0438? \u0412 JS \u043d\u0435 \u0431\u044b\u043b\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0438 \u0432 \u0440\u0430\u0439\u043e\u043d\u0435 2011, \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0432\u0437\u0440\u044b\u0432\u043e\u043c \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434\u0430 \u043d\u0430\u0447\u0430\u043b\u0438 \u0440\u0430\u0441\u0442\u0438 \u043a\u0430\u043a \u0433\u0440\u0438\u0431\u044b userland \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u2014 AMD! CommonJS! UMD! \u0418\u0437 \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u043f\u043e\u0431\u0435\u0434\u0438\u043b CJS (<code>require \/ module.exports<\/code>), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0432 nodejs. \u0412 2015 JS \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 ESM (<code>import \/ export<\/code>) \u2014 \u043d\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 userland \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0412 2019 nodejs \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043b\u0430 ES modules, \u043d\u043e \u0438\u0445 \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0437 CJS-\u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u043e\u0441\u044c (\u0434\u0430 \u0438 \u0435\u0449\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f) \u043c\u043d\u043e\u0433\u043e.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, ESM \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0442\u0443\u043b\u0438\u043d\u0433\u0435, \u043d\u043e \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 nodejs. \u0427\u0442\u043e\u0431\u044b \u043d\u0438\u043a\u043e\u0433\u043e \u043d\u0435 \u043e\u0431\u0438\u0434\u0435\u0442\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043b\u044e\u0448\u043a\u0438 ESM, \u043c\u044b \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u043d\u0430 npm \u0434\u0432\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u043d\u0430\u0448\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u0440\u0430\u0437\u0440\u0443\u043b\u0438\u043c\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 package.json:<\/p>\n<pre><code class=\"json\">{     \"module\": \".\/esm\/index.esm\",     \"main\": \".\/cjs\/index.cjs\",     \"exports\": {         \".\": {             \"import\": \".\/esm\/index.esm\",             \"require\": \".\/cjs\/index.cjs\",         }     } } <\/code><\/pre>\n<p>\u0414\u0430, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u044d\u0442\u043e \u0440\u0435\u0448\u0430\u0435\u0442, \u043d\u043e \u0443\u0434\u0432\u0430\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u043d\u0430\u0448\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u041c\u043e\u0436\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0438\u0445\u043d\u0443\u0442\u044c \u043e\u0431\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0432 \u043e\u0434\u0438\u043d \u0444\u0430\u0439\u043b?<\/p>\n<pre><code>export const hello = 'hello'; if (typeof module !== 'undefined') {     module.exports.hello = hello; } <\/code><\/pre>\n<p>\u042d\u0442\u043e \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e nodejs &#171;\u043a\u0440\u0430\u0441\u0438\u0442&#187; \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 cjs \/ esm \u0446\u0432\u0435\u0442 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f <code>.cjs \/ .esm<\/code> \u0438\u043b\u0438 <code>type<\/code> \u0432 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u043c <code>package.json<\/code>. \u0412 cjs-\u0444\u0430\u0439\u043b\u0435 \u0442\u043e\u043a\u0435\u043d <code>export<\/code> \u0432\u044b\u0437\u043e\u0432\u0435\u0442 SyntaxError, \u0432 esm \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>module<\/code>. \u041e\u0431\u0435\u0440\u043d\u0443\u0442\u044c <code>export<\/code> \u0432 <code>try \/ catch<\/code> \u0442\u043e\u0436\u0435 \u043d\u0435 \u0432\u044b\u0439\u0434\u0435\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e <code>export<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0444\u0430\u0439\u043b\u0430. \u0412 \u043e\u0431\u0449\u0435\u043c, dual packaging \u2014 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0431\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0430.<\/p>\n<h3>\u0427\u0435\u043c ESM \u043b\u0443\u0447\u0448\u0435 CJS<\/h3>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0437\u0430\u0439\u0434\u0435\u043c \u0441 \u0434\u0443\u0440\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b. \u041c\u043e\u0436\u0435\u0442, ESM \u043d\u0438\u0447\u0435\u043c \u043d\u0435 \u043b\u0443\u0447\u0448\u0435 CJS, \u0438 \u0432\u0441\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b\u0438 <em>\u0445\u0438\u043f\u0441\u0442\u0435\u0440\u044b,<\/em> \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c? \u042d\u0441\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b (\u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \/ \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u043b\u0443\u0447\u0448\u0435 \u043c\u0435\u0441\u0442\u0435\u0447\u043a\u043e\u0432\u043e\u0439 \u043f\u043e\u0434\u0435\u043b\u043a\u0438 \/ \u043d\u043e\u0432\u043e\u0435 \u043b\u0443\u0447\u0448\u0435 \u0441\u0442\u0430\u0440\u043e\u0433\u043e) \u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u0447\u0442\u0438 \u0432 \u043b\u044e\u0431\u043e\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0432 2025 (<a href=\"https:\/\/caniuse.com\/mdn-html_elements_script_type_module\" rel=\"noopener noreferrer nofollow\">caniuse<\/a>) ESM \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438. \u0417\u043d\u0430\u0447\u0438\u0442, ESM-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u0431\u0435\u0437 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438 \u0431\u0435\u0437 \u0431\u0430\u043d\u0434\u043b\u0435\u0440\u0430, \u0447\u0435\u0440\u0435\u0437 jsdelivr \/ unpkg. \u041d\u043e \u044d\u0442\u043e \u043f\u043e\u043a\u0430 \u043c\u0430\u0440\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e, \u0435\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<\/li>\n<li>\n<p>ESM \u043b\u0435\u0433\u043a\u043e \u0442\u0440\u0438\u0448\u0435\u0439\u043a\u0430\u0435\u0442\u0441\u044f, CJS \u2014 \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043b\u044f \u0431\u0430\u043d\u0434\u043b\u0435\u0440\u0430 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u0432\u044b\u0440\u044f\u043d\u0438\u0435 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 <code>exports<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f CJS \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043f\u0438\u0445\u0438\u0432\u0430\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043d\u044b\u0439 \u0431\u0430\u043d\u0434\u043b &#171;\u0440\u0430\u043d\u0442\u0430\u0439\u043c&#187; \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>require<\/code> \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>exports<\/code><\/p>\n<\/li>\n<\/ol>\n<p>\u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442! \u0412\u043e\u0437\u044c\u043c\u0435\u043c \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u0443\u044e &#171;\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443&#187; \u0438\u0437 \u0434\u0432\u0443\u0445 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442, \u043d\u043e \u0432 &#171;\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438&#187; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443:<\/p>\n<pre><code>\/\/ lib.cjs, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 cjs-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 module.exports.hello = 'hello'; module.exports.world = 'world';  \/\/ lib.mjs, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 esm-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 export const hello = 'hello'; export const world = 'world';  \/\/ user.mjs, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 import { world } from 'lib'; console.log(world); <\/code><\/pre>\n<p>\u041c\u044b \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043f\u043e\u0435\u0445\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e world, \u0430 hello \u043e\u0442\u0440\u0435\u0437\u0430\u043b\u0441\u044f. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u0430\u0447\u0430\u043b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432 \u0443\u043c\u0435. \u0414\u043b\u044f ESM \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e: \u0441\u0446\u0435\u043f\u043b\u044f\u0435\u043c \u0444\u0430\u0439\u043b\u044b, \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0442\u043e\u043a\u0435\u043d\u044b <code>import \/ export<\/code><\/p>\n<pre><code>\/\/ \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f\u0430 const hello = 'hello'; const world = 'world'; console.log(world); <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u0440\u0435\u0437\u0430\u0435\u043c \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0432\u044b \u0432\u0435\u043b\u0438\u043a\u043e\u043b\u0435\u043f\u043d\u044b! \u0414\u043b\u044f CJS \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435: \u043f\u043e\u0434\u043f\u0438\u0445\u043d\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 <code>exports<\/code>&#8230;<\/p>\n<pre><code>\/\/ \u0440\u0430\u043d\u0442\u0430\u0439\u043c const exports = {}; \/\/ lib exports.hello = 'hello'; exports.world = 'world'; \/\/ user const { world } = exports; console.log(world); <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u0438\u043d\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f exports, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0435\u0433\u043e \u043f\u043e\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0442\u0441\u044f, \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u0437 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0439. \u041f\u043e\u0442\u043d\u043e!<\/p>\n<p>\u041d\u043e \u043e\u043a\u0435\u0439, \u044f \u043d\u0435 \u0433\u0435\u043d\u0438\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u043f\u0440\u043e\u0433\u043d\u0430\u0432 \u043d\u0430\u0448\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0447\u0435\u0440\u0435\u0437 \u0441\u0430\u043c\u044b\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0431\u0430\u043d\u0434\u043b\u0435\u0440\u044b. \u0412\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code>\/\/ vite var r={},l;function o(){return l||(l=1,r.hello=\"hello\",r.world=\"world\"),r}var e=o();console.log(e.world); \/\/ vite + terser var l,o={};var r=(l||(l=1,o.hello=\"hello\",o.world=\"world\"),o);console.log(r.world); \/\/ webpack (()=&gt;{var r={346:r=&gt;{r.exports.z=\"world\"}},o={};function t(e){var s=o[e];if(void 0!==s)return s.exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(()=&gt;{\"use strict\";var r=t(346);console.log(r.z)})()})(); \/\/ esbuild (()=&gt;{var h=Object.create;var s=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var c=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var g=(l,o)=&gt;()=&gt;(o||l((o={exports:{}}).exports,o),o.exports);var i=(l,o,r,p)=&gt;{if(o&amp;&amp;typeof o==\"object\"||typeof o==\"function\")for(let e of x(o))!f.call(l,e)&amp;&amp;e!==r&amp;&amp;s(l,e,{get:()=&gt;o[e],enumerable:!(p=m(o,e))||p.enumerable});return l};var n=(l,o,r)=&gt;(r=l!=null?h(c(l)):{},i(o||!l||!l.__esModule?s(r,\"default\",{value:l,enumerable:!0}):r,l));var t=g((b,d)=&gt;{d.exports.hello=\"hello\";d.exports.world=\"world\"});var w=n(t(),1);console.log(w.world);})(); <\/code><\/pre>\n<p><code>hello<\/code> \u043e\u0442\u0440\u0435\u0437\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e webpack. \u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043a\u043e\u0434 \u0432\u0435\u0437\u0434\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e <em>\u043c\u0435\u0440\u0437\u043a\u0438\u0439<\/em> \u0437\u0430 \u0441\u0447\u0435\u0442 cjs-\u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0430 (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 esbuild).<\/p>\n<p>Fun fact: \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c lib.cjs \u0432 \u0432\u0438\u0434\u0435 <code>module.exports = { hello: 'hello', world: 'world' }<\/code>, webpack \u0442\u043e\u0436\u0435 \u043f\u0440\u043e\u0438\u0433\u0440\u0430\u0435\u0442: <code>(()=&gt;{var r={346:r=&gt;{r.exports={hello:\"hello\",world:\"world\"}}},o={};function e(t){var l=o[t];if(void 0!==l)return l.exports;var s=o[t]={exports:{}};return r[t](s,s.exports,e),s.exports}(()=&gt;{\"use strict\";var r=e(346);console.log(r.world)})()})();<\/code><\/p>\n<p>\u0414\u043b\u044f \u0447\u0438\u0441\u0442\u043e\u0442\u044b \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u043c \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0435 \u0441 esm-\u0441\u0431\u043e\u0440\u043a\u043e\u0439. \u0412\u0441\u0435 \u043c\u043e\u043b\u043e\u0434\u0446\u044b, \u0432\u0441\u0435 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0438\u0441\u044c! \u0420\u0430\u043d\u0442\u0430\u0439\u043c \u0442\u043e\u0436\u0435 \u0438\u0441\u0447\u0435\u0437, \u0438 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u0441\u0442\u0430\u043b \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u043c:<\/p>\n<ul>\n<li>\n<p>vite: <code>const o=\"world\";console.log(o);<\/code><\/p>\n<\/li>\n<li>\n<p>vite + terser <code>console.log(\"world\");<\/code><\/p>\n<\/li>\n<li>\n<p>webpack <code>(()=&gt;{\"use strict\";console.log(\"world\")})();<\/code><\/p>\n<\/li>\n<li>\n<p>esbuild: <code>(()=&gt;{var o=\"world\";console.log(o);})();<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0431\u0430\u043d\u0434\u043b\u0435\u0440<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0442\u0440\u0438-\u0448\u0435\u0439\u043a\u0438\u043d\u0433 cjs<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0440\u0430\u0437\u043c\u0435\u0440 cjs<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0440\u0430\u0437\u043c\u0435\u0440 esm<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">vite<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043d\u0435\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">106<\/p>\n<\/td>\n<td>\n<p align=\"left\">32<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">vite+terser<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043d\u0435\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">84<\/p>\n<\/td>\n<td>\n<p align=\"left\">22<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">webpack<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0434\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">222<\/p>\n<\/td>\n<td>\n<p align=\"left\">44<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">esbuild<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043d\u0435\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">635<\/p>\n<\/td>\n<td>\n<p align=\"left\">41<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041b\u0435\u0433\u0435\u043d\u0434\u0430 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0430! CJS-\u043a\u043e\u0434 \u0442\u0440\u0438\u0448\u0435\u0439\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044e \u043b\u0435\u0432\u043e\u0439 \u043f\u044f\u0442\u043a\u0438 \u0431\u0430\u043d\u0434\u043b\u0435\u0440\u0430 \u0438 \u043c\u0443\u0441\u043e\u0440\u0438\u0442 \u0432 \u0431\u0430\u043d\u0434\u043b\u0435. \u041d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0440\u0435\u0448\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u043c\u0438-\u0442\u043e \u043f\u043b\u0430\u0433\u0438\u043d\u0430\u043c\u0438, \u043d\u043e \u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043b\u0430\u0433\u0438\u043d\u044b \u2014 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<h3>\u041a\u043e\u0433\u0434\u0430 CJS \u043d\u0435 \u0445\u0443\u0436\u0435 ESM<\/h3>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u043b\u044e\u0441\u044b ESM \u043e\u0442\u043d\u043e\u0441\u0438\u043b\u0438\u0441\u044c \u043a \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0443 \u2014 \u043e\u043d\u0438 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 ESM, \u0438 \u0431\u0430\u043d\u0434\u043b\u043e\u043c \u043a\u043e\u0434 \u0435\u0434\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0443\u0434\u0430. \u0417\u043d\u0430\u0447\u0438\u0442, \u0435\u0441\u043b\u0438 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0430\u043a\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f nodejs (\u043c\u0438\u0434\u043b\u0432\u0430\u0440 express \/ \u043f\u043b\u0430\u0433\u0438\u043d stylelint \/ \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0439\u0442\u0435 \u0441\u0430\u043c\u0438), CJS \u043d\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u0438 ESM \u043d\u0435 \u043d\u0443\u0436\u0435\u043d!<\/p>\n<p>\u0421 \u043d\u0430\u0442\u044f\u0436\u0435\u0447\u043a\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u043b\u044e\u0441\u044b ESM \u043d\u0435 \u0442\u0430\u043a \u0432\u0430\u0436\u043d\u044b, \u043a\u043e\u0433\u0434\u0430 \u0442\u0440\u0438-\u0448\u0435\u0439\u043a\u0438\u043d\u0433 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0430\u043a\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 <em>\u043e\u0434\u043d\u043e\u0439<\/em> \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430 \u043d\u0435\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, date-fns \u0438\u043b\u0438 lodash), \u043d\u043e <em>\u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438<\/em> \u043a\u0430\u0436\u0434\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0436\u0438\u0432\u0435\u0442 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u044d\u043d\u0442\u0440\u0438\u043f\u043e\u0439\u043d\u0442\u0435 (\u0434\u0430: <code>import addDays from 'date-fns\/addDays'<\/code>, \u043d\u0435\u0442: <code>import { addDays } from 'date-fns'<\/code>). \u041d\u0430\u0442\u044f\u0436\u0435\u0447\u043a\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e cjs-\u0440\u0430\u043d\u0442\u0430\u0439\u043c \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u0441\u044f.<\/p>\n<p>\u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u0435\u0439\u0441\u0430\u0445 (\u043f\u0430\u043a\u0435\u0442 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0438 \u0442\u0440\u0438-\u0448\u0435\u0439\u043a\u0438\u043d\u0433 \u043d\u0443\u0436\u0435\u043d) ESM \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442.<\/p>\n<h3>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 ESM \u0432 nodejs<\/h3>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 node 10 \u2014 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0432\u0435\u0440\u0441\u0438\u044f, \u0433\u0434\u0435 ESM \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u2014 \u0443\u0448\u043b\u0430 \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0432 2020 \u0433\u043e\u0434\u0443, \u0438 \u0443\u0436\u0435 \u0434\u0430\u0432\u043d\u043e \u043f\u043e\u0440\u0430 \u043f\u0435\u0440\u0435\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f. \u041d\u043e \u0435\u0441\u0442\u044c \u043d\u044e\u0430\u043d\u0441.<\/p>\n<p>\u0412 \u0441\u043f\u0435\u043a\u0435 ES Modules \u0437\u0430\u0440\u044b\u0442\u0430 \u0441\u0432\u0438\u043d\u044c\u044f \u2014 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Operators\/await#top_level_await\" rel=\"noopener noreferrer nofollow\">top-level await<\/a>. \u041d\u0435 \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u0442\u044c, \u0437\u0430\u0447\u0435\u043c \u0435\u0433\u043e \u0442\u0443\u0434\u0430 \u0432\u043a\u043b\u044e\u0447\u0438\u043b\u0438, \u043d\u043e \u0444\u0430\u043a\u0442 \u2014 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 <code>import { f } from '.\/some-module'<\/code> \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c, \u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043e\u0436\u0434\u0430\u0442\u044c \u0432\u0441\u0435 await \u0432 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0435. \u041a\u0430\u043a \u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 <code>require(esm)<\/code>, \u0447\u0442\u043e\u0431\u044b \u044f \u043c\u043e\u0433 \u043f\u043e\u0442\u0438\u0445\u043e\u043d\u044c\u043a\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c esm-\u043f\u0430\u043a\u0435\u0442\u0438\u043a\u0438 \u0432 \u0441\u0432\u043e\u0439 cjs-\u043a\u043e\u0434? node 12 \u0434\u0430\u0451\u0442 \u0440\u0435\u0448\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442: \u043d\u0438\u043a\u0430\u043a, <code>require(esm)<\/code> \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u041d\u043e \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0432 node 22 (\u0441 \u0431\u0435\u043a\u043f\u043e\u0440\u0442\u043e\u043c \u0432 node 20) \u044d\u0442\u0430 \u043d\u0435\u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0430, \u0438 esm-\u043c\u043e\u0434\u0443\u043b\u0438 <em>\u0431\u0435\u0437 top-level await<\/em> \u043c\u043e\u0436\u043d\u043e <code>require<\/code>. \u0415\u0449\u0435 \u0440\u0430\u0437, \u0435\u0441\u043b\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u0430\u0448\u0438\u0445 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u0439:<\/p>\n<ul>\n<li>\n<p>\u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 esm (\u0438 \u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 cjs) \u2014 esm-only \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 node &gt;= 12<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 cjs (\u0438\u043b\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 cjs) \u2014 esm-only \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 node &gt;= 20<\/p>\n<\/li>\n<\/ul>\n<p>\u0418 \u043e\u0441\u043e\u0431\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439: \u0447\u0438\u0441\u0442\u044b\u0435 CLI \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 <code>npx my-lib<\/code> \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043a\u043e\u0434, \u0438 \u0442\u043e\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 node &gt;= 12.<\/p>\n<figure class=\"\"><\/figure>\n<p>\u0412 \u0430\u043f\u0440\u0435\u043b\u0435 2025 node 18, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0431\u0435\u0437 <code>require(esm)<\/code>, \u0434\u043e\u0448\u043b\u0430 \u0434\u043e EOL. \u0412\u0441\u0435, \u0443 \u043a\u043e\u0433\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f nodejs, \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u043e\u0432\u0430\u0442\u044c esm-only \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0412\u0441\u0435, \u0443 \u043a\u043e\u0433\u043e \u043a\u043e\u0434 \u043d\u0430 esm, \u043e\u043c\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0443\u0436\u0435 4 \u0433\u043e\u0434\u0430. \u041d\u0443 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c esm-only. \u0413\u043b\u0430\u0432\u043d\u043e\u0435 top-level await \u043d\u0435 \u0434\u0435\u043b\u0430\u0439\u0442\u0435.<\/p>\n<h3>\u0410 \u0432\u0434\u0440\u0443\u0433 \u043a\u043e\u043c\u0443-\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043d\u0430\u0434\u043e CommonJS<\/h3>\n<p>\u041d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0432\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0435 \u043e\u0433\u0440\u043e\u043c\u043d\u0443\u044e \u043a\u043e\u0434\u043e\u0432\u0443\u044e \u0431\u0430\u0437\u0443 \u043d\u0430 CommonJS \u043d\u0430 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 node. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0443 \u0432\u0430\u0441 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c esm-only \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443. \u0412\u0435\u0434\u044c \u043e\u0434\u043d\u043e \u0434\u0435\u043b\u043e \u2014 \u043e\u0442\u043e\u0440\u0432\u0430\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u0430\u043c\u0438 \u043f\u043e\u0447\u0438\u043d\u0438\u0442\u044c, \u0430 \u0434\u0440\u0443\u0433\u043e\u0435 \u2014 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u0432 \u0431\u0435\u0437\u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u0435\u0440\u0442\u043e\u0447\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0434\u043f\u0438\u0445\u0438\u0432\u0430\u0435\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0432 <code>globalThis<\/code>, \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u0435\u0440\u0437\u043a\u043e, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<pre><code>\/\/ index.cjs import(\".\/lib.mjs\")     .then(lib =&gt; globalThis.lib = lib)     .then(() =&gt; import('.\/app.cjs')); \/\/ app.cjs console.log(globalThis.lib.hello); <\/code><\/pre>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043c\u043e\u0436\u043d\u043e <\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-469499","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/469499","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=469499"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/469499\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=469499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=469499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=469499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}