Giter Site home page Giter Site logo

Comments (11)

julienrf avatar julienrf commented on August 17, 2024

Hi, you should not set the scalaJSModuleKind to NoModule when using the module bundler. Let it be CommonJSModule.

Also, can you show me the code of your facade and the way you use it?

Last, Iโ€™m not totally sure but I think the right scope for the webpack task is webpack in (Compile, fullOptJS).

from scalajs-bundler.

mathieuleclaire avatar mathieuleclaire commented on August 17, 2024

Hi, this two modifications lead to this:

demo.js:2 Uncaught ReferenceError: exports is not defined
index.html:13 Uncaught ReferenceError: demo is not defined

That's why I had switched from NoModule to CommonJSModule.
And my facade is this:

import org.scalajs.dom.Element
import scala.scalajs.js

@js.native
class Modal(element: Element) extends js.Object {

  def open(): Unit = js.native
  def close(): Unit = js.native
}

I tried to use JSImport, but I didn't understand how to use it, but it is certainly the key !

from scalajs-bundler.

julienrf avatar julienrf commented on August 17, 2024

Indeed you have to use @JSImport. Does this section help? Can you elaborate on whatโ€™s unclear?

from scalajs-bundler.

julienrf avatar julienrf commented on August 17, 2024

In your case, I guess you want to annotate your Modal class with the following: @JSImport("bootstrap.native", "Modal")

from scalajs-bundler.

mathieuleclaire avatar mathieuleclaire commented on August 17, 2024

Mmh, same result sadely :(. I do not understand what is the JSImport first parameter ? A js file name ? A namespace ?

from scalajs-bundler.

julienrf avatar julienrf commented on August 17, 2024

Could you share a project from which I can reproduce the issue, please?

The first parameter of @JSImport is the CommonJS module name, as explained in the documentation

from scalajs-bundler.

julienrf avatar julienrf commented on August 17, 2024

BTW, why are you enabling the WebScalaJSBundlerPlugin on the demo project?

from scalajs-bundler.

mathieuleclaire avatar mathieuleclaire commented on August 17, 2024

Yes I do. I pushed my modifications in the scalajsbundler branch in the repo https://github.com/openmole/scaladget. Launch the runDemo key. And then open the demo/target/index.html. Thanks !

from scalajs-bundler.

julienrf avatar julienrf commented on August 17, 2024

I fixed the problem here: openmole/scaladget#8

from scalajs-bundler.

mathieuleclaire avatar mathieuleclaire commented on August 17, 2024

Yes, it works fine ! Thanks. This plugin is really amazing. It render possible to build really smart libs !

from scalajs-bundler.

julienrf avatar julienrf commented on August 17, 2024

Good to know that it works for you :)

from scalajs-bundler.

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.