"Rules for running Rollup under Bazel" load("@rules_nodejs//nodejs:providers.bzl", "JSModuleInfo", "STAMP_ATTR", "StampSettingInfo") load("@build_bazel_rules_nodejs//:providers.bzl", "ExternalNpmPackageInfo", "JSEcmaScriptModuleInfo", "node_modules_aspect", "run_node") load("@build_bazel_rules_nodejs//internal/linker:link_node_modules.bzl", "module_mappings_aspect") _DOC = "Runs the rollup.js CLI under Bazel." _ROLLUP_ATTRS = { "args": attr.string_list( doc = """Command line arguments to pass to Rollup. Can be used to override config file settings. These argument passed on the command line before arguments that are added by the rule. Run `bazel` with `--subcommands` to see what Rollup CLI command line was invoked. See the Rollup CLI docs for a complete list of supported arguments.""", default = [], ), "config_file": attr.label( doc = """A `rollup.config.js` file Passed to the `--config` option, see [the config doc](https://rollupjs.org/guide/en/#configuration-files) If not set, a default basic Rollup config is used. """, allow_single_file = True, default = "//@bazel/rollup:rollup.config.js", ), "deps": attr.label_list( aspects = [module_mappings_aspect, node_modules_aspect], doc = """Other libraries that are required by the code, or by the rollup.config.js""", ), "entry_point": attr.label( doc = """The bundle's entry point (e.g. your main.js or app.js or index.js). This is just a shortcut for the `entry_points` attribute with a single output chunk named the same as the rule. For example, these are equivalent: ```python rollup_bundle( name = "bundle", entry_point = "index.js", ) ``` ```python rollup_bundle( name = "bundle", entry_points = { "index.js": "bundle" } ) ``` If `rollup_bundle` is used on a `ts_library`, the `rollup_bundle` rule handles selecting the correct outputs from `ts_library`. In this case, `entry_point` can be specified as the `.ts` file and `rollup_bundle` will handle the mapping to the `.mjs` output file. For example: ```python ts_library( name = "foo", srcs = [ "foo.ts", "index.ts", ], ) rollup_bundle( name = "bundle", deps = [ "foo" ], entry_point = "index.ts", ) ``` """, allow_single_file = True, ), "entry_points": attr.label_keyed_string_dict( doc = """The bundle's entry points (e.g. your main.js or app.js or index.js). Passed to the [`--input` option](https://github.com/rollup/rollup/blob/master/docs/999-big-list-of-options.md#input) in Rollup. Keys in this dictionary are labels pointing to .js entry point files. Values are the name to be given to the corresponding output chunk. Either this attribute or `entry_point` must be specified, but not both. """, allow_files = True, ), "format": attr.string( doc = """Specifies the format of the generated bundle. One of the following: - `amd`: Asynchronous Module Definition, used with module loaders like RequireJS - `cjs`: CommonJS, suitable for Node and other bundlers - `esm`: Keep the bundle as an ES module file, suitable for other bundlers and inclusion as a `