generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add bundle=false support (#98)
* feature: bundle=false support * cleanup test cases & providers when not bundling * update docs --------- Co-authored-by: Greg Magolan <[email protected]>
- Loading branch information
1 parent
e2c8172
commit 044face
Showing
11 changed files
with
158 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 @@ | ||
build --enable_runfiles | ||
common:bzlmod --enable_bzlmod |
This file contains 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,38 @@ | ||
load("@aspect_bazel_lib//lib:testing.bzl", "assert_contains") | ||
load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild") | ||
|
||
SRCS = [ | ||
"main.js", | ||
"lib.js", | ||
] | ||
|
||
ENTRY = "main.js" | ||
|
||
esbuild( | ||
name = "bundle-true", | ||
testonly = 1, | ||
srcs = SRCS, | ||
entry_point = ENTRY, | ||
output = "bundle-true.js", | ||
) | ||
|
||
assert_contains( | ||
name = "bundle-true_test", | ||
actual = ":bundle-true.js", | ||
expected = "ANSWER = 42", | ||
) | ||
|
||
esbuild( | ||
name = "bundle-false", | ||
testonly = 1, | ||
srcs = SRCS, | ||
bundle = False, | ||
entry_point = ENTRY, | ||
output = "bundle-false.js", | ||
) | ||
|
||
assert_contains( | ||
name = "bundle-false_test", | ||
actual = ":bundle-false.js", | ||
expected = "from \"./lib\"", | ||
) |
This file contains 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,9 @@ | ||
"Bazel dependencies" | ||
|
||
bazel_dep(name = "aspect_rules_esbuild", version = "0.0.0", dev_dependency = True) | ||
bazel_dep(name = "aspect_bazel_lib", version = "1.36.0", dev_dependency = True) | ||
|
||
local_path_override( | ||
module_name = "aspect_rules_esbuild", | ||
path = "../..", | ||
) |
This file contains 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,34 @@ | ||
# Override http_archive for local testing | ||
local_repository( | ||
name = "aspect_rules_esbuild", | ||
path = "../..", | ||
) | ||
|
||
###################### | ||
# rules_esbuild setup # | ||
###################### | ||
|
||
# Fetches the rules_esbuild dependencies. | ||
# If you want to have a different version of some dependency, | ||
# you should fetch it *before* calling this. | ||
# Alternatively, you can skip calling this function, so long as you've | ||
# already fetched all the dependencies. | ||
load("@aspect_rules_esbuild//esbuild:dependencies.bzl", "rules_esbuild_dependencies") | ||
|
||
rules_esbuild_dependencies() | ||
|
||
# If you didn't already register a toolchain providing nodejs, do that: | ||
load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") | ||
|
||
nodejs_register_toolchains( | ||
name = "node", | ||
node_version = DEFAULT_NODE_VERSION, | ||
) | ||
|
||
# Register a toolchain containing esbuild npm package and native bindings | ||
load("@aspect_rules_esbuild//esbuild:repositories.bzl", "LATEST_ESBUILD_VERSION", "esbuild_register_toolchains") | ||
|
||
esbuild_register_toolchains( | ||
name = "esbuild", | ||
esbuild_version = LATEST_ESBUILD_VERSION, | ||
) |
Empty file.
This file contains 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 @@ | ||
export const ANSWER = 42; |
This file contains 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 @@ | ||
import { ANSWER } from './lib'; | ||
|
||
console.log(ANSWER); |
This file contains 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 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