-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add js library as option for webpack config (#163)
Fix #161 ### Changes are visible to end-users: yes - Searched for relevant documentation and updated as needed: YES - Breaking change (forces users to change their own code or config): NO - Suggested release notes appear below: YES Added option to use js_library for webpack config as alternative to files. ### Test plan - New test cases added
- Loading branch information
Showing
17 changed files
with
1,222 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
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,15 @@ | ||
# Import Aspect bazelrc presets | ||
try-import %workspace%/../../.aspect/bazelrc/bazel7.bazelrc | ||
import %workspace%/../../.aspect/bazelrc/convenience.bazelrc | ||
import %workspace%/../../.aspect/bazelrc/correctness.bazelrc | ||
import %workspace%/../../.aspect/bazelrc/debug.bazelrc | ||
import %workspace%/../../.aspect/bazelrc/javascript.bazelrc | ||
import %workspace%/../../.aspect/bazelrc/performance.bazelrc | ||
|
||
### YOUR PROJECT SPECIFIC OPTIONS GO HERE ### | ||
|
||
# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`. | ||
# This file should appear in `.gitignore` so that settings are not shared with team members. This | ||
# should be last statement in this config so the user configuration is able to overwrite flags from | ||
# this file. See https://bazel.build/configure/best-practices#bazelrc-file. | ||
try-import %workspace%/../../.aspect/bazelrc/user.bazelrc |
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 @@ | ||
../../.bazelversion |
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,4 @@ | ||
# Disabling pnpm [hoisting](https://pnpm.io/npmrc#hoist) by setting `hoist=false` is recommended on | ||
# projects using rules_js so that pnpm outside of Bazel lays out a node_modules tree similar to what | ||
# rules_js lays out under Bazel (without a hidden node_modules/.pnpm/node_modules) | ||
hoist=false |
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,32 @@ | ||
load("@aspect_rules_js//js:defs.bzl", "js_library") | ||
load("@aspect_rules_webpack//webpack:defs.bzl", "webpack_bundle") | ||
load("@bazel_skylib//rules:build_test.bzl", "build_test") | ||
load("@npm//:defs.bzl", "npm_link_all_packages") | ||
|
||
npm_link_all_packages(name = "node_modules") | ||
|
||
js_library( | ||
name = "webpack-config", | ||
srcs = ["webpack.config.cjs"], | ||
deps = [ | ||
":node_modules/ts-loader", | ||
], | ||
) | ||
|
||
webpack_bundle( | ||
name = "basic", | ||
srcs = [ | ||
"src/index.ts", | ||
"tsconfig.json", | ||
], | ||
node_modules = "//:node_modules", | ||
output_dir = True, | ||
webpack_config = ":webpack-config", | ||
) | ||
|
||
build_test( | ||
name = "test", | ||
targets = [ | ||
":basic", | ||
], | ||
) |
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,6 @@ | ||
############################################################################### | ||
# Bazel now uses Bzlmod by default to manage external dependencies. | ||
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. | ||
# | ||
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958 | ||
############################################################################### |
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,33 @@ | ||
# Override http_archive for local testing | ||
local_repository( | ||
name = "aspect_rules_webpack", | ||
path = "../..", | ||
) | ||
|
||
# Fetch the Bazel module dependencies | ||
|
||
load("@aspect_rules_webpack//webpack:dependencies.bzl", "rules_webpack_dependencies") | ||
|
||
rules_webpack_dependencies() | ||
|
||
# Fetch and register a nodejs interpreter, if you haven't already | ||
|
||
load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains") | ||
|
||
rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION) | ||
|
||
# brought as a dep by webpack ruleset | ||
load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") | ||
|
||
npm_translate_lock( | ||
name = "npm", | ||
no_optional = True, | ||
npmrc = "//:.npmrc", | ||
pnpm_lock = "//:pnpm-lock.yaml", | ||
pnpm_version = "9.0.0", | ||
verify_node_modules_ignored = "//:.bazelignore", | ||
) | ||
|
||
load("@npm//:repositories.bzl", "npm_repositories") | ||
|
||
npm_repositories() |
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,11 @@ | ||
{ | ||
"devDependencies": { | ||
"ts-loader": "9.4.2", | ||
"typescript": "4.8.4", | ||
"webpack": "5.76.2", | ||
"webpack-cli": "5.0.1" | ||
}, | ||
"pnpm": { | ||
"onlyBuiltDependencies": [] | ||
} | ||
} |
Oops, something went wrong.