Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@bazel/terser
Advanced tools
The Terser rules run the Terser JS minifier with Bazel.
Wraps the Terser CLI documented at https://github.com/terser-js/terser#command-line-usage
Add the @bazel/terser
npm package to your devDependencies
in package.json
.
If you didn't use the yarn_install
or npm_install
rule, you'll have to declare a rule in your root BUILD.bazel
file to execute terser:
# Create a terser rule to use in terser_minified#terser_bin
# attribute when using self-managed dependencies
nodejs_binary(
name = "terser_bin",
entry_point = "//:node_modules/terser/bin/uglifyjs",
# Point bazel to your node_modules to find the entry point
node_modules = ["//:node_modules"],
)
Run the terser minifier.
Typical example:
load("@npm//@bazel/terser:index.bzl", "terser_minified")
terser_minified(
name = "out.min",
src = "input.js",
config_file = "terser_config.json",
)
Note that the name
attribute determines what the resulting files will be called.
So the example above will output out.min.js
and out.min.js.map
(since sourcemap
defaults to true
).
If the input is a directory, then the output will also be a directory, named after the name
attribute.
terser_minified(name, args, config_file, debug, sourcemap, src, terser_bin)
ATTRIBUTES
Name | Description | Type | Mandatory | Default | |||
---|---|---|---|---|---|---|---|
name | A unique name for this target. | Name | required |
Terser only parses minify() args from the config file so additional arguments such as | List of strings | optional | [] |
config_file |
A JSON file containing Terser minify() options.
This is the file you would pass to the --config-file argument in terser's CLI. https://github.com/terser-js/terser#minify-options documents the content of the file. Bazel will make a copy of your config file, treating it as a template. Run bazel with If you use the magic strings For example
Will disable the If | Label | optional | //@bazel/terser:terser_config.default.json | |||
debug |
Configure terser to produce more readable output.
Instead of setting this attribute, consider using debugging compilation mode instead bazel build --compilation_mode=dbg //my/terser:target so that it only affects the current build. | Boolean | optional | False | |||
sourcemap | Whether to produce a .js.map output | Boolean | optional | True | |||
src |
File(s) to minify.
Can be a .js file, a rule producing .js files as its default output, or a rule producing a directory of .js files. Note that you can pass multiple files to terser, which it will bundle together. If you want to do this, you can pass a filegroup here. | Label | required |
|
FAQs
Run Terser JS optimizer under Bazel
The npm package @bazel/terser receives a total of 0 weekly downloads. As such, @bazel/terser popularity was classified as not popular.
We found that @bazel/terser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.