-
Notifications
You must be signed in to change notification settings - Fork 232
Re-enable Javascript support #1347
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
Open
smocherla-brex
wants to merge
21
commits into
bazelbuild:master
Choose a base branch
from
smocherla-brex:smocherla/re-enable-kotlin-js
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5e634fb
Initial commit to re-enable JS support, add native toolchain
smocherla-brex 61d5005
wip
smocherla-brex 0fb2762
Simple klib examples working
smocherla-brex 1adcf7c
Rollback unnecessary changes
smocherla-brex 3ca5c06
Add es_target
smocherla-brex 61931e3
ktlint and fix reflection issue
smocherla-brex 9a22b6f
Fix kotlin/js compilation
smocherla-brex a66d4a0
lint
smocherla-brex 7883cd3
lint
smocherla-brex 9b82987
Add example with rules_js
smocherla-brex aa36a43
Ignore examples from root module
smocherla-brex d4c8c61
handle output group
smocherla-brex 6021ebe
Remove native-toolchain changes for now
smocherla-brex 2d0ae34
Fix example with cjs
smocherla-brex 1bc8b1f
Add couple of unit tests
smocherla-brex 16dbf80
Try fixing integrationt tests
smocherla-brex a86ba79
Add docs
smocherla-brex 7ee8d5d
Fix integration tests
smocherla-brex a3b525f
add node integration back
smocherla-brex 5ce2d58
Fix integration test in WORKSPACE
smocherla-brex fe611e9
Fix integration test failure with Bazel 8
smocherla-brex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../.bazelversion |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bazel-node/ | ||
node_modules/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
load("@npm//:defs.bzl", "npm_link_all_packages") | ||
|
||
npm_link_all_packages(name = "node_modules") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module( | ||
name = "node", | ||
) | ||
|
||
bazel_dep(name = "protobuf", version = "29.0", repo_name = "com_google_protobuf") | ||
bazel_dep(name = "rules_kotlin", version = "2.1.1") | ||
local_path_override( | ||
module_name = "rules_kotlin", | ||
path = "../..", | ||
) | ||
|
||
bazel_dep(name = "aspect_rules_js", version = "2.3.8") | ||
|
||
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True) | ||
npm.npm_translate_lock( | ||
name = "npm", | ||
pnpm_lock = "//:pnpm-lock.yaml", | ||
verify_node_modules_ignored = "//:.bazelignore", | ||
) | ||
use_repo(npm, "npm") | ||
|
||
pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm") | ||
|
||
# Allows developers to use the matching pnpm version, for example: | ||
# bazel run -- @pnpm --dir /home/runner/work/rules_js/rules_js install | ||
use_repo(pnpm, "pnpm") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
workspace(name = "node") | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
local_repository( | ||
name = "rules_kotlin", | ||
path = "../..", | ||
) | ||
|
||
# required with Bazel 8/workspace | ||
http_archive( | ||
name = "rules_python", | ||
sha256 = "2ef40fdcd797e07f0b6abda446d1d84e2d9570d234fddf8fcd2aa262da852d1c", | ||
strip_prefix = "rules_python-1.2.0", | ||
url = "https://github.com/bazelbuild/rules_python/releases/download/1.2.0/rules_python-1.2.0.tar.gz", | ||
) | ||
|
||
load("@rules_python//python:repositories.bzl", "py_repositories") | ||
|
||
py_repositories() | ||
|
||
# required with Bazel 8/workspace | ||
http_archive( | ||
name = "rules_shell", | ||
sha256 = "bc61ef94facc78e20a645726f64756e5e285a045037c7a61f65af2941f4c25e1", | ||
strip_prefix = "rules_shell-0.4.1", | ||
url = "https://github.com/bazelbuild/rules_shell/releases/download/v0.4.1/rules_shell-v0.4.1.tar.gz", | ||
) | ||
|
||
load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains") | ||
|
||
rules_shell_dependencies() | ||
|
||
rules_shell_toolchains() | ||
|
||
http_archive( | ||
name = "rules_java", | ||
sha256 = "6d8c6d5cd86fed031ee48424f238fa35f33abc9921fd97dd4ae1119a29fc807f", | ||
urls = [ | ||
"https://github.com/bazelbuild/rules_java/releases/download/8.6.3/rules_java-8.6.3.tar.gz", | ||
], | ||
) | ||
|
||
load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies") | ||
|
||
rules_java_dependencies() | ||
|
||
# note that the following line is what is minimally required from protobuf for the java rules | ||
# consider using the protobuf_deps() public API from @com_google_protobuf//:protobuf_deps.bzl | ||
load("@com_google_protobuf//bazel/private:proto_bazel_features.bzl", "proto_bazel_features") # buildifier: disable=bzl-visibility | ||
|
||
proto_bazel_features(name = "proto_bazel_features") | ||
|
||
# register toolchains | ||
load("@rules_java//java:repositories.bzl", "rules_java_toolchains") | ||
|
||
rules_java_toolchains() | ||
|
||
http_archive( | ||
name = "rules_proto", | ||
sha256 = "8e195dbb6a505ca4c7aafa6b7cffa47fe49a261b27a342053cfb2b973cc4aa12", | ||
strip_prefix = "rules_proto-7.0.0", | ||
url = "https://github.com/bazelbuild/rules_proto/releases/download/7.0.0/rules_proto-7.0.0.tar.gz", | ||
) | ||
|
||
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies") | ||
|
||
rules_proto_dependencies() | ||
|
||
load("@rules_proto//proto:setup.bzl", "rules_proto_setup") | ||
|
||
rules_proto_setup() | ||
|
||
http_archive( | ||
name = "aspect_rules_js", | ||
sha256 = "304c51726b727d53277dd28fcda1b8e43b7e46818530b8d6265e7be98d5e2b25", | ||
strip_prefix = "rules_js-2.3.8", | ||
url = "https://github.com/aspect-build/rules_js/releases/download/v2.3.8/rules_js-v2.3.8.tar.gz", | ||
) | ||
|
||
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") | ||
|
||
rules_js_dependencies() | ||
|
||
load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains") | ||
|
||
rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION) | ||
|
||
load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") | ||
|
||
npm_translate_lock( | ||
name = "npm", | ||
pnpm_lock = "//:pnpm-lock.yaml", | ||
verify_node_modules_ignored = "//:.bazelignore", | ||
) | ||
|
||
load("@npm//:repositories.bzl", "npm_repositories") | ||
|
||
npm_repositories() | ||
|
||
load("@rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories") | ||
|
||
kotlin_repositories() # if you want the default. Otherwise see custom kotlinc distribution below | ||
|
||
load("@rules_kotlin//kotlin:core.bzl", "kt_register_toolchains") | ||
|
||
kt_register_toolchains() # to use the default toolchain, otherwise see toolchains below |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package express | ||
|
||
@JsModule("express") | ||
@JsNonModule | ||
external fun express(): ExpressApp | ||
|
||
external interface ExpressApp { | ||
fun get(path: String, handler: (Request, Response) -> Unit) | ||
fun listen(port: Int, callback: () -> Unit) | ||
} | ||
|
||
external interface Request | ||
external interface Response { | ||
fun send(body: String) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
load("@aspect_rules_js//js:defs.bzl", "js_binary") | ||
load("@rules_kotlin//kotlin:js.bzl", "kt_js_library") | ||
|
||
kt_js_library( | ||
name = "app", | ||
srcs = [ | ||
"App.kt", | ||
"Main.kt", | ||
], | ||
output_kind = "js", | ||
) | ||
|
||
filegroup( | ||
name = "js-file", | ||
srcs = [":app"], | ||
output_group = "js", | ||
) | ||
|
||
js_binary( | ||
name = "express", | ||
data = ["//:node_modules/express"], | ||
entry_point = ":js-file", | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package express | ||
|
||
fun main() { | ||
val app = express() | ||
|
||
app.get("/") { _, res -> | ||
res.send("Hello from Kotlin/JS Node server!") | ||
} | ||
|
||
app.listen(3000) { | ||
println("Server started on http://localhost:3000") | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "node", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"express": "^4.19.2" | ||
}, | ||
"devDependencies": { | ||
"source-map-support": "^0.5.6" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need
rules_python
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was needed only for this example (not the root module) with Bazel 8 workspace. It appears related to this change with Bazel 8 bazelbuild/bazel#23043. Without this, I get the error
It gets fixed with
I can add that flag as well (it appears some internal bazel repos rely on rules_python) and because this is WORKSPACE, it breaks unless it's already pulled in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... python is an even bigger mess than I remembered.