{"id":319625,"date":"2021-03-15T21:00:21","date_gmt":"2021-03-15T21:00:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=319625"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=319625","title":{"rendered":"\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c JavaScript \u0438\u043c\u043f\u043e\u0440\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Import maps"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442. \u0421 \u0432\u044b\u0445\u043e\u0434\u043e\u043c Chrome 89 (\u0430 \u0442\u0430\u043a \u0436\u0435 \u0432 Deno 1.8) \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c  \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u041a\u0430\u0440\u0442\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432 (Import maps) \u2013 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430,  \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c JavaScript-\u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432.<\/p>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f  \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445  \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0435\u0437 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0438.  \u041e\u0434\u043d\u0430 \u0438\u0437 \u0446\u0435\u043b\u0435\u0439 \u043a\u0430\u0440\u0442 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432 \u043a\u0430\u043a \u0440\u0430\u0437 \u0440\u0435\u0448\u0430\u0435\u0442 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0437\u0430\u043a\u043e\u043d\u043d\u043e \u0438 \u0431\u0435\u0437 \u0432\u0441\u044f\u043a\u0438\u0445 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u043e\u0432 \u043f\u0438\u0441\u0430\u0442\u044c, \u0441\u043a\u0430\u0436\u0435\u043c, \u0442\u0430\u043a:<\/p>\n<pre><code class=\"javascript\">import React from 'react';<\/code><\/pre>\n<p>\u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430 import \u0438\u043b\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 import() \u043c\u043e\u0433\u043b\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0442\u044c \u043f\u0443\u0442\u0438 \u043a \u043c\u043e\u0434\u0443\u043b\u044f\u043c \u0432 \u043d\u043e\u0432\u043e\u043c \u0432\u0438\u0434\u0435, \u043d\u0443\u0436\u043d\u043e \u044d\u0442\u0438 \u043f\u0443\u0442\u0438 \u0433\u0434\u0435-\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c. \u0414\u0430, \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043c\u0430\u0433\u0438\u0438 \u0441 \u043f\u043e\u0434\u043a\u0430\u043f\u043e\u0442\u043d\u044b\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043a\u0430\u043a \u0432 \u0442\u043e\u0439 \u0436\u0435 Node.js \u0438\u043b\u0438 webpack \u0442\u0443\u0442 \u043d\u0435\u0442.<\/p>\n<p>\u041a\u0430\u0440\u0442\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432 \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0433\u0430 script \u0441 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c type=&#187;importmap&#187; \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON.<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e python -m SimpleHTTPServer 9000) \u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<p>index.html<\/p>\n<pre><code class=\"xml\">&lt;!DOCTYPE html&gt; &lt;html&gt;   &lt;body&gt;     &lt;script type=\"importmap\"&gt;       {         \"imports\": {           \"mylib\": \".\/my-lib.mjs\"         }       }     &lt;\/script&gt;     &lt;script type=\"module\"&gt;       import { sayHi } from \"mylib\";        sayHi();     &lt;\/script&gt;   &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>\u0438 my-lib.mjs<\/p>\n<pre><code class=\"javascript\">export function sayHi() {   console.log(\"hi!\"); }<\/code><\/pre>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443, \u0438 \u0432\u0443\u0430\u043b\u044f: \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432\u044b\u0432\u0435\u043b\u043e\u0441\u044c &#171;hi!&#187;. \u0414\u0430\u043b\u0435\u0435 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c, \u043a\u0430\u043a \u043e\u043d\u043e \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e.<\/p>\n<h3>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/h3>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 JSON \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0434\u0432\u0430 \u043a\u043b\u044e\u0447\u0430: <em>imports<\/em> \u0438 <em>scopes<\/em>. \u0415\u0441\u043b\u0438 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447, \u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c (\u0445\u043e\u0442\u044f \u0443 \u043c\u0435\u043d\u044f \u0425\u0440\u043e\u043c \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442).<\/p>\n<h3>Imports<\/h3>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0430 imports \u2013 \u043e\u0431\u044a\u0435\u043a\u0442, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0435\u0439 \u0438\u043c\u0435\u043d\u0430 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 (\u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0430) \u0438 \u0430\u0434\u0440\u0435\u0441 \u043c\u043e\u0434\u0443\u043b\u044f. \u0410\u0434\u0440\u0435\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441 <em>\/<\/em>,<em> ..\/<\/em>,<em> .\/<\/em> \u0438\u043b\u0438 \u0431\u044b\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u043c URL.<\/p>\n<pre><code class=\"json\">\"imports\": {   \"module-name\": \"address\" }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c &#171;\u043f\u0430\u043a\u0435\u0442\u044b&#187;, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0443\u043b\u0435\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043a \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e \u043a\u043b\u044e\u0447\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \/ \u0432 \u043a\u043e\u043d\u0435\u0446.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e &#171;my-pack&#187; \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u043d\u0435\u0451 index.mjs \u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<pre><code class=\"javascript\">export default function mainFunc() {   console.log(\"text from mainFunc\"); }<\/code><\/pre>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u0432 &#171;my-pack&#187; \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e &#171;some-module&#187; \u0441 \u0444\u0430\u0439\u043b\u043e\u043c some-helper.mjs \u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<pre><code class=\"javascript\">export function someHelper() {   console.log(\"text from someHelper\"); }<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c importmap \u043d\u0430\u0448\u0435\u0433\u043e index.html:<\/p>\n<pre><code class=\"xml\">  &lt;script type=\"importmap\"&gt;     {       \"imports\": {         \"mypack\": \".\/my-pack\/index.mjs\",         \"mypack\/\": \".\/my-pack\/\"       }     }   &lt;\/script&gt;<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u0440\u043e\u043c\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430<\/p>\n<pre><code class=\"javascript\">import mainFunc from \"mypack\";<\/code><\/pre>\n<p>\u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0435\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u044f\u043c<\/p>\n<pre><code class=\"javascript\">import { someHelper } from \"mypack\/some-module\/some-helper.mjs\";<\/code><\/pre>\n<h3>Scopes<\/h3>\n<p>\u0411\u044b\u0432\u0430\u044e\u0442 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0438\u043c\u043f\u043e\u0440\u0442 (\u0442\u043e\u0447\u043d\u0435\u0435, \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0438\u043c\u043f\u043e\u0440\u0442\u0430), \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043e\u0442\u043a\u0443\u0434\u0430 \u0435\u0451 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442. \u041d\u0430 \u044d\u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439 \u0438 \u043d\u0443\u0436\u043d\u044b \u0441\u043a\u043e\u0443\u043f\u044b. \u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"xml\">&lt;script type=\"importmap\"&gt;   {     \"imports\": {       \"mypack\": \".\/my-pack\/index.mjs\",       \"mypack\/\": \".\/my-pack\/\"     },     \"scopes\": {       \"some\/other\/url\/\": {         \"mypack\": \".\/my-pack\/index-v2.jsm\"       }     }   } &lt;\/script&gt;<\/code><\/pre>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f, url \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441 some\/other\/url\/ \u0438\u043c\u043f\u043e\u0440\u0442 &#171;mypack&#187; \u0431\u0443\u0434\u0435\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 &#171;.\/my-pack\/index-v2.jsm&#187;, \u0432\u043e \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f &#171;.\/my-pack\/index.mjs&#187;.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0441\u043a\u043e\u0443\u043f\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"xml\">&lt;script type=\"importmap\"&gt; {   \"imports\": {     \"a\": \"\/a-1.mjs\",     \"b\": \"\/b-1.mjs\",     \"c\": \"\/c-1.mjs\"   },   \"scopes\": {     \"\/scope2\/\": {       \"a\": \"\/a-2.mjs\"     },     \"\/scope2\/scope3\/\": {       \"b\": \"\/b-3.mjs\"     }   } } &lt;\/script&gt;<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u0442\u0430\u043a\u043e\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0443\u0442\u0435\u0439:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"center\"><strong>Specifier<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Referrer<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Resulting URL<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>a<\/p>\n<\/td>\n<td>\n<p>\/scope1\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/a-1.mjs<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>b<\/p>\n<\/td>\n<td>\n<p>\/scope1\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/b-1.mjs<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>c<\/p>\n<\/td>\n<td>\n<p>\/scope1\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/c-1.mjs<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<\/td>\n<td>\n<\/td>\n<td>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>a<\/p>\n<\/td>\n<td>\n<p>\/scope2\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/a-2.mjs<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>b<\/p>\n<\/td>\n<td>\n<p>\/scope2\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/b-1.mjs<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>c<\/p>\n<\/td>\n<td>\n<p>\/scope2\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/c-1.mjs<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<\/td>\n<td>\n<\/td>\n<td>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>a<\/p>\n<\/td>\n<td>\n<p>\/scope2\/scope3\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/a-2.mjs<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>b<\/p>\n<\/td>\n<td>\n<p>\/scope2\/scope3\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/b-3.mjs<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>c<\/p>\n<\/td>\n<td>\n<p>\/scope2\/scope3\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/c-1.mjs<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u0440\u0442 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432<\/h3>\n<p>\u041a\u0430\u043a \u0438 \u0441 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0433 script. \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0442\u0435\u0433\u0430:<\/p>\n<pre><code class=\"xml\">&lt;script type=\"importmap\"&gt; {   \"imports\": { ... },   \"scopes\": { ... } } &lt;\/script&gt; <\/code><\/pre>\n<p>\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442 src:<\/p>\n<pre><code class=\"xml\">&lt;script type=\"importmap\" src=\"some\/address\/to\/import-map.importmap\"&gt;&lt;\/script&gt;<\/code><\/pre>\n<p>\u0412\u0430\u0436\u043d\u043e, \u0447\u0442\u043e \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443 \u043e\u0442\u0432\u0435\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u0441 MIME type <em>application\/importmap+json<\/em>. <\/p>\n<h3>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438<\/h3>\n<ol>\n<li>\n<p>\u041a\u0430\u0440\u0442\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0442 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u043b\u0430\u0439\u043d\u043e\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u0440\u0442\u0443 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0442\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u043e\u0448\u0438\u0431\u043a\u0435:<\/p>\n<blockquote>\n<p>An import map is added after module script load was triggered.<\/p>\n<\/blockquote>\n<\/li>\n<li>\n<p>\u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443 \u043a\u0430\u0440\u0442\u0443 \u0438\u043c\u043f\u043e\u0440\u0442\u0430. \u0415\u0441\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u0442\u043e\u0440\u0443\u044e, \u0442\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u043e\u0448\u0438\u0431\u043a\u0435. \u0412 \u0425\u0440\u043e\u043c\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<blockquote>\n<p>Multiple import maps are not yet supported. <a href=\"https:\/\/crbug.com\/927119\" rel=\"noopener noreferrer nofollow\">https:\/\/crbug.com\/927119<\/a><\/p>\n<\/blockquote>\n<\/li>\n<\/ol>\n<h3>Deno<\/h3>\n<p>\u0412 Deno \u043a\u0430\u0440\u0442\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u043b\u0430\u0433\u0430 &#8212;import-map:<\/p>\n<p><code>deno run --import-map=import_map.json index.ts <\/code><\/p>\n<p>\u0413\u0434\u0435 <em>import_map.json<\/em> &#8212; \u044d\u0442\u043e \u043a\u0430\u0440\u0442\u0430 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432, \u0430 <em>index.ts<\/em> &#8212; \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 (\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438).<\/p>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438<\/p>\n<p><a href=\"https:\/\/wicg.github.io\/import-maps\/\" rel=\"noopener noreferrer nofollow\">https:\/\/wicg.github.io\/import-maps<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/WICG\/import-maps\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/WICG\/import-maps<\/a><\/p>\n<p><a href=\"https:\/\/deno.land\/manual\/linking_to_external_code\/import_maps\" rel=\"noopener noreferrer nofollow\">https:\/\/deno.land\/manual\/linking_to_external_code\/import_maps<\/a><\/p>\n<\/div>\n<p> \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\/post\/547214\/\"> https:\/\/habr.com\/ru\/post\/547214\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442. \u0421 \u0432\u044b\u0445\u043e\u0434\u043e\u043c Chrome 89 (\u0430 \u0442\u0430\u043a \u0436\u0435 \u0432 Deno 1.8) \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c  \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u041a\u0430\u0440\u0442\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432 (Import maps) \u2013 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430,  \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c JavaScript-\u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432.<\/p>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f  \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445  \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0435\u0437 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0438.  \u041e\u0434\u043d\u0430 \u0438\u0437 \u0446\u0435\u043b\u0435\u0439 \u043a\u0430\u0440\u0442 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432 \u043a\u0430\u043a \u0440\u0430\u0437 \u0440\u0435\u0448\u0430\u0435\u0442 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0437\u0430\u043a\u043e\u043d\u043d\u043e \u0438 \u0431\u0435\u0437 \u0432\u0441\u044f\u043a\u0438\u0445 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u043e\u0432 \u043f\u0438\u0441\u0430\u0442\u044c, \u0441\u043a\u0430\u0436\u0435\u043c, \u0442\u0430\u043a:<\/p>\n<pre><code class=\"javascript\">import React from 'react';<\/code><\/pre>\n<p>\u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430 import \u0438\u043b\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 import() \u043c\u043e\u0433\u043b\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0442\u044c \u043f\u0443\u0442\u0438 \u043a \u043c\u043e\u0434\u0443\u043b\u044f\u043c \u0432 \u043d\u043e\u0432\u043e\u043c \u0432\u0438\u0434\u0435, \u043d\u0443\u0436\u043d\u043e \u044d\u0442\u0438 \u043f\u0443\u0442\u0438 \u0433\u0434\u0435-\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c. \u0414\u0430, \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043c\u0430\u0433\u0438\u0438 \u0441 \u043f\u043e\u0434\u043a\u0430\u043f\u043e\u0442\u043d\u044b\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043a\u0430\u043a \u0432 \u0442\u043e\u0439 \u0436\u0435 Node.js \u0438\u043b\u0438 webpack \u0442\u0443\u0442 \u043d\u0435\u0442.<\/p>\n<p>\u041a\u0430\u0440\u0442\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432 \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0433\u0430 script \u0441 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c type=&#187;importmap&#187; \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON.<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e python -m SimpleHTTPServer 9000) \u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<p>index.html<\/p>\n<pre><code class=\"xml\">&lt;!DOCTYPE html&gt; &lt;html&gt;   &lt;body&gt;     &lt;script type=\"importmap\"&gt;       {         \"imports\": {           \"mylib\": \".\/my-lib.mjs\"         }       }     &lt;\/script&gt;     &lt;script type=\"module\"&gt;       import { sayHi } from \"mylib\";        sayHi();     &lt;\/script&gt;   &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>\u0438 my-lib.mjs<\/p>\n<pre><code class=\"javascript\">export function sayHi() {   console.log(\"hi!\"); }<\/code><\/pre>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443, \u0438 \u0432\u0443\u0430\u043b\u044f: \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432\u044b\u0432\u0435\u043b\u043e\u0441\u044c &#171;hi!&#187;. \u0414\u0430\u043b\u0435\u0435 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c, \u043a\u0430\u043a \u043e\u043d\u043e \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e.<\/p>\n<h3>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/h3>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 JSON \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0434\u0432\u0430 \u043a\u043b\u044e\u0447\u0430: <em>imports<\/em> \u0438 <em>scopes<\/em>. \u0415\u0441\u043b\u0438 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447, \u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c (\u0445\u043e\u0442\u044f \u0443 \u043c\u0435\u043d\u044f \u0425\u0440\u043e\u043c \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442).<\/p>\n<h3>Imports<\/h3>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0430 imports \u2013 \u043e\u0431\u044a\u0435\u043a\u0442, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0435\u0439 \u0438\u043c\u0435\u043d\u0430 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 (\u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0430) \u0438 \u0430\u0434\u0440\u0435\u0441 \u043c\u043e\u0434\u0443\u043b\u044f. \u0410\u0434\u0440\u0435\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441 <em>\/<\/em>,<em> ..\/<\/em>,<em> .\/<\/em> \u0438\u043b\u0438 \u0431\u044b\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u043c URL.<\/p>\n<pre><code class=\"json\">\"imports\": {   \"module-name\": \"address\" }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c &#171;\u043f\u0430\u043a\u0435\u0442\u044b&#187;, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0443\u043b\u0435\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043a \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e \u043a\u043b\u044e\u0447\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \/ \u0432 \u043a\u043e\u043d\u0435\u0446.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e &#171;my-pack&#187; \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u043d\u0435\u0451 index.mjs \u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<pre><code class=\"javascript\">export default function mainFunc() {   console.log(\"text from mainFunc\"); }<\/code><\/pre>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u0432 &#171;my-pack&#187; \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e &#171;some-module&#187; \u0441 \u0444\u0430\u0439\u043b\u043e\u043c some-helper.mjs \u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<pre><code class=\"javascript\">export function someHelper() {   console.log(\"text from someHelper\"); }<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c importmap \u043d\u0430\u0448\u0435\u0433\u043e index.html:<\/p>\n<pre><code class=\"xml\">  &lt;script type=\"importmap\"&gt;     {       \"imports\": {         \"mypack\": \".\/my-pack\/index.mjs\",         \"mypack\/\": \".\/my-pack\/\"       }     }   &lt;\/script&gt;<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u0440\u043e\u043c\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430<\/p>\n<pre><code class=\"javascript\">import mainFunc from \"mypack\";<\/code><\/pre>\n<p>\u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0435\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u044f\u043c<\/p>\n<pre><code class=\"javascript\">import { someHelper } from \"mypack\/some-module\/some-helper.mjs\";<\/code><\/pre>\n<h3>Scopes<\/h3>\n<p>\u0411\u044b\u0432\u0430\u044e\u0442 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0438\u043c\u043f\u043e\u0440\u0442 (\u0442\u043e\u0447\u043d\u0435\u0435, \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0438\u043c\u043f\u043e\u0440\u0442\u0430), \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043e\u0442\u043a\u0443\u0434\u0430 \u0435\u0451 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442. \u041d\u0430 \u044d\u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439 \u0438 \u043d\u0443\u0436\u043d\u044b \u0441\u043a\u043e\u0443\u043f\u044b. \u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"xml\">&lt;script type=\"importmap\"&gt;   {     \"imports\": {       \"mypack\": \".\/my-pack\/index.mjs\",       \"mypack\/\": \".\/my-pack\/\"     },     \"scopes\": {       \"some\/other\/url\/\": {         \"mypack\": \".\/my-pack\/index-v2.jsm\"       }     }   } &lt;\/script&gt;<\/code><\/pre>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f, url \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441 some\/other\/url\/ \u0438\u043c\u043f\u043e\u0440\u0442 &#171;mypack&#187; \u0431\u0443\u0434\u0435\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 &#171;.\/my-pack\/index-v2.jsm&#187;, \u0432\u043e \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f &#171;.\/my-pack\/index.mjs&#187;.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0441\u043a\u043e\u0443\u043f\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"xml\">&lt;script type=\"importmap\"&gt; {   \"imports\": {     \"a\": \"\/a-1.mjs\",     \"b\": \"\/b-1.mjs\",     \"c\": \"\/c-1.mjs\"   },   \"scopes\": {     \"\/scope2\/\": {       \"a\": \"\/a-2.mjs\"     },     \"\/scope2\/scope3\/\": {       \"b\": \"\/b-3.mjs\"     }   } } &lt;\/script&gt;<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u0442\u0430\u043a\u043e\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0443\u0442\u0435\u0439:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"center\"><strong>Specifier<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Referrer<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Resulting URL<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>a<\/p>\n<\/td>\n<td>\n<p>\/scope1\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/a-1.mjs<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>b<\/p>\n<\/td>\n<td>\n<p>\/scope1\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/b-1.mjs<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>c<\/p>\n<\/td>\n<td>\n<p>\/scope1\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/c-1.mjs<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<\/td>\n<td>\n<\/td>\n<td>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>a<\/p>\n<\/td>\n<td>\n<p>\/scope2\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/a-2.mjs<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>b<\/p>\n<\/td>\n<td>\n<p>\/scope2\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/b-1.mjs<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>c<\/p>\n<\/td>\n<td>\n<p>\/scope2\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/c-1.mjs<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<\/td>\n<td>\n<\/td>\n<td>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>a<\/p>\n<\/td>\n<td>\n<p>\/scope2\/scope3\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/a-2.mjs<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>b<\/p>\n<\/td>\n<td>\n<p>\/scope2\/scope3\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/b-3.mjs<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>c<\/p>\n<\/td>\n<td>\n<p>\/scope2\/scope3\/foo.mjs<\/p>\n<\/td>\n<td>\n<p>\/c-1.mjs<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u0440\u0442 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432<\/h3>\n<p>\u041a\u0430\u043a \u0438 \u0441 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0433 script. \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0442\u0435\u0433\u0430:<\/p>\n<pre><code class=\"xml\">&lt;script type=\"importmap\"&gt; {   \"imports\": { ... },   \"scopes\": { ... } } &lt;\/script&gt; <\/code><\/pre>\n<p>\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442 src:<\/p>\n<pre><code class=\"xml\">&lt;script type=\"importmap\" src=\"some\/address\/to\/import-map.importmap\"&gt;&lt;\/script&gt;<\/code><\/pre>\n<p>\u0412\u0430\u0436\u043d\u043e, \u0447\u0442\u043e \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443 \u043e\u0442\u0432\u0435\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u0441 MIME type <em>application\/importmap+json<\/em>. <\/p>\n<h3>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438<\/h3>\n<ol>\n<li>\n<p>\u041a\u0430\u0440\u0442\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0442 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u043b\u0430\u0439\u043d\u043e\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u0440\u0442\u0443 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0442\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u043e\u0448\u0438\u0431\u043a\u0435:<\/p>\n<blockquote>\n<p>An import map is added after module script load was triggered.<\/p>\n<\/blockquote>\n<\/li>\n<li>\n<p>\u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443 \u043a\u0430\u0440\u0442\u0443 \u0438\u043c\u043f\u043e\u0440\u0442\u0430. \u0415\u0441\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u0442\u043e\u0440\u0443\u044e, \u0442\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u043e\u0448\u0438\u0431\u043a\u0435. \u0412 \u0425\u0440\u043e\u043c\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<blockquote>\n<p>Multiple import maps are not yet supported. <a href=\"https:\/\/crbug.com\/927119\" rel=\"noopener noreferrer nofollow\">https:\/\/crbug.com\/927119<\/a><\/p>\n<\/blockquote>\n<\/li>\n<\/ol>\n<h3>Deno<\/h3>\n<p>\u0412 Deno \u043a\u0430\u0440\u0442\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u043b\u0430\u0433\u0430 &#8212;import-map:<\/p>\n<p><code>deno run --import-map=import_map.json index.ts <\/code><\/p>\n<p>\u0413\u0434\u0435 <em>import_map.json<\/em> &#8212; \u044d\u0442\u043e \u043a\u0430\u0440\u0442\u0430 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432, \u0430 <em>index.ts<\/em> &#8212; \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 (\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438).<\/p>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438<\/p>\n<p><a href=\"https:\/\/wicg.github.io\/import-maps\/\" rel=\"noopener noreferrer nofollow\">https:\/\/wicg.github.io\/import-maps<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/WICG\/import-maps\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/WICG\/import-maps<\/a><\/p>\n<p><a href=\"https:\/\/deno.land\/manual\/linking_to_external_code\/import_maps\" rel=\"noopener noreferrer nofollow\">https:\/\/deno.land\/manual\/linking_to_external_code\/import_maps<\/a><\/p>\n<\/div>\n<p> \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\/post\/547214\/\"> https:\/\/habr.com\/ru\/post\/547214\/<\/a><br \/><\/br><\/br><\/p>\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-319625","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/319625","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=319625"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/319625\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=319625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=319625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=319625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}