Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cut down on bundle size by tag-building at compile time #263

Open
wants to merge 6 commits into
base: master
from
Open
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -2,8 +2,6 @@ organization in ThisBuild := "me.shadaj"

scalaVersion in ThisBuild := "2.12.8"

scalacOptions in ThisBuild ++= Seq("-feature", "-deprecation")

lazy val slinky = project.in(file(".")).aggregate(
readWrite,
core,
@@ -42,18 +40,14 @@ def commonScalacOptions(scalaVersion: String) = {
"-encoding",
"UTF-8",
"-feature",
"-language:existentials",
"-language:higherKinds",
"-language:implicitConversions",
"-language:experimental.macros",
"-unchecked",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard"
"-Ywarn-value-discard",
"-deprecation"
) ++ (if (priorTo2_13(scalaVersion)) {
Seq(
"-Xfuture",
"-Yno-adapted-args",
"-deprecation",
"-Xfatal-warnings" // fails Scaladoc compilation on 2.13
)
} else {
@@ -12,7 +12,7 @@ import scala.language.implicitConversions
import scala.reflect.macros.whitebox

final class KeyAndRefAddingStage[D](private val args: js.Array[js.Any]) extends AnyVal {
@inline def withKey(key: String): KeyAndRefAddingStage[D] = {
def withKey(key: String): KeyAndRefAddingStage[D] = {
if (args(0) == null) {
throw new IllegalStateException("This component has already been built into a ReactElement, and cannot be reused")
}
@@ -21,7 +21,7 @@ final class KeyAndRefAddingStage[D](private val args: js.Array[js.Any]) extends
this
}

@inline def withRef(ref: D => Unit): KeyAndRefAddingStage[D] = {
def withRef(ref: D => Unit): KeyAndRefAddingStage[D] = {
if (args(0) == null) {
throw new IllegalStateException("This component has already been built into a ReactElement, and cannot be reused")
}
@@ -30,7 +30,7 @@ final class KeyAndRefAddingStage[D](private val args: js.Array[js.Any]) extends
this
}

@inline def withRef(ref: ReactRef[D]): KeyAndRefAddingStage[D] = {
def withRef(ref: ReactRef[D]): KeyAndRefAddingStage[D] = {
if (args(0) == null) {
throw new IllegalStateException("This component has already been built into a ReactElement, and cannot be reused")
}
@@ -41,7 +41,7 @@ final class KeyAndRefAddingStage[D](private val args: js.Array[js.Any]) extends
}

object KeyAndRefAddingStage {
@inline implicit def build[D](stage: KeyAndRefAddingStage[D]): ReactElement = {
implicit def build[D](stage: KeyAndRefAddingStage[D]): ReactElement = {
if (stage.args(0) == null) {
throw new IllegalStateException("This component has already been built into a ReactElement, and cannot be reused")
}
@@ -18,10 +18,8 @@ final class BuildingComponent[E, R <: js.Object](private val args: js.Array[js.A
mods.foreach {
case a: AttrPair[_] =>
args(1).asInstanceOf[js.Dictionary[js.Any]](a.name) = a.value
case o: OptionalAttrPair[_] =>
if (o.value.isDefined) args(1).asInstanceOf[js.Dictionary[js.Any]](o.name) = o.value.get
case r =>
args.push(r.asInstanceOf[ReactElementMod])
args.push(r.asInstanceOf[ReactElement])
}

this
@@ -56,7 +54,7 @@ final class BuildingComponent[E, R <: js.Object](private val args: js.Array[js.A
}

object BuildingComponent {
@inline implicit def make[E, R <: js.Object](comp: BuildingComponent[E, R]): ReactElement = {
implicit def make[E, R <: js.Object](comp: BuildingComponent[E, R]): ReactElement = {
if (comp.args(0) == null) {
throw new IllegalStateException("This component has already been built into a ReactElement, and cannot be reused")
}
@@ -10,7 +10,7 @@ import scala.language.experimental.macros
import scala.language.implicitConversions

final class KeyAddingStage(private val args: js.Array[js.Any]) extends AnyVal {
@inline def withKey(key: String): ReactElement = {
def withKey(key: String): ReactElement = {
if (args(0) == null) {
throw new IllegalStateException("This component has already been built into a ReactElement, and cannot be reused")
}
@@ -21,7 +21,7 @@ final class KeyAddingStage(private val args: js.Array[js.Any]) extends AnyVal {
}

object KeyAddingStage {
@inline implicit def build(stage: KeyAddingStage): ReactElement = {
implicit def build(stage: KeyAddingStage): ReactElement = {
if (stage.args(0) == null) {
throw new IllegalStateException("This component has already been built into a ReactElement, and cannot be reused")
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.