我一直试图让它工作一天左右,但没有运气。Webpack 似乎没有将kotlin
npm 模块注入我的测试,即使它是由 webpack 加载的。所以它抛出下面的错误说它找不到它。
这是错误日志:
Asset Size Chunks Chunk Names
main 1.55 MB 0 [big] main
classes/java/test/vuekt_test.js 1.37 MB 1 [big] classes/java/test/vuekt_test.js
chunk {0} main (main) 1.55 MB [entry]
[0] ./~/process/browser.js 5.42 kB {0} {1}
[1] ./~/kotlin/kotlin.js 1.31 MB {0} {1}
[2] ./js/kitchensink/kotlin/MyComponent.html 2.59 kB {0} {1}
[3] ./js/kitchensink/kotlin/VueApp.html 725 bytes {0} {1}
[4] ./~/vue/dist/vue.runtime.esm.js 187 kB {0}
[5] ./js/vuekt.js 40 kB {0}
[6] (webpack)/buildin/global.js 509 bytes {0}
chunk {1} classes/java/test/vuekt_test.js (classes/java/test/vuekt_test.js) 1.36 MB [entry]
[0] ./~/process/browser.js 5.42 kB {0} {1}
[1] ./~/kotlin/kotlin.js 1.31 MB {0} {1}
[2] ./js/kitchensink/kotlin/MyComponent.html 2.59 kB {0} {1}
[3] ./js/kitchensink/kotlin/VueApp.html 725 bytes {0} {1}
[7] ./classes/java/test/vuekt_test.js 40.6 kB {1} [built]
webpack: Compiled successfully.
webpack: Compiling...
30 06 2017 08:36:42.464:INFO [PhantomJS 2.1.1 (Windows 7 0.0.0)]: Connected on socket RaGM1IMTAMuV2JRuAAAA with id 80698172
PhantomJS 2.1.1 (Windows 7 0.0.0) ERROR
Error: Error loading module 'vuekt_test'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'vuekt_test'.
at classes/java/test/vuekt_test.js:35113
正如您在这一行的日志中看到的那样[1] ./~/kotlin/kotlin.js 1.31 MB {0} {1}
,kotlin-stdlib-js 资源正在被 webpack 加载。
它也包含在main
您可以看到在此行上加载的捆绑包中
main 1.55 MB 0 [big] main
但是,它没有被注入vuekt_test.js
. 这就是您在上面看到的错误被抛出的原因。
我不知道如何让它注入kotlin
它。
这是我的配置build.gradle
:
kotlinFrontend {
npm {
dependency("vue", "2.3.4")
devDependency("vue-template-compiler", "2.3.4")
devDependency("vue-template-es2015-compiler", "1.5.2")
devDependency("vue-template-loader", "0.3.1") //this requires the above 2 devDependencies
devDependency("webpack", "2.6.1")
devDependency("webpack-dev-server", "2.4.4")
devDependency("css-loader", "0.28.4")
devDependency("style-loader", "0.18.2")
devDependency("to-string-loader", "1.1.5")
devDependency("file-loader", "0.11.2")
devDependency("karma")
}
webpackBundle {
bundleName = "main"
contentPath = file('src/web')
port = 9002
}
karma {
port = 9876
runnerPort = 9100
reporters = ["progress"]
frameworks = ["qunit"]
}
}
这是karma.conf.js
文件:
var webpackConfig = require("C:\\my_workspace\\vue.kt\\build\\webpack.config.js");
webpackConfig.resolve.modules.push("C:\\my_workspace\\vue.kt\\build\\classes\\java\\test\\vuekt_test.js");
module.exports = function (config) {
config.set({
"basePath": "C:\\my_workspace\\vue.kt\\build",
"frameworks": [
"qunit"
],
"reporters": [
"progress"
],
"files": [
"C:\\my_workspace\\vue.kt\\build\\classes\\java\\test\\vuekt_test.js"
],
"exclude": [
"*~",
"*.swp",
"*.swo"
],
"port": 9876,
"runnerPort": 9100,
"colors": false,
"autoWatch": true,
"browsers": [
"PhantomJS"
],
"captureTimeout": 5000,
"singleRun": false,
"preprocessors": {
"C:\\my_workspace\\vue.kt\\build\\classes\\java\\test\\vuekt_test.js": [
"webpack"
]
},
"plugins": [
"karma-phantomjs-launcher",
"karma-qunit",
"karma-webpack"
],
"client": {
"clearContext": false,
"qunit": {
"showUI": true,
"testTimeout": 5000
}
},
"webpack": webpackConfig
})
};
我需要做什么来解决这个问题?