@@ -11,6 +11,9 @@ version = "1.4.0-SNAPSHOT"
11
11
12
12
java.sourceCompatibility = JavaVersion .VERSION_1_8
13
13
14
+
15
+
16
+
14
17
idea {
15
18
module {
16
19
isDownloadSources = true
@@ -290,4 +293,69 @@ publishing {
290
293
}
291
294
}
292
295
}
293
- }
296
+ }
297
+
298
+
299
+
300
+ /* ******FIX JS DEPS******** https://blog.jetbrains.com/kotlin/2021/10/control-over-npm-dependencies-in-kotlin-js/ *****/
301
+ rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin ::class .java) {
302
+ rootProject.the< org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension > ().disableGranularWorkspaces()
303
+ }
304
+ tasks.register(" backupYarnLock" ) {
305
+ dependsOn(" :kotlinNpmInstall" )
306
+
307
+ doLast {
308
+ copy {
309
+ from(" $rootDir /build/js/yarn.lock" )
310
+ rename { " yarn.lock.bak" }
311
+ into(rootDir)
312
+ }
313
+ }
314
+
315
+ inputs.file(" $rootDir /build/js/yarn.lock" ).withPropertyName(" inputFile" )
316
+ outputs.file(" $rootDir /yarn.lock.bak" ).withPropertyName(" outputFile" )
317
+ }
318
+
319
+ val restoreYarnLock = tasks.register(" restoreYarnLock" ) {
320
+ doLast {
321
+ copy {
322
+ from(" $rootDir /yarn.lock.bak" )
323
+ rename { " yarn.lock" }
324
+ into(" $rootDir /build/js" )
325
+ }
326
+ }
327
+
328
+ inputs.file(" $rootDir /yarn.lock.bak" ).withPropertyName(" inputFile" )
329
+ outputs.file(" $rootDir /build/js/yarn.lock" ).withPropertyName(" outputFile" )
330
+ }
331
+
332
+ tasks.named(" kotlinNpmInstall" ).configure {
333
+ dependsOn(restoreYarnLock)
334
+ }
335
+
336
+ tasks.register(" validateYarnLock" ) {
337
+ dependsOn(" :kotlinNpmInstall" )
338
+
339
+ doLast {
340
+ val expected = file(" $rootDir /yarn.lock.bak" ).readText()
341
+ val actual = file(" $rootDir /build/js/yarn.lock" ).readText()
342
+
343
+ if (expected != actual) {
344
+ throw AssertionError (
345
+ " Generated yarn.lock differs from the one in the repository. " +
346
+ " It can happen because someone has updated a dependency and haven't run `./gradlew :backupYarnLock --refresh-dependencies` " +
347
+ " afterwards."
348
+ )
349
+ }
350
+ }
351
+
352
+ inputs.files(" $rootDir /yarn.lock.bak" , " $rootDir /build/js/yarn.lock" ).withPropertyName(" inputFiles" )
353
+ }
354
+
355
+ allprojects {
356
+ tasks.withType< org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask > {
357
+ args + = " --ignore-scripts"
358
+ }
359
+ }
360
+
361
+ /* *********************************************************************************************************************/
0 commit comments