Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Add support for scala.js #14

Draft
wants to merge 3 commits into
base: upstream/scalapb-deps-toolchain
Choose a base branch
from

Conversation

gvacaliuc
Copy link

@gvacaliuc gvacaliuc commented Mar 2, 2021

Description

Adding the following rules:

  • scalajs_library
  • scalajs_binary
  • scalajs_proto_library
    • with support for grpcweb

Example usage: https://github.com/gvacaliuc/bazel-scalapb-grpcweb-example

This currently works with unary rpc calls, but there is some mangled error that I believe to be from the from the minified grpc-web source on the client side. Confirmed that the server is streaming results back to the client, but the client does not process the returned stream.

I think that there is something called a "source map" which will let us debug from the minified JS to original source (which will help us debug the grpc-web error) and the minifed JS to the original SCALA (so you can debug your scala.js code). The scala.js linker has some options to configure it.

issues

  • move scalajs rules to a seperate scala_js.bzl file
  • figure out what a source map is and how we can plumb it through bazel to webpack
  • determine if it makes sense to look into rules_nodejs for some of their provider values (so that scalajs_ rules accurately reflect what they provide rather than masquerading as JavaInfo providers
    • if so, add an example w/ esbuild to that above
  • determine what the dev/prod lifecycle looks like (sbt has fastOpt/fullOpt)
  • figure out how to write tests in scala.js
  • figure out how to write tests for these rules
  • clean up library so that we just override the compile phase
  • the proto library methods conflict with each other because they introduce an aspect w/ the same name, namely they both codegen scala for their proto dependencies (can we share...?)
  • fix issues w/ the scala dep provider toolchain (rules_scala build fails w/o a properly configured toolchain, e.g. one that is provided in the example above)

This is a good link to understand what's going on with scala.js: http://www.lihaoyi.com/hands-on-scala-js/#TheCompilationPipeline

Motivation

@gvacaliuc gvacaliuc requested a review from tian000 March 2, 2021 08:38
("write_manifest", phase_write_manifest),
("dependency", phase_dependency_common),
("collect_jars", phase_collect_jars_common),
("compile", phase_compile_scalajs_library),
Copy link
Author

@gvacaliuc gvacaliuc Mar 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think that there is a way to change the compile phase here w/o creating a whole new rule

@gvacaliuc gvacaliuc changed the title working scalajs library and binary Add support for scala.js Mar 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant