score:1
you cannot do that, because @jsimport
s must be top-level, and macros can only be called in places which are not top-level.
the reason that @jsimport
must be top-level is that it does not semantically correspond to require
. instead, it corresponds to import
in es2015. they desugar into require
when targeting commonjs modules, but that is a special case. dynamic uses of require
cannot be written in terms of import
in es2015, and therefore not in terms of @jsimport
either.
now the reason you have to tweak $g.require
into require
is another issue. it used to be the case that this was simply node.js hijacking javascript in a non-spec-compliant way, and scala.js would not allow you to access it. now it turns out that es2015 kind of makes that special require
thing valid-ish, so eventually you'll be able to access it natively in scala.js, through https://github.com/scala-js/scala-js/issues/2800
Source: stackoverflow.com
Related Query
- how to return a require call from macro in scala.js
- How can I call a Scala function taking a PartialFunction with a Unit return type from Java?
- How are Scala collections able to return the correct collection type from a map operation?
- How do you call a Scala singleton method from Java?
- How do you call Scala objects from Java?
- How to call main method of a Scala program from the main method of a java program?
- How do I get a scala macro to replace a method call
- How can I reflectively call a method on a Scala object from Java?
- How to call superclass constructor from child class in scala and how to do constructor chaining
- How to return Unit from a scala function?
- How does Scala implement return from within an expression?
- How to return multiple random elements from List scala
- How to call scala from python?
- How to call java method taking parameter as List<Class<?>> from Scala
- How to call function from hashmap in Scala
- How to return different results from Futures in Scala without ending up in nested if statements
- How to best implement "first success" in Scala (i.e., return the first success from a sequence of failure-prone operations)
- How to call a scala function from php?
- How can I call a method defined on a Scala package object from Java? (Scala 2.10.x)
- How to call wildcard java function from scala
- How to call a Scala function from Play html template
- Strange Scala compiler error when removing a call to a function that has Unit return type, how is this even possible?
- How to assign a function as a return type from function in Scala
- How to return a value from a Scala def
- How call function which is return from another one?
- How do I call Scala sealed traits from Kotlin?
- How to return selectively multiple rows from one rows in Scala
- Is it possible to call a scala macro from generic scala code?
- how to return value from a if block in scala
- How to call constructor from companion apply method in scala case class?
More Query from same tag
- Convert a List[(String, String)] to List[Map[String, String]] in scala
- Java Listener interface to Scala
- Why putStrLn of zio didn't output
- What is the proper way to code a read-while loop in Scala?
- How to create generic constraint based on dependent type?
- How to make Scala Power Pack for IntelliJ Idea to work?
- Slick select row by id
- Where is scala on node with spark-shell installed?
- Determine by parameter which member to change
- Scala Ordering Using Scala 2.11 having issue , but no issue while using 2.12
- Reading a large file in functional scala
- Guidance on play's execution context and creating my jdbc thread pool
- Flink: java.lang.UnsupportedOperationException: Cannot override partitioning for KeyedStream
- How to create a dataframe from a list of Scala custom objects
- I'm having problems connecting from gatling to a rabbit q using gatling-amqp-plugin
- Usage example of scalaz-stream's inflate
- Are Inheritance & Polymorphic Relations possible / a good idea with Slick?
- Replace the values based on condition spark
- Printing RDD to a text file with Header
- Header written multiple times while combining csv files using scala and spark
- NullPointerException when Plain SQL and String Interpolation
- How to use 'groupBy' method on a list of Int, & Strings
- SBT not loading properly in Intellij-Idea (no SBT external Imports)
- javascript var not updated (HTML+javascript+jquery)
- Can a for-compr yield 2 seperate variables
- How to convert a json value "aaa,bbb" to a "Seq[String]" with argonaut?
- Scala: How to access a shadowed function variable from an object
- IPv6ToBigInteger
- Scala Shapeless Code for Project Euler #2
- Scala pattern matching and type inference