npm helper to bootstrap sbt and link Scala.js (Scala 3) projects to JavaScript. Scala.js compiles through sbt; this package downloads sbt into node_modules and exposes npm scripts for common link and run tasks.
Published on npm: sjs-nodejs
Requirements: Node.js 18+
| Tool | Version |
|---|---|
| sbt | 1.10.7 |
| Scala | 3.5.2 |
| Scala.js | 1.21.0 |
In your Scala.js project:
npm install sjs-nodejsTo try changes in this repo from another Scala.js project without publishing to npm.
In this repository:
cd /path/to/sjs-nodejs
npm install
npm linkIn your Scala.js app:
cd /path/to/your-scalajs-app
npm link sjs-nodejsYour app’s node_modules/sjs-nodejs now points at your local clone. Re-run npm link sjs-nodejs after pulling changes if behavior looks stale.
To unlink later:
cd /path/to/your-scalajs-app
npm unlink sjs-nodejs
npm install sjs-nodejs # restore the published package, if neededIn your Scala.js app:
npm install /path/to/sjs-nodejs
# or, relative path:
npm install ../sjs-nodejspackage.json will record a file: dependency (for example "sjs-nodejs": "file:../sjs-nodejs").
Whichever option you use, add the same scripts to your app’s package.json so npm can find sbt and this package:
{
"scripts": {
"sbtInit": "node node_modules/sjs-nodejs/index.js",
"sjsBuild": "npm run sbtInit && node_modules/sbt/bin/sbt fastLinkJS",
"sjsBuildFull": "npm run sbtInit && node_modules/sbt/bin/sbt fullLinkJS",
"sjs": "node_modules/sbt/bin/sbt run"
}
}Then from your app directory:
npm run sjsBuildAdd these to your project's package.json (or rely on the same script names if you copy them from this package):
| Script | Command | Description |
|---|---|---|
sbtInit |
downloads & unpacks sbt | Run once (also run by build scripts) |
sjsBuild |
fastLinkJS |
Fast development link |
sjsBuildFull |
fullLinkJS |
Full optimizations for production |
sjs |
run |
Run the Scala.js app via sbt |
Example:
npm run sjsBuild # fast link
npm run sjsBuildFull # optimized link
npm run sjs # runproject/plugins.sbt
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.21.0")build.sbt
lazy val root = project
.in(file("."))
.enablePlugins(ScalaJSPlugin)
.settings(
scalaVersion := "3.5.2",
scalaJSUseMainModuleInitializer := true,
)project/build.properties
sbt.version=1.10.7- Targets Scala 3 and Scala.js 1.x (not Scala 2.12 / Scala.js 0.6).
- Build tasks renamed:
fastOptJS→fastLinkJS,fullOptJS→fullLinkJS. - Bundled sbt upgraded from 1.0.1 to 1.10.7.
https://github.com/devasthali-os/introv.scalajs
Maintainers: see docs/publishing.md for logging in to npm, pre-publish checks, npm publish, and verification on npmjs.com.