kotlinx.coroutines icon indicating copy to clipboard operation
kotlinx.coroutines copied to clipboard

Missing kotlinx-atomicfu

Open michaelprichardson opened this issue 2 years ago • 1 comments

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?

michaelprichardson avatar Jul 15 '22 16:07 michaelprichardson

are there any workarounds for this issue until its fixed?

bassammohtaseb avatar Aug 01 '22 20:08 bassammohtaseb

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

mvicsokolova avatar Nov 14 '22 12:11 mvicsokolova