{"id":401028,"date":"2024-06-29T15:36:27","date_gmt":"2024-06-29T15:36:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=401028"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-29T15:36:27","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=401028","title":{"rendered":"<span>\u0420\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u044f VS Code \u043d\u0430 Kotlin\/JS<\/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><a href=\"https:\/\/kotlinlang.org\/docs\/js-overview.html\" rel=\"noopener noreferrer nofollow\"><u>Kotlin\/JS<\/u><\/a>\u00a0\u2013 \u044d\u0442\u043e \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 Kotlin, \u0432 JavaScript. \u041c\u043d\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0451 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f Visual Studio Code, \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u043a\u043e\u0434\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Kotlin, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0437\u0430\u0434\u0430\u043b\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c, \u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u044d\u0442\u043e? \u041a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0430\u0441 \u0436\u0434\u0443\u0442?<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ad9\/4b8\/63e\/ad94b863e7e0af802b1a420abced7349.png\" width=\"900\" height=\"599\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ad9\/4b8\/63e\/ad94b863e7e0af802b1a420abced7349.png\"\/><figcaption><\/figcaption><\/figure>\n<p>TLDR: \u0434\u0430, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e<\/p>\n<p>Disclaimer: \u044d\u0442\u043e \u043d\u0435 \u0433\u0430\u0439\u0434\u043b\u0430\u0439\u043d \u043f\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439, \u0430 \u043b\u0438\u0448\u044c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u043f\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0435 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b<\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u043d\u0430 TypeScript \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b\u00a0<a href=\"https:\/\/www.npmjs.com\/package\/@types\/vscode\" rel=\"noopener noreferrer nofollow\">\u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u0438<\/a>\u00a0\u0442\u0438\u043f\u043e\u0432 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <em>d.ts<\/em>. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 Kotlin\/JS, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0443\u00a0<a href=\"https:\/\/kotlinlang.org\/docs\/js-external-declarations-with-dukat.html\" rel=\"noopener noreferrer nofollow\">Dukat<\/a>. \u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0438\u0437 <em>d.ts<\/em> \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u0439 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u043d\u0430 Kotlin.<\/p>\n<p>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.\u00a0<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438\u0437 Intellij IDEA, \u0432\u044b\u0431\u0440\u0430\u0432 Kotlin \u2013 Node.JS application \u2013 Gradle Kotlin \u2013 IR Kotlin\/JS Compiler. <a href=\"https:\/\/kotlinlang.org\/docs\/js-ir-compiler.html\" rel=\"noopener noreferrer nofollow\">IR<\/a> \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u2013 \u044d\u0442\u043e \u043d\u043e\u0432\u044b\u0439 \u0431\u0435\u043a\u0435\u043d\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u043a\u043e\u0440\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0442\u0430\u043d\u0435\u0442 \u0431\u0435\u043a\u0435\u043d\u0434\u043e\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ba5\/7a8\/883\/ba57a888371b5a4108192807b10c1bda.gif\" alt=\"\u0414\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430\" title=\"\u0414\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430\" width=\"600\" height=\"493\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ba5\/7a8\/883\/ba57a888371b5a4108192807b10c1bda.gif\"\/><figcaption>\u0414\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/figcaption><\/figure>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043c <em>build.gradle.kts<\/em> \u0444\u0430\u0439\u043b \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f<\/p>\n<pre><code class=\"kotlin\">plugins {     kotlin(\"js\") version \"1.5.31\" }  group = \"com.alikhachev\" version = \"1.0-SNAPSHOT\"  repositories {     mavenCentral() }  dependencies {     testImplementation(kotlin(\"test\")) }  kotlin {     js(IR) {         binaries.executable()         nodejs {          }     } }<\/code><\/pre>\n<p>\u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0447\u0442\u043e \u043f\u043e\u043a\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/kotlinlang.org\/docs\/js-to-kotlin-interop.html#jsexport-annotation\" rel=\"noopener noreferrer nofollow\">\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0438\u0447\u0435\u0439<\/a> \u044f\u0437\u044b\u043a\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0431\u043b\u043e\u043a <code>kotlin<\/code> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434, \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u0434\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <code>@JsExport<\/code>:<\/p>\n<pre><code class=\"kotlin\">sourceSets {     all {         languageSettings {             optIn(\"kotlin.js.ExperimentalJsExport\")         }     } }<\/code><\/pre>\n<p>Kotlin Gradle plugin, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f VS Code, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 <em>package.json<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0431\u043b\u043e\u043a \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>js<\/code> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434<\/p>\n<pre><code class=\"kotlin\">compilations.named(\"main\") {     packageJson {         customField(\"categories\", listOf(\"Other\"))         customField(\"activationEvents\", listOf(\"onCommand:helloworld.helloWorld\"))         customField(\"contributes\", mapOf(\"commands\" to listOf(mapOf(\"command\" to \"helloworld.helloWorld\", \"title\" to \"Hello World\"))))         customField(\"engines\", mapOf(\"vscode\" to \"^1.60.0\"))         customField(\"displayName\", \"HelloWorld\")         customField(\"description\", \"My first extension\")     } }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u0443\u044e \u0432\u044b\u0448\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0430 <em>@types\/vscode <\/em>\u0432 \u0431\u043b\u043e\u043a <code>dependencies<\/code>:<\/p>\n<pre><code class=\"kotlin\">implementation(npm(\"@types\/vscode\", \"^1.60.0\", generateExternals = true))<\/code><\/pre>\n<p>\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u044f <code>generateExternals = true<\/code>, \u043c\u044b \u043f\u0440\u043e\u0441\u0438\u043c Kotlin Gradle Plugin \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c Kotlin-\u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u0438 \u0438\u0437 <em>d.ts<\/em> \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Dukat.<\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 <a href=\"https:\/\/github.com\/Kotlin\/dukat\/issues\/292\" rel=\"noopener noreferrer nofollow\">issue<\/a> \u0432 Dukat \u0438 \u0433\u043e\u043b\u043e\u0441\u0443\u0435\u043c \u0437\u0430 \u043d\u0435\u0433\u043e. \u0410 \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043f\u043e\u043a\u0430 \u0431\u0430\u0433 \u043d\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u044f\u0442, \u043e\u0431\u043e\u0439\u0434\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0440\u0443\u0447\u043d\u044b\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432. <\/p>\n<p>\u0412\u044b\u0441\u0442\u0430\u0432\u0438\u043c <code>generateExternals = false<\/code> \u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0438\u0445 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>.\/gradlew generateExternals<\/code>. \u0414\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e <em>externals<\/em> \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c Kotlin\/JS \u043c\u043e\u0434\u0443\u043b\u044c <em>vscode<\/em>, \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u043d\u0435\u0433\u043e (\u0432\u044b\u043d\u043e\u0441\u0438\u0442\u044c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c dead code elimination \u0441\u043c\u043e\u0433 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0432\u044b\u0440\u0435\u0437\u0430\u0442\u044c \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043a\u043e\u0434 \u0438\u0437 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0433\u043e js-\u0444\u0430\u0439\u043b\u0430). \u041f\u043e\u0434\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434, \u043a\u0430\u043a \u0438 \u0441\u0430\u043c \u043c\u043e\u0434\u0443\u043b\u044c, \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0436\u0443, \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0435\u0433\u043e \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438. <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 <em>@types\/vscode<\/em> \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c:<\/p>\n<pre><code class=\"kotlin\">implementation(project(\":vscode\"))<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0441\u0440\u0430\u0437\u0443 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432 \u043e\u0434\u0438\u043d \u043a\u043b\u0438\u043a \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 VS Code:<\/p>\n<pre><code class=\"kotlin\">tasks.register(\"installExtension\", Sync::class) {     dependsOn(\"productionExecutableCompileSync\")     from({         kotlin.js().compilations.named(\"main\").map { it.npmProject.dir }     }) \/\/ build\/js\/packages\/&lt;\u0438\u043c\u044f \u043c\u043e\u0434\u0443\u043b\u044f>     into {         project.provider { File(providers.systemProperty(\"user.home\").get()).resolve(\".vscode\/extensions\").resolve(project.name) }     } \/\/ ~\/.vscode\/extensions\/&lt;\u0438\u043c\u044f \u043c\u043e\u0434\u0443\u043b\u044f>     doFirst {         logger.info(\"Installing VS Code extension into $destinationDir\")     } }<\/code><\/pre>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0431\u0443\u0434\u0435\u0442 \u0431\u0440\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 npm \u043c\u043e\u0434\u0443\u043b\u044c \u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f\u043c\u0438 VS Code <em>~\/.vscode\/extensions\/<\/em><\/p>\n<h2>\u041a\u043e\u0434 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0423\u0434\u0430\u043b\u0438\u043c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0430 IDEA, \u043e\u043d \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <em>extension.kt<\/em> \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u0445, \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0442\u043e\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u043e\u0442 Microsoft <a href=\"https:\/\/code.visualstudio.com\/api\/get-started\/your-first-extension\" rel=\"noopener noreferrer nofollow\">Your First Extension<\/a>:<\/p>\n<pre><code class=\"kotlin\">@JsExport fun activate(context: vscode.ExtensionContext) {     val disposable = vscode.commands.registerCommand(\"helloworld.helloWorld\", {         vscode.window.showInformationMessage(\"Hello World from Kotlin\/JS!\")     })      context.subscriptions.asDynamic().push(disposable) }  @JsExport fun deactivate() {  }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0430\u0448\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u043f\u043e \u0441\u0431\u043e\u0440\u043a\u0435 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 <code>.\/gradlew installExtension<\/code> \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 VS Code \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <em>Hello World<\/em>. \u0420\u0430\u0434\u0443\u0435\u043c\u0441\u044f \u0441\u0432\u043e\u0435\u043c\u0443 \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u043c\u0443 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044e \u043d\u0430 Kotlin\/JS \ud83d\ude42<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ef4\/c25\/d2f\/ef4c25d2f93a4afefa120d7339e88f70.gif\" width=\"600\" height=\"451\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ef4\/c25\/d2f\/ef4c25d2f93a4afefa120d7339e88f70.gif\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u041e\u0442\u043b\u0430\u0434\u043a\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f<\/h2>\n<p>\u041a\u0430\u043a\u0430\u044f \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u0430\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0431\u0435\u0437 \u043e\u0442\u043b\u0430\u0434\u043a\u0438?<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <em>build.gradle.kts<\/em> \u0437\u0430\u0434\u0430\u0447\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c VS Code \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u043e\u0442\u043b\u0430\u0434\u043a\u0438, \u043f\u043e\u0434\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044f \u043d\u0430\u0448\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438:<\/p>\n<pre><code class=\"kotlin\">tasks.register(\"debugExtension\", Exec::class) {     dependsOn(\"developmentExecutableCompileSync\")     val path = kotlin.js().compilations.named(\"main\").map { it.npmProject.dir }.get()     commandLine(\"code\", \"--inspect-extensions=9229\", \"--extensionDevelopmentPath=$path\") }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c Run configuration \u0432 IDEA:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/316\/084\/322\/316084322e4c07222b89332bf0ccecf9.png\" alt=\"IDEA run configuration\" title=\"IDEA run configuration\" width=\"2304\" height=\"1616\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/316\/084\/322\/316084322e4c07222b89332bf0ccecf9.png\"\/><figcaption>IDEA run configuration<\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u0441\u0435\u0430\u043d\u0441 \u043e\u0442\u043b\u0430\u0434\u043a\u0438, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 <code>.\/gradlew debugExtension<\/code> \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0432\u0448\u0438\u0441\u044c \u0434\u0435\u0431\u0430\u0433\u0433\u0435\u0440\u043e\u043c \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435. \u0423 \u0432\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441, \u0430 \u0437\u0430\u0447\u0435\u043c, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u044d\u0442\u043e \u0432\u0441\u0451 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 TypeScript? \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b \u043b\u044e\u0431\u0438\u0442\u0435 Kotlin \u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Kotlin Multiplatform \u0438\u043b\u0438 Kotlin\/JS, \u0442\u043e\u0433\u0434\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e \u0434\u043b\u044f \u0432\u0430\u0441 \u0443\u0434\u043e\u0431\u043d\u0435\u0435. \u0418\u043b\u0438 \u0432\u044b \u0442\u0430\u043a\u043e\u0439 \u0436\u0435, \u043a\u0430\u043a \u0438 \u044f, <s>\u0431\u043e\u043b\u044c\u043d\u043e\u0439 \u043d\u0430 \u0433\u043e\u043b\u043e\u0432\u0443<\/s> \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0439\u0441\u044f \u0447\u0435\u043c-\u0442\u043e \u043d\u043e\u0432\u044b\u043c \u0438\u043d\u0436\u0435\u043d\u0435\u0440 \ud83d\ude09<\/p>\n<p><a href=\"https:\/\/github.com\/ALikhachev\/vs-code-hello-world-kt-extension\" rel=\"noopener noreferrer nofollow\">GitHub<\/a><\/p>\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\/582114\/\"> https:\/\/habr.com\/ru\/articles\/582114\/<\/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><a href=\"https:\/\/kotlinlang.org\/docs\/js-overview.html\" rel=\"noopener noreferrer nofollow\"><u>Kotlin\/JS<\/u><\/a>\u00a0\u2013 \u044d\u0442\u043e \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 Kotlin, \u0432 JavaScript. \u041c\u043d\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0451 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f Visual Studio Code, \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u043a\u043e\u0434\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Kotlin, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0437\u0430\u0434\u0430\u043b\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c, \u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u044d\u0442\u043e? \u041a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0430\u0441 \u0436\u0434\u0443\u0442?<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>TLDR: \u0434\u0430, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e<\/p>\n<p>Disclaimer: \u044d\u0442\u043e \u043d\u0435 \u0433\u0430\u0439\u0434\u043b\u0430\u0439\u043d \u043f\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439, \u0430 \u043b\u0438\u0448\u044c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u043f\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0435 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b<\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u043d\u0430 TypeScript \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b\u00a0<a href=\"https:\/\/www.npmjs.com\/package\/@types\/vscode\" rel=\"noopener noreferrer nofollow\">\u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u0438<\/a>\u00a0\u0442\u0438\u043f\u043e\u0432 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <em>d.ts<\/em>. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 Kotlin\/JS, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0443\u00a0<a href=\"https:\/\/kotlinlang.org\/docs\/js-external-declarations-with-dukat.html\" rel=\"noopener noreferrer nofollow\">Dukat<\/a>. \u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0438\u0437 <em>d.ts<\/em> \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u0439 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u043d\u0430 Kotlin.<\/p>\n<p>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.\u00a0<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438\u0437 Intellij IDEA, \u0432\u044b\u0431\u0440\u0430\u0432 Kotlin \u2013 Node.JS application \u2013 Gradle Kotlin \u2013 IR Kotlin\/JS Compiler. <a href=\"https:\/\/kotlinlang.org\/docs\/js-ir-compiler.html\" rel=\"noopener noreferrer nofollow\">IR<\/a> \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u2013 \u044d\u0442\u043e \u043d\u043e\u0432\u044b\u0439 \u0431\u0435\u043a\u0435\u043d\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u043a\u043e\u0440\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0442\u0430\u043d\u0435\u0442 \u0431\u0435\u043a\u0435\u043d\u0434\u043e\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<figure class=\"full-width\"><figcaption>\u0414\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/figcaption><\/figure>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043c <em>build.gradle.kts<\/em> \u0444\u0430\u0439\u043b \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f<\/p>\n<pre><code class=\"kotlin\">plugins {     kotlin(\"js\") version \"1.5.31\" }  group = \"com.alikhachev\" version = \"1.0-SNAPSHOT\"  repositories {     mavenCentral() }  dependencies {     testImplementation(kotlin(\"test\")) }  kotlin {     js(IR) {         binaries.executable()         nodejs {          }     } }<\/code><\/pre>\n<p>\u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0447\u0442\u043e \u043f\u043e\u043a\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/kotlinlang.org\/docs\/js-to-kotlin-interop.html#jsexport-annotation\" rel=\"noopener noreferrer nofollow\">\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0438\u0447\u0435\u0439<\/a> \u044f\u0437\u044b\u043a\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0431\u043b\u043e\u043a <code>kotlin<\/code> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434, \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u0434\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <code>@JsExport<\/code>:<\/p>\n<pre><code class=\"kotlin\">sourceSets {     all {         languageSettings {             optIn(\"kotlin.js.ExperimentalJsExport\")         }     } }<\/code><\/pre>\n<p>Kotlin Gradle plugin, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f VS Code, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 <em>package.json<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0431\u043b\u043e\u043a \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>js<\/code> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434<\/p>\n<pre><code class=\"kotlin\">compilations.named(\"main\") {     packageJson {         customField(\"categories\", listOf(\"Other\"))         customField(\"activationEvents\", listOf(\"onCommand:helloworld.helloWorld\"))         customField(\"contributes\", mapOf(\"commands\" to listOf(mapOf(\"command\" to \"helloworld.helloWorld\", \"title\" to \"Hello World\"))))         customField(\"engines\", mapOf(\"vscode\" to \"^1.60.0\"))         customField(\"displayName\", \"HelloWorld\")         customField(\"description\", \"My first extension\")     } }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u0443\u044e \u0432\u044b\u0448\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0430 <em>@types\/vscode <\/em>\u0432 \u0431\u043b\u043e\u043a <code>dependencies<\/code>:<\/p>\n<pre><code class=\"kotlin\">implementation(npm(\"@types\/vscode\", \"^1.60.0\", generateExternals = true))<\/code><\/pre>\n<p>\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u044f <code>generateExternals = true<\/code>, \u043c\u044b \u043f\u0440\u043e\u0441\u0438\u043c Kotlin Gradle Plugin \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c Kotlin-\u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u0438 \u0438\u0437 <em>d.ts<\/em> \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Dukat.<\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 <a href=\"https:\/\/github.com\/Kotlin\/dukat\/issues\/292\" rel=\"noopener noreferrer nofollow\">issue<\/a> \u0432 Dukat \u0438 \u0433\u043e\u043b\u043e\u0441\u0443\u0435\u043c \u0437\u0430 \u043d\u0435\u0433\u043e. \u0410 \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043f\u043e\u043a\u0430 \u0431\u0430\u0433 \u043d\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u044f\u0442, \u043e\u0431\u043e\u0439\u0434\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0440\u0443\u0447\u043d\u044b\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432. <\/p>\n<p>\u0412\u044b\u0441\u0442\u0430\u0432\u0438\u043c <code>generateExternals = false<\/code> \u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0438\u0445 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>.\/gradlew generateExternals<\/code>. \u0414\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e <em>externals<\/em> \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c Kotlin\/JS \u043c\u043e\u0434\u0443\u043b\u044c <em>vscode<\/em>, \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u043d\u0435\u0433\u043e (\u0432\u044b\u043d\u043e\u0441\u0438\u0442\u044c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c dead code elimination \u0441\u043c\u043e\u0433 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0432\u044b\u0440\u0435\u0437\u0430\u0442\u044c \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043a\u043e\u0434 \u0438\u0437 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0433\u043e js-\u0444\u0430\u0439\u043b\u0430). \u041f\u043e\u0434\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434, \u043a\u0430\u043a \u0438 \u0441\u0430\u043c \u043c\u043e\u0434\u0443\u043b\u044c, \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0436\u0443, \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0435\u0433\u043e \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438. <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 <em>@types\/vscode<\/em> \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c:<\/p>\n<pre><code class=\"kotlin\">implementation(project(\":vscode\"))<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0441\u0440\u0430\u0437\u0443 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432 \u043e\u0434\u0438\u043d \u043a\u043b\u0438\u043a \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 VS Code:<\/p>\n<pre><code class=\"kotlin\">tasks.register(\"installExtension\", Sync::class) {     dependsOn(\"productionExecutableCompileSync\")     from({         kotlin.js().compilations.named(\"main\").map { it.npmProject.dir }     }) \/\/ build\/js\/packages\/&lt;\u0438\u043c\u044f \u043c\u043e\u0434\u0443\u043b\u044f>     into {         project.provider { File(providers.systemProperty(\"user.home\").get()).resolve(\".vscode\/extensions\").resolve(project.name) }     } \/\/ ~\/.vscode\/extensions\/&lt;\u0438\u043c\u044f \u043c\u043e\u0434\u0443\u043b\u044f>     doFirst {         logger.info(\"Installing VS Code extension into $destinationDir\")     } }<\/code><\/pre>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0431\u0443\u0434\u0435\u0442 \u0431\u0440\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 npm \u043c\u043e\u0434\u0443\u043b\u044c \u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f\u043c\u0438 VS Code <em>~\/.vscode\/extensions\/<\/em><\/p>\n<h2>\u041a\u043e\u0434 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0423\u0434\u0430\u043b\u0438\u043c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0430 IDEA, \u043e\u043d \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <em>extension.kt<\/em> \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u0445, \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0442\u043e\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u043e\u0442 Microsoft <a href=\"https:\/\/code.visualstudio.com\/api\/get-started\/your-first-extension\" rel=\"noopener noreferrer nofollow\">Your First Extension<\/a>:<\/p>\n<pre><code class=\"kotlin\">@JsExport fun activate(context: vscode.ExtensionContext) {     val disposable = vscode.commands.registerCommand(\"helloworld.helloWorld\", {         vscode.window.showInformationMessage(\"Hello World from Kotlin\/JS!\")     })      context.subscriptions.asDynamic().push(disposable) }  @JsExport fun deactivate() {  }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0430\u0448\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u043f\u043e \u0441\u0431\u043e\u0440\u043a\u0435 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 <code>.\/gradlew installExtension<\/code> \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 VS Code \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <em>Hello World<\/em>. \u0420\u0430\u0434\u0443\u0435\u043c\u0441\u044f \u0441\u0432\u043e\u0435\u043c\u0443 \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u043c\u0443 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044e \u043d\u0430 Kotlin\/JS \ud83d\ude42<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u041e\u0442\u043b\u0430\u0434\u043a\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f<\/h2>\n<p>\u041a\u0430\u043a\u0430\u044f \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u0430\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0431\u0435\u0437 \u043e\u0442\u043b\u0430\u0434\u043a\u0438?<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <em>build.gradle.kts<\/em> \u0437\u0430\u0434\u0430\u0447\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c VS Code \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u043e\u0442\u043b\u0430\u0434\u043a\u0438, \u043f\u043e\u0434\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044f \u043d\u0430\u0448\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438:<\/p>\n<pre><code class=\"kotlin\">tasks.register(\"debugExtension\", Exec::class) {     dependsOn(\"developmentExecutableCompileSync\")     val path = kotlin.js().compilations.named(\"main\").map { it.npmProject.dir }.get()     commandLine(\"code\", \"--inspect-extensions=9229\", \"--extensionDevelopmentPath=$path\") }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c Run configuration \u0432 IDEA:<\/p>\n<figure class=\"full-width\"><figcaption>IDEA run configuration<\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u0441\u0435\u0430\u043d\u0441 \u043e\u0442\u043b\u0430\u0434\u043a\u0438, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 <code>.\/gradlew debugExtension<\/code> \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0432\u0448\u0438\u0441\u044c \u0434\u0435\u0431\u0430\u0433\u0433\u0435\u0440\u043e\u043c \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435. \u0423 \u0432\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441, \u0430 \u0437\u0430\u0447\u0435\u043c, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u044d\u0442\u043e \u0432\u0441\u0451 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 TypeScript? \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b \u043b\u044e\u0431\u0438\u0442\u0435 Kotlin \u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Kotlin Multiplatform \u0438\u043b\u0438 Kotlin\/JS, \u0442\u043e\u0433\u0434\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e \u0434\u043b\u044f \u0432\u0430\u0441 \u0443\u0434\u043e\u0431\u043d\u0435\u0435. \u0418\u043b\u0438 \u0432\u044b \u0442\u0430\u043a\u043e\u0439 \u0436\u0435, \u043a\u0430\u043a \u0438 \u044f, <s>\u0431\u043e\u043b\u044c\u043d\u043e\u0439 \u043d\u0430 \u0433\u043e\u043b\u043e\u0432\u0443<\/s> \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0439\u0441\u044f \u0447\u0435\u043c-\u0442\u043e \u043d\u043e\u0432\u044b\u043c \u0438\u043d\u0436\u0435\u043d\u0435\u0440 \ud83d\ude09<\/p>\n<p><a href=\"https:\/\/github.com\/ALikhachev\/vs-code-hello-world-kt-extension\" rel=\"noopener noreferrer nofollow\">GitHub<\/a><\/p>\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\/582114\/\"> https:\/\/habr.com\/ru\/articles\/582114\/<\/a><br \/><\/br><\/br><\/p>\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-401028","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/401028","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=401028"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/401028\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=401028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=401028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=401028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}