{"id":18118463,"url":"https://github.com/platypii/sbt-typescript","last_synced_at":"2025-04-14T16:56:20.342Z","repository":{"id":40327887,"uuid":"240185490","full_name":"platypii/sbt-typescript","owner":"platypii","description":"An sbt plugin for compiling typescript","archived":false,"fork":false,"pushed_at":"2023-11-23T17:09:51.000Z","size":336,"stargazers_count":10,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T10:39:15.723Z","etag":null,"topics":["play-framework","playframework","sbt","sbt-plugin","sbt-web","scala","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/platypii.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-13T05:35:57.000Z","updated_at":"2024-12-20T07:26:49.000Z","dependencies_parsed_at":"2024-11-01T05:11:44.413Z","dependency_job_id":"a02c1cc3-793a-4ad2-8d5d-3048abb9f4d4","html_url":"https://github.com/platypii/sbt-typescript","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platypii%2Fsbt-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platypii%2Fsbt-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platypii%2Fsbt-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platypii%2Fsbt-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/platypii","download_url":"https://codeload.github.com/platypii/sbt-typescript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248923657,"owners_count":21183949,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["play-framework","playframework","sbt","sbt-plugin","sbt-web","scala","typescript"],"created_at":"2024-11-01T05:11:33.851Z","updated_at":"2025-04-14T16:56:20.319Z","avatar_url":"https://github.com/platypii.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sbt-typescript\n\n## Typescript :handshake: Scala\n\n\n[![workflow status](https://github.com/platypii/sbt-typescript/actions/workflows/ci.yml/badge.svg)](https://github.com/platypii/CloudBASE/actions)\n[![Maven Artifact](https://maven-badges.herokuapp.com/maven-central/com.github.platypii/sbt-typescript/badge.svg)](https://search.maven.org/search?q=g:com.github.platypii%20a:sbt-typescript)\n[![Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\nThis sbt plugin compiles the TypeScript code in your Play application to javascript fit for consumption by your average browser and device.\n\n## Setup\n\nFor Play 2.9+ projects, add the following line to your `project/plugins.sbt`:\n\n```scala\naddSbtPlugin(\"com.github.platypii\" % \"sbt-typescript\" % \"5.3.2\")\n```\n\nFor Play 2.8- projects, use the previous version `4.6.4`.\n\nIf your project is not a Play application you will have to enable `sbt-web` in `build.sbt`:\n\n    lazy val root = (project in file(\".\")).enablePlugins(SbtWeb)\n\nIt is STRONGLY RECOMMENDED that you have node installed.\nIt is possible to fallback to JVM-based trireme, but it is slow, and may not work with the latest javascript code.\n\n### Dependencies\n\nNPM libraries are used as standard sbt dependencies (jar files).\nAdd your typescript libraries as dependencies as follows.\nIf the library doesn't include typescript definitions add them too.\n```scala\nresolvers += Resolver.bintrayRepo(\"webjars\",\"maven\")\nlibraryDependencies ++= Seq(\n    \"org.webjars.npm\" % \"react\" % \"15.4.0\",\n    \"org.webjars.npm\" % \"types__react\" % \"15.0.34\"\n)\n ```\nThese NPM dependencies are resolved through [WebJars](https://www.webjars.org/).\nCheck whether the versions of the NPM packages you need are available there.\nIf not, you can add webjars to maven through the webjars.org website.\nSince we added the webjars resolver they will be available immediately.\nOtherwise, you would have to wait before being able to use them.\nNPM package names like `@angular/code` and `@types/react` are a bit different in webjars: `angular__react` and `types__react`.\nAdd the following to `build.sbt` to resolve against those npms.\n\n    resolveFromWebjarsNodeModulesDir := true\n\nTo lint your TypeScript code add [`sbt-tslint`](https://github.com/joost-de-vries/sbt-tslint) to your project and create a `tslint.json` file with the linting rules.\n\n### Configuration\n\nCreate a `tsconfig.json` file in the root of your project with the required [compiler options](https://www.typescriptlang.org/docs/handbook/compiler-options.html).\n\nThe following `tsc` compiler options are managed by `sbt-typescript` so setting them in `tsconfig.json` has no effect: `outDir`, `rootDirs`, `paths`, `baseUrl`, `typeRoots`.\nIf you use the `stage` compile mode the `outFile` option is also managed by `sbt-typescript`.\n\nOption                 | Description\n-----------------------|------------\noutFile                | Concatenate and emit output to a single file.\noutDir                 | Destination directory for output files.\ntypingsFile            | A file that refers to typings that the build needs. Default None, but would normally be \"/typings/index.d.ts\"\n\nTo be able to view the original Typescript code from your browser when developing add the following to `tsconfig.json`\n```json\n\"compilerOptions\": {\n    \"sourceMap\": true,\n    \"mapRoot\": \"/assets\",\n    \"sourceRoot\": \"/assets\",\n```\n\nYou can get more verbose logging of what sbt-typescript is doing by adding to `build.sbt`:\n```scala\ntypescript / logLevel := Level.Debug\n```\n\n### Testing\n\nTo test your TypeScript code add an sbt plugin for a JS test framework.\nFor instance [sbt-jasmine](https://github.com/joost-de-vries/sbt-jasmine) or [sbt-mocha](https://github.com/sbt/sbt-mocha).\nYou can override `tsc` configurations for your test code.\nTo do that create a file `tsconfig.test.json` and add to `build.sbt`\n\n    (typescript / projectTestFile) := Some(\"tsconfig.test.json\")\n\nAny settings in that file will override those in `tsconfig.json` for the compilation of test code.\n\n#### Configuring an IDE\nThe typescript version of your project can be found in `project/target/node-modules/webjars/typescript`.\nConfigure your IDE to use that and point it to the `tsconfig.json`.\n\n#### Compiling directly through tsc\nSometimes it can be helpful to compile your project directly through the TypeScript compiler without `sbt-typescript` in between to check whether a problem is an `sbt-typescript` problem.\nTo do that you can run\n\n```bash\nproject/target/node-modules/webjars/typescript/bin/tsc -p . -w\n```\nMake sure to set the executable bit if necessary.\nFor this kind of compilation to work you have to fill in the settings in `tsconfig.json` that `sbt-typescript` normally manages.\nSee the [Angular2 demo project](https://github.com/joost-de-vries/play-angular-typescript.g8/blob/master/src/main/g8/tsconfig.json) for an example.\n\n#### Compiling to a single js file\nYou can develop using individual javascript files when running `sbt ~run` in Play and have your whole typescript application concatenated into a single javascript output file for your stage environment without changes to your sources.\nTo do that you have to add a `-DtsCompileMode=stage` parameter to the sbt task in your CI that creates the stage app.\nSo for Play that will often be `sbt stage -DtsCompileMode=stage`.\n\n#### Import modules without type information\nIf you are importing modules for which you don't have the typings you can ignore the TS2307 `can not find module` error:\n\n    tsCodesToIgnore := List(canNotFindModule)\n\n## Publishing sbt-typescript\n\nUse sbt-sonatype plugin.\n\n```\nsbt publishSigned\nsbt sonatypeBundleRelease\n```\n\n## History\n\nThis project was started by Brandon Arp: https://github.com/ArpNetworking/sbt-typescript\n\nWith further contributions by Joost de Vries: https://github.com/joost-de-vries/sbt-typescript\n\nAdopted by platypii: https://github.com/platypii/sbt-typescript\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplatypii%2Fsbt-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplatypii%2Fsbt-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplatypii%2Fsbt-typescript/lists"}