Struggling with Kotlin JS project using kotlin-frontend-plugin


#1

Hi there!

I’m trying to setup my own Kotlin JS project using Gradle and I want use the kotlin-frontend-plugin. My ultimat goal with this project is to use React with Kotlin (I hope that is feasible using the kotlin-frontend-plugin).

I’ve been trying to follow the directions here: https://github.com/Kotlin/kotlin-frontend-plugin

However my build fails with the following message: Error: Cannot find module ‘qunit’

21:16:32: Executing task ‘build’…

:nodejs-download UP-TO-DATE
:npm-preunpack UP-TO-DATE
:npm-configure UP-TO-DATE
:npm-install UP-TO-DATE
:npm-index UP-TO-DATE
:npm-deps
:npm
:packages
:compileKotlin2Js UP-TO-DATE
:processResources NO-SOURCE
:processTestResources NO-SOURCE
:webpack-config UP-TO-DATE
:webpack-helper SKIPPED
:webpack-bundle UP-TO-DATE
:bundle
:compileJava NO-SOURCE
:classes UP-TO-DATE
:jar UP-TO-DATE
:assemble
:compileTestKotlin2Js UP-TO-DATE
:karma-config
A problem was found with the configuration of task ‘:karma-config’. Registering invalid inputs and outputs via TaskInputs and TaskOutputs methods has been deprecated and is scheduled to be removed in Gradle 5.0.

  • Directory ‘/Users/freshlyground/kotlin-frontend-plugin-ex1/karma.config.d’ specified for property ‘$1’ does not exist.
    :karma-config UP-TO-DATE
    :karma-run-single
    18 04 2018 21:16:33.991:ERROR [preprocess]: Can not load “…”!
    Error: No provider for “preprocessor:”! (Resolving: preprocess -> preprocessor:)
    at error (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/di/lib/injector.js:22:12)
    at Object.get (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/di/lib/injector.js:9:13)
    at get (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/di/lib/injector.js:54:19)
    at Injector.get (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/di/lib/injector.js:28:19)
    at instantiatePreprocessor (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/karma/lib/preprocessor.js:55:20)
    at Array.forEach ()
    at createPreprocessor (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/karma/lib/preprocessor.js:74:20)
    at Array.invoke (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/di/lib/injector.js:75:15)
    at get (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/di/lib/injector.js:48:43)
    at /Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/di/lib/injector.js:71:14
    at Array.map ()
    at Injector.invoke (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/di/lib/injector.js:70:31)
    at Server.start (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/karma/lib/server.js:126:18)
    at Object.exports.run (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/karma/lib/cli.js:283:26)
    at Object. (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/karma/bin/karma:3:23)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
    internal/modules/cjs/loader.js:550
    throw err;
    ^

Error: Cannot find module ‘qunit’
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
at Function.resolve (internal/modules/cjs/helpers.js:18:19)
at initQUnit (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/karma-qunit/lib/index.js:14:39)
at Array.invoke (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/di/lib/injector.js:75:15)
at Injector.get (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/di/lib/injector.js:48:43)
at /Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/karma/lib/server.js:166:20
at Array.forEach ()
at Server._start (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/karma/lib/server.js:165:21)
at Injector.invoke (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/di/lib/injector.js:75:15)
at Server.start (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/karma/lib/server.js:126:18)
at Object.exports.run (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/karma/lib/cli.js:283:26)
at Object. (/Users/freshlyground/kotlin-frontend-plugin-ex1/build/node_modules/karma/bin/karma:3:23)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
:karma-run-single FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:karma-run-single’.

Process ‘command ‘/Users/freshlyground/.gradle/nodejs/node-v9.11.1-darwin-x64/bin/node’’ finished with non-zero exit value 1

My project is available for easy cloning here:

Does anyone know what I’m doing wrong?


#2

This is known issue with the current version of kotlin-frontend-plugin:


#3

Thanks for pointing that out :slight_smile:

By adding a dev dependency to qunit, the build came further but now crashes on:

ERROR in ./js-tests/kotlin-frontend-plugin-ex1-tests.js
Module not found: Error: Can't resolve 'kotlin-test' in '/Users/freshlyground/Code/kotlin-frontend-plugin-ex1/build/js-tests'
 @ ./js-tests/kotlin-frontend-plugin-ex1-tests.js 26:37-59