kotlinx.coroutines
kotlinx.coroutines copied to clipboard
Missing kotlinx-atomicfu
Using coroutines in nodejs, it requires kotlinx-atomicfu
but there is no kotlinx-atomicfu
as a dependency in the coroutines package.json.
Here is the top part of the kotlinx-coroutines-core.js
:
(function (root, factory) {
if (typeof define === 'function' && define.amd)
define(['exports', 'kotlin', 'kotlinx-atomicfu'], factory);
else if (typeof exports === 'object')
factory(module.exports, require('kotlin'), require('kotlinx-atomicfu'));
else {
if (typeof kotlin === 'undefined') {
throw new Error("Error loading module 'kotlinx-coroutines-core'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'kotlinx-coroutines-core'.");
}
if (typeof this['kotlinx-atomicfu'] === 'undefined') {
throw new Error("Error loading module 'kotlinx-coroutines-core'. Its dependency 'kotlinx-atomicfu' was not found. Please, check whether 'kotlinx-atomicfu' is loaded prior to 'kotlinx-coroutines-core'.");
}
root['kotlinx-coroutines-core'] = factory(typeof this['kotlinx-coroutines-core'] === 'undefined' ? {} : this['kotlinx-coroutines-core'], kotlin, this['kotlinx-atomicfu']);
}
}(this, function (_, Kotlin, $module$kotlinx_atomicfu) {
'use strict';
I get the error:
ERROR in ./node_modules/kotlinx-coroutines-core/kotlinx-coroutines-core.js
Module not found: Error: Can't resolve 'kotlinx-atomicfu' in ...
Should there be an extra dependency for kotlinx-atomicfu
in the package.json?
are there any workarounds for this issue until its fixed?
Hi! This issue will not be fixed for JS legacy atomicfu transformation, instead you can turn on JS IR transformation (see https://github.com/Kotlin/kotlinx-atomicfu#transformation-modes)
If you're using the last kotlinx-atomicfu
version, and Kotlin >= 1.7.20
then just add this property to your gradle.properties
file:
kotlinx.atomicfu.enableJsIrTransformation=true