File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -170,3 +170,5 @@ val documentedSubprojects
170170 " kotlinx-serialization-hocon" ,
171171 " kotlinx-serialization-protobuf"
172172 )
173+
174+ project.configureJsCacheRedirector()
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2017-2026 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+ */
4+
5+ import org.gradle.api.Project
6+ import org.gradle.kotlin.dsl.the
7+ import org.gradle.kotlin.dsl.withType
8+ import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport
9+
10+ const val DEFAULT_YARN_REGISTRY = " https://registry.yarnpkg.com"
11+ const val NPM_REGISTRY_CACHE = " https://cache-redirector.jetbrains.com/registry.npmjs.org"
12+ const val NODE_DIST_CACHE = " https://cache-redirector.jetbrains.com/nodejs.org/dist"
13+ const val YARN_DIST_CACHE = " https://cache-redirector.jetbrains.com/github.com/yarnpkg/yarn/releases/download"
14+
15+ fun Project.configureJsCacheRedirector () {
16+ rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin ::class .java) {
17+ rootProject.the< org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension > ().restoreYarnLockTaskProvider.configure {
18+ doLast {
19+ // yarn 1.x doesn't and won't support overriding registry used in yarn.lock, so we need to replace it manually
20+ // https://github.com/yarnpkg/yarn/issues/6436#issuecomment-426728911
21+ val lockFile = outputFile.get()
22+ lockFile.writeText(lockFile.readText().replace(DEFAULT_YARN_REGISTRY , NPM_REGISTRY_CACHE ))
23+ }
24+ }
25+ rootProject.the< org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootEnvSpec > ().downloadBaseUrl.set(YARN_DIST_CACHE )
26+ }
27+
28+ rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin ::class .java) {
29+ rootProject.the< org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsEnvSpec > ().downloadBaseUrl.set(NODE_DIST_CACHE )
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments