kotlin - 生产模式下的 Kotlin/JS 错误:未捕获的 TypeError:属性描述符必须是对象,未定义
问题描述
我的反应网络应用程序在 BrowserDevelopmentRun 模式下运行,但 BrowserProductionRun 发生错误导致应用程序无法加载
导致错误的行部分如下所示(exzerpt):
_f4686g$=C.prototype.encodeNullableSerializableValue_f4686g$,vt.prototype.encodeSerializableValue
堆栈跟踪
Uncaught TypeError: Property descriptor must be an object, got undefined
3829 my-react-web-client.js:2
3829 my-react-web-client.js:2
o log$:13
i hot module replacement:363
9518 my-react-web-client.js:2
o log$:13
i hot module replacement:363
5325 StringOps.kt:42
o log$:13
<anonymous> jsonp chunk loading:484
<anonymous> jsonp chunk loading:484
<anonymous> universalModuleDefinition:9
<anonymous> universalModuleDefinition:10
my-react-web-client.js:2:730473
ObjectOrReflectDefineProperty self-hosted:2635
defineProperty self-hosted:2686
3829 my-react-web-client.js:2
3829 my-react-web-client.js:2
o log$:13
i hot module replacement:363
9518 my-react-web-client.js:2
o log$:13
i hot module replacement:363
5325 StringOps.kt:42
o log$:13
<anonym> jsonp chunk loading:484
<anonym> jsonp chunk loading:484
<anonym> universalModuleDefinition:9
<anonym> universalModuleDefinition:10
构建.gradle
plugins {
id 'org.jetbrains.kotlin.js' version '1.5.10'
}
repositories {
mavenCentral()
maven { url 'https://maven.pkg.jetbrains.space/public/p/kotlin/p/kotlin/kotlin-js-wrappers' }
}
dependencies {
testImplementation 'org.jetbrains.kotlin:kotlin-test-js'
implementation group: 'org.jetbrains.kotlin-wrappers', name: 'kotlin-react', version: '17.0.2-pre.212-kotlin-1.5.10'
implementation group: 'org.jetbrains.kotlin-wrappers', name: 'kotlin-react-dom', version: '17.0.2-pre.212-kotlin-1.5.10'
implementation group: 'org.jetbrains.kotlin-wrappers', name: 'kotlin-styled', version: '5.3.0-pre.212-kotlin-1.5.10'
implementation group: 'org.jetbrains.kotlin-wrappers', name: 'kotlin-css', version: '1.0.0-pre.212-kotlin-1.5.10'
implementation group: 'org.jetbrains.kotlin-wrappers', name: 'kotlin-redux', version: '4.0.5-pre.212-kotlin-1.5.10'
implementation group: 'org.jetbrains.kotlin-wrappers', name: 'kotlin-react-redux', version: '7.2.3-pre.212-kotlin-1.5.10'
implementation 'dev.gitlive:firebase-functions:1.3.1'
implementation 'dev.gitlive:firebase-auth:1.3.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0'
implementation 'org.kodein.di:kodein-di-js:7.6.0'
implementation npm("query-string", "7.0.0")
}
kotlin {
js(LEGACY) {
binaries.executable()
browser {
commonWebpackConfig {
cssSupport.enabled = true
}
}
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile).all {
kotlinOptions {
freeCompilerArgs += '-Xopt-in=kotlin.RequiresOptIn'
}
}
解决方案
推荐阅读
- firebase - Flutter:将日期时间转换为时间戳
- docker - 在 docker buildkit 中使用秘密标志的正确方法
- spring - 使用java实现弹性搜索过滤器聚合
- reactjs - Material-UI Data-Grid:如何将参数传递给自定义工具栏?
- pytorch - 如何将 Pytorch DataLoader 用于具有多个标签的数据集
- vue.js - Nuxt.js/Vue.js 动态图像不起作用
- amazon-web-services - 如何在 AWS EMR 上安装 Cudatoolkit 以在 Tensorflow 中启用分布式训练?
- xaml - DatePicker 不显示文本
- reactjs - 尝试使用 webpack 从目录动态导入图像时返回 void
- azure - CLI 脚本中的 Azure 资源锁删除延迟