Git Product home page Git Product logo

Comments (11)

ekrich avatar ekrich commented on May 31, 2024

@andares This is a bug, thanks for reporting. This class is missing in the Scala.js Java library and because all the tests are not run with Scala.js - this bug was not found.

Right now we cannot share tests because we don't have a shared test framework for all three platforms but I would like to find or have a test for this so if you could supply the code you used to create the error it would be helpful.

from sconfig.

andares avatar andares commented on May 31, 2024

I'm glad to be able to support.

here is my code, I have to say I'm a beginner in scala 😹

package example

import org.ekrich.config._
import scala.io.Source

object Test extends App {
  def parseFile() = {
    // That's not work, need `java.io.File`
    val config = ConfigFactory.parseString("main.conf")
    println(config.resolve)
    // println(config)
  }

  def parseString() = {
    val content = """
_pattern.default.main = "../default/main.conf"

core = {
  version: 0.1
  extends: [
    ${_pattern.default.main}
  ]
}
"""
    val config = ConfigFactory.parseString(content)
    println(config.resolve) // That's crash
    // println(config) // That's ok
  }

  // --> run test
  // parseFile
  parseString
}

here is build.sbt content:

import Dependencies._

ThisBuild / scalaVersion     := "2.12.8"
ThisBuild / version          := "0.1.0-SNAPSHOT"
ThisBuild / organization     := "com.example"
ThisBuild / organizationName := "example"

lazy val root = (project in file("."))
  .settings(
    name := "bhc",
    libraryDependencies += scalaTest % Test,
  )

// See https://www.scala-sbt.org/1.x/docs/Using-Sonatype.html for instructions on how to publish to Sonatype.

// sconfig
libraryDependencies += "org.ekrich" %%% "sconfig" % "0.9.+"

// scalajs
enablePlugins(ScalaJSPlugin)
scalaJSUseMainModuleInitializer := true

Talk a little more, at the beginning I thought I could get the best support for hocon in scala. but I found Scala relies heavily on java libraries on the jvm platform. I think scalajs is hard to deal with, may be use js lib by interop is better way 🤣

from sconfig.

ekrich avatar ekrich commented on May 31, 2024

Scala.js doesn't have any support for java.io.File so we don't expect that to work but I think you should be able to call resolve but right now Scala.js doesn't have support for IdentityHashMap. I may be able to add it locally at first until we can get it added to Scala.js.

from sconfig.

andares avatar andares commented on May 31, 2024

That's ok, thank you for the reply 👍

from sconfig.

ekrich avatar ekrich commented on May 31, 2024

Test with working example - https://github.com/ekrich/sconfig/blob/master/sconfig/native/src/test/scala/ConfigFactoryTests.scala#L43-L62

from sconfig.

andares avatar andares commented on May 31, 2024

That's great! I have try it again.

from sconfig.

ekrich avatar ekrich commented on May 31, 2024

@andares Sorry, I didn't mean to mislead you. I am still working on the Scala.js support for this feature. I just made a test case that works on Scala Native that I can use to test when finishing development on Scala.js. I will close this ticket out once completed and then will need to make a new release for the Scala.js support of this feature.

from sconfig.

andares avatar andares commented on May 31, 2024

I see, I have parse hocon file with npm lib now, never mind 👌

from sconfig.

ekrich avatar ekrich commented on May 31, 2024

I'm sorry you had to resort to that but thanks for reporting and your interest. I have been working on this issue but it requires adding java.util.IdentityHashMap to Scala.js, first locally and then via a PR to Scala.js. It may be working but I just found out how to do resolve myself. I am not a config expert but have spent a bunch of time porting this library.

If you are using Scala.js you can get help here - https://gitter.im/scala-js/scala-js There is another HOCON lib for Scala.js that is very lightweight. https://github.com/akka-js/shocon I hope you keep using Scala.js.

If you would like to discuss further you can find me here as well. https://gitter.im/ekrich/sconfig

from sconfig.

andares avatar andares commented on May 31, 2024

Thank you for your help indeed. I'll keep trying Scala.js in my project. As compile to js language, use npm lib to resolve problem is also possible 😄 You can close the issue when the work is over.

from sconfig.

ekrich avatar ekrich commented on May 31, 2024

Fixed by #57

from sconfig.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.