Skip to content

Commit

Permalink
fix: expand make variables properly when passed via args (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aghassi authored Mar 22, 2024
1 parent 9c3edba commit a962156
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
11 changes: 11 additions & 0 deletions e2e/smoke/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,21 @@ webpack_bundle(
node_modules = "//v5:node_modules",
)

# Validates that args are properly expanded when
# a format string is passed
entryPointFile = 'entry-point.js'
webpack_bundle(
name = "bundle-entry-args-v5",
args = ['--entry', '$(rootpath {})'.format(entryPointFile)],
srcs = ["entry-point.js"],
node_modules = "//v5:node_modules",
)

write_source_files(
name = "bundles",
files = {
"expected-v4.js_": ":bundle-v4.js",
"expected-v5.js_": ":bundle-v5.js",
"expected-v5.js_": ":bundle-entry-args-v5.js",
},
)
3 changes: 3 additions & 0 deletions e2e/smoke/src/entry-point.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { version } from './module'

console.log(version)
8 changes: 7 additions & 1 deletion webpack/private/webpack_bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,13 @@ def _impl(ctx):
])

# Add user specified arguments after rule supplied arguments
args.add_all(ctx.attr.args)
args.add_all([
" ".join([
expand_variables(ctx, exp, attribute_name = "args")
for exp in expand_locations(ctx, arg, entry_points_srcs + ctx.attr.srcs + ctx.attr.deps + ctx.attr.data).split(" ")
])
for arg in ctx.attr.args
])

executable = ctx.executable.webpack_exec_cfg
execution_requirements = {}
Expand Down

0 comments on commit a962156

Please sign in to comment.