-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update to rules_js 1.0.0-rc.4
- Loading branch information
1 parent
8c96d84
commit d8e0c70
Showing
10 changed files
with
1,215 additions
and
1,124 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
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 |
---|---|---|
|
@@ -11,28 +11,41 @@ npx pnpm install [email protected] webpack-cli webpack-dev-server @bazel/worker --l | |
touch BUILD | ||
cat >WORKSPACE <<EOF | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
http_archive( | ||
name = "aspect_rules_js", | ||
sha256 = "b82da82edf64ba7e07e568193d645fc09b0a4ec92e0d82bd4e53d1a0e28ff681", | ||
strip_prefix = "rules_js-1.0.0-rc.3", | ||
url = "https://github.com/aspect-build/rules_js/archive/refs/tags/v1.0.0-rc.3.tar.gz", | ||
sha256 = "f2b36aac9d3368e402c9083c884ad9b26ca6fa21e83b53c12482d6cb2e949451", | ||
strip_prefix = "rules_js-1.0.0-rc.4", | ||
url = "https://github.com/aspect-build/rules_js/archive/refs/tags/v1.0.0-rc.4.tar.gz", | ||
) | ||
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") | ||
rules_js_dependencies() | ||
load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") | ||
nodejs_register_toolchains( | ||
name = "nodejs", | ||
node_version = "16.9.0", | ||
) | ||
load("@aspect_bazel_lib//lib:repositories.bzl", "DEFAULT_YQ_VERSION", "register_yq_toolchains") | ||
register_yq_toolchains( | ||
version = DEFAULT_YQ_VERSION, | ||
) | ||
load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock") | ||
npm_translate_lock( | ||
name = "npm_webpack", | ||
pnpm_lock = "//:pnpm-lock.yaml", | ||
) | ||
load("@npm_webpack//:repositories.bzl", "npm_repositories") | ||
npm_repositories() | ||
EOF | ||
bazel fetch @npm_webpack//:all | ||
cp $(bazel info output_base)/external/npm_webpack/{defs,repositories}.bzl "$out" | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
|
||
|
||
bzl_library( | ||
name = "webpack_bundle", | ||
srcs = ["webpack_bundle.bzl"], | ||
visibility = ["//webpack:__subpackages__"], | ||
deps = ["@aspect_bazel_lib//lib:copy_to_bin"], | ||
deps = [ | ||
"@aspect_bazel_lib//lib:copy_to_bin", | ||
"@aspect_rules_js//js:libs", | ||
"@aspect_rules_js//js:providers", | ||
], | ||
) | ||
|
||
exports_files(["webpack.config.js", "webpack_worker.js"]) | ||
exports_files([ | ||
"webpack.config.js", | ||
"webpack_worker.js", | ||
]) | ||
|
||
# gazelle:exclude v*.*.*/* | ||
# gazelle:ignore | ||
bzl_library( | ||
name = "versions", | ||
srcs = ["versions.bzl"], | ||
visibility = ["//webpack:__subpackages__"] | ||
visibility = ["//webpack:__subpackages__"], | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,72 @@ | ||
"webpack_dev_server macro" | ||
load("@aspect_rules_js//js:defs.bzl", "js_binary_lib") | ||
load("@bazel_skylib//lib:dicts.bzl", "dicts") | ||
|
||
load("@aspect_rules_js//js:libs.bzl", "js_binary_lib", "js_lib_helpers") | ||
load("@bazel_skylib//lib:dicts.bzl", "dicts") | ||
|
||
_attrs = dicts.add(js_binary_lib.attrs, { | ||
"entry_point": attr.label( | ||
doc = "Internal use only", | ||
mandatory = True, | ||
), | ||
"srcs": attr.label_list( | ||
doc = "JavaScript source files from the workspace.", | ||
allow_files = True | ||
), | ||
"webpack_config": attr.label( | ||
"webpack_config": attr.label( | ||
doc = """Webpack configuration file. | ||
See https://webpack.js.org/configuration/""", | ||
allow_single_file = [".js"], | ||
mandatory = False | ||
), | ||
allow_single_file = [".js"], | ||
mandatory = False, | ||
), | ||
"_webpack_devserver_config": attr.label( | ||
doc = "Internal use only", | ||
allow_single_file = [".js"], | ||
default = Label("//webpack/private/devserver:webpack.config.js") | ||
allow_single_file = [".js"], | ||
default = Label("//webpack/private/devserver:webpack.config.js"), | ||
), | ||
}) | ||
|
||
|
||
def _impl(ctx): | ||
|
||
fixed_args = [ | ||
"serve", | ||
"--output-path", | ||
"./dist", | ||
"-c", | ||
ctx.file._webpack_devserver_config.short_path | ||
"-c", | ||
ctx.file._webpack_devserver_config.short_path, | ||
] | ||
|
||
files = ctx.files.srcs + ctx.files.data + [ | ||
ctx.file._webpack_devserver_config | ||
] | ||
files = [ctx.file._webpack_devserver_config] | ||
files.extend(ctx.files.data) | ||
files.extend(js_lib_helpers.gather_files_from_js_providers( | ||
targets = ctx.attr.data, | ||
include_transitive_sources = ctx.attr.include_transitive_sources, | ||
include_declarations = ctx.attr.include_declarations, | ||
include_npm_linked_packages = ctx.attr.include_npm_linked_packages, | ||
)) | ||
|
||
if ctx.attr.webpack_config: | ||
files.append(ctx.file.webpack_config) | ||
fixed_args.extend(["-c", ctx.file.webpack_config.short_path, "--merge"]) | ||
|
||
|
||
launcher = js_binary_lib.create_launcher( | ||
ctx, | ||
log_prefix_rule_set = "aspect_rules_webpack", | ||
log_prefix_rule = "webpack_devserver", | ||
fixed_args = fixed_args, | ||
) | ||
|
||
runfiles = launcher.runfiles.merge(ctx.runfiles( | ||
runfiles = ctx.runfiles( | ||
files = files, | ||
)) | ||
).merge(launcher.runfiles).merge_all([ | ||
target[DefaultInfo].default_runfiles | ||
for target in ctx.attr.data | ||
]) | ||
|
||
return [DefaultInfo( | ||
executable = launcher.executable, | ||
runfiles = runfiles | ||
)] | ||
return [ | ||
DefaultInfo( | ||
executable = launcher.executable, | ||
runfiles = runfiles, | ||
), | ||
] | ||
|
||
lib = struct( | ||
attrs = _attrs, | ||
implementation = _impl, | ||
toolchains = js_binary_lib.toolchains, | ||
) | ||
) |
Oops, something went wrong.