From 748288f1db8754362f42757585c1ba817dee371f Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Sat, 27 Apr 2024 06:21:34 -0700 Subject: [PATCH] chore: bump to latest stardoc --- .github/workflows/ci.bazelrc | 1 - MODULE.bazel | 5 ++++ WORKSPACE | 22 ++++++++++++++ docs/repositories.md | 56 +++++++++++++++++------------------- docs/swc.md | 52 ++++++++++++++++----------------- internal_deps.bzl | 4 +-- 6 files changed, 81 insertions(+), 59 deletions(-) diff --git a/.github/workflows/ci.bazelrc b/.github/workflows/ci.bazelrc index 865790f..3d5edfd 100644 --- a/.github/workflows/ci.bazelrc +++ b/.github/workflows/ci.bazelrc @@ -1,4 +1,3 @@ - # Directories caches by GitHub actions common --disk_cache=~/.cache/bazel-disk-cache common --repository_cache=~/.cache/bazel-repository-cache diff --git a/MODULE.bazel b/MODULE.bazel index dcc7879..db5a56e 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -21,3 +21,8 @@ swc.toolchain( use_repo(swc, "swc_toolchains") register_toolchains("@swc_toolchains//:all") + +####### Dev dependencies ######## + +bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True) +bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True, repo_name = "io_bazel_stardoc") diff --git a/WORKSPACE b/WORKSPACE index 12b4d9a..339303f 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -52,6 +52,28 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() +############################################ +# Stardoc +load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories") + +stardoc_repositories() + +load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps") + +rules_jvm_external_deps() + +load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup") + +rules_jvm_external_setup() + +load("@io_bazel_stardoc//:deps.bzl", "stardoc_external_deps") + +stardoc_external_deps() + +load("@stardoc_maven//:defs.bzl", stardoc_pinned_maven_install = "pinned_maven_install") + +stardoc_pinned_maven_install() + # Buildifier load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps") diff --git a/docs/repositories.md b/docs/repositories.md index c8e345c..2497aa9 100644 --- a/docs/repositories.md +++ b/docs/repositories.md @@ -30,31 +30,6 @@ swc_register_toolchains( ) ``` - - - - -## swc_repositories - -
-swc_repositories(name, integrity_hashes, platform, repo_mapping, swc_version, swc_version_from)
-
- -Fetch external dependencies needed to run the SWC cli - -**ATTRIBUTES** - - -| Name | Description | Type | Mandatory | Default | -| :------------- | :------------- | :------------- | :------------- | :------------- | -| name | A unique name for this repository. | Name | required | | -| integrity_hashes | A mapping from platform to integrity hash. | Dictionary: String -> String | optional | {} | -| platform | - | String | required | | -| repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar" declares that, for any time this repository depends on @foo (such as a dependency on @foo//some:target, it should actually resolve that dependency within globally-declared @bar (@bar//some:target). | Dictionary: String -> String | required | | -| swc_version | Explicit version. If provided, the package.json is not read. | String | optional | "" | -| swc_version_from | Location of package.json which has a version for @swc/core. | Label | optional | None | - - ## swc_register_toolchains @@ -76,10 +51,33 @@ Users can avoid this macro and do these steps themselves, if they want more cont | Name | Description | Default Value | | :------------- | :------------- | :------------- | -| name | base name for all created repos; we recommend swc | none | -| swc_version | version of the swc project, from https://github.com/swc-project/swc/releases Exactly one of swc_version or swc_version_from must be set. | None | -| swc_version_from | label of a json file (typically package.json) which declares an exact @swc/core version in a dependencies or devDependencies property. Exactly one of swc_version or swc_version_from must be set. | None | -| register | whether to call through to native.register_toolchains. Should be True for WORKSPACE users, but false when used under bzlmod extension | True | +| name | base name for all created repos; we recommend `swc` | none | +| swc_version | version of the swc project, from https://github.com/swc-project/swc/releases Exactly one of `swc_version` or `swc_version_from` must be set. | `None` | +| swc_version_from | label of a json file (typically `package.json`) which declares an exact `@swc/core` version in a dependencies or devDependencies property. Exactly one of `swc_version` or `swc_version_from` must be set. | `None` | +| register | whether to call through to native.register_toolchains. Should be True for WORKSPACE users, but false when used under bzlmod extension | `True` | | kwargs | passed to each swc_repositories call | none | + + +## swc_repositories + +
+swc_repositories(name, integrity_hashes, platform, repo_mapping, swc_version, swc_version_from)
+
+ +Fetch external dependencies needed to run the SWC cli + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this repository. | Name | required | | +| integrity_hashes | A mapping from platform to integrity hash. | Dictionary: String -> String | optional | `{}` | +| platform | - | String | required | | +| repo_mapping | In `WORKSPACE` context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.

For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`).

This attribute is _not_ supported in `MODULE.bazel` context (when invoking a repository rule inside a module extension's implementation function). | Dictionary: String -> String | optional | | +| swc_version | Explicit version. If provided, the package.json is not read. | String | optional | `""` | +| swc_version_from | Location of package.json which has a version for @swc/core. | Label | optional | `None` | + + diff --git a/docs/swc.md b/docs/swc.md index 609b8fb..f3a090b 100644 --- a/docs/swc.md +++ b/docs/swc.md @@ -13,14 +13,13 @@ swc( ) ``` - ## swc_compile
-swc_compile(name, args, data, js_outs, map_outs, out_dir, output_dir, plugins, root_dir,
-            source_maps, source_root, srcs, swcrc)
+swc_compile(name, srcs, data, args, js_outs, map_outs, out_dir, output_dir, plugins, root_dir,
+            source_maps, source_root, swcrc)
 
Underlying rule for the `swc` macro. @@ -31,25 +30,24 @@ and has convenient default values. Use this if you need more control over how the rule is called, for example to set your own output labels for `js_outs`. - **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | -| args | Additional arguments to pass to swcx cli (NOT swc!).

NB: this is not the same as the CLI arguments for @swc/cli npm package. For performance, rules_swc does not call a Node.js program wrapping the swc rust binding. Instead, we directly spawn the (somewhat experimental) native Rust binary shipped inside the @swc/core npm package, which the swc project calls "swcx" Tracking issue for feature parity: https://github.com/swc-project/swc/issues/4017 | List of strings | optional | [] | -| data | Runtime dependencies to include in binaries/tests that depend on this target.

The transitive npm dependencies, transitive sources, default outputs and runfiles of targets in the data attribute are added to the runfiles of this target. They should appear in the '*.runfiles' area of any executable which has a runtime dependency on this target.

If this list contains linked npm packages, npm package store targets or other targets that provide JsInfo, NpmPackageStoreInfo providers are gathered from JsInfo. This is done directly from the npm_package_store_deps field of these. For linked npm package targets, the underlying npm_package_store target(s) that back the links is used. Gathered NpmPackageStoreInfo providers are propagated to the direct dependencies of downstream linked npm_package targets.

NB: Linked npm package targets that are "dev" dependencies do not forward their underlying npm_package_store target(s) through npm_package_store_deps and will therefore not be propagated to the direct dependencies of downstream linked npm_package targets. npm packages that come in from npm_translate_lock are considered "dev" dependencies if they are have dev: true set in the pnpm lock file. This should be all packages that are only listed as "devDependencies" in all package.json files within the pnpm workspace. This behavior is intentional to mimic how devDependencies work in published npm packages. | List of labels | optional | [] | -| js_outs | list of expected JavaScript output files.

There should be one for each entry in srcs. | List of labels | optional | | -| map_outs | list of expected source map output files.

Can be empty, meaning no source maps should be produced. If non-empty, there should be one for each entry in srcs. | List of labels | optional | | -| out_dir | With output_dir=False, output files will have this directory prefix.

With output_dir=True, this is the name of the output directory. | String | optional | "" | -| output_dir | Whether to produce a directory output rather than individual files.

If out_dir is also specified, it is used as the name of the output directory. Otherwise, the directory is named the same as the target. | Boolean | optional | False | -| plugins | swc compilation plugins, created with swc_plugin rule | List of labels | optional | [] | -| root_dir | a subdirectory under the input package which should be consider the root directory of all the input files | String | optional | "" | -| source_maps | Create source map files for emitted JavaScript files.

see https://swc.rs/docs/usage/cli#--source-maps--s | String | optional | "false" | -| source_root | Specify the root path for debuggers to find the reference source code.

see https://swc.rs/docs/usage/cli#--source-root

If not set, then the directory containing the source file is used. | String | optional | "" | | srcs | source files, typically .ts files in the source tree | List of labels | required | | -| swcrc | label of a configuration file for swc, see https://swc.rs/docs/configuration/swcrc | Label | optional | None | +| data | Runtime dependencies to include in binaries/tests that depend on this target.

The transitive npm dependencies, transitive sources, default outputs and runfiles of targets in the `data` attribute are added to the runfiles of this target. They should appear in the '*.runfiles' area of any executable which has a runtime dependency on this target.

If this list contains linked npm packages, npm package store targets or other targets that provide `JsInfo`, `NpmPackageStoreInfo` providers are gathered from `JsInfo`. This is done directly from the `npm_package_store_deps` field of these. For linked npm package targets, the underlying `npm_package_store` target(s) that back the links is used. Gathered `NpmPackageStoreInfo` providers are propagated to the direct dependencies of downstream linked `npm_package` targets.

NB: Linked npm package targets that are "dev" dependencies do not forward their underlying `npm_package_store` target(s) through `npm_package_store_deps` and will therefore not be propagated to the direct dependencies of downstream linked `npm_package` targets. npm packages that come in from `npm_translate_lock` are considered "dev" dependencies if they are have `dev: true` set in the pnpm lock file. This should be all packages that are only listed as "devDependencies" in all `package.json` files within the pnpm workspace. This behavior is intentional to mimic how `devDependencies` work in published npm packages. | List of labels | optional | `[]` | +| args | Additional arguments to pass to swcx cli (NOT swc!).

NB: this is not the same as the CLI arguments for @swc/cli npm package. For performance, rules_swc does not call a Node.js program wrapping the swc rust binding. Instead, we directly spawn the (somewhat experimental) native Rust binary shipped inside the @swc/core npm package, which the swc project calls "swcx" Tracking issue for feature parity: https://github.com/swc-project/swc/issues/4017 | List of strings | optional | `[]` | +| js_outs | list of expected JavaScript output files.

There should be one for each entry in srcs. | List of labels | optional | `[]` | +| map_outs | list of expected source map output files.

Can be empty, meaning no source maps should be produced. If non-empty, there should be one for each entry in srcs. | List of labels | optional | `[]` | +| out_dir | With output_dir=False, output files will have this directory prefix.

With output_dir=True, this is the name of the output directory. | String | optional | `""` | +| output_dir | Whether to produce a directory output rather than individual files.

If out_dir is also specified, it is used as the name of the output directory. Otherwise, the directory is named the same as the target. | Boolean | optional | `False` | +| plugins | swc compilation plugins, created with swc_plugin rule | List of labels | optional | `[]` | +| root_dir | a subdirectory under the input package which should be consider the root directory of all the input files | String | optional | `""` | +| source_maps | Create source map files for emitted JavaScript files.

see https://swc.rs/docs/usage/cli#--source-maps--s | String | optional | `"false"` | +| source_root | Specify the root path for debuggers to find the reference source code.

see https://swc.rs/docs/usage/cli#--source-root

If not set, then the directory containing the source file is used. | String | optional | `""` | +| swcrc | label of a configuration file for swc, see https://swc.rs/docs/configuration/swcrc | Label | optional | `None` | @@ -69,15 +67,15 @@ Execute the SWC compiler | :------------- | :------------- | :------------- | | name | A name for this target | none | | srcs | List of labels of TypeScript source files. | none | -| args | Additional options to pass to swcx cli, see https://github.com/swc-project/swc/discussions/3859 Note: we do **not** run the [NodeJS wrapper @swc/cli](https://swc.rs/docs/usage/cli) | [] | -| data | Files needed at runtime by binaries or tests that transitively depend on this target. See https://bazel.build/reference/be/common-definitions#typical-attributes | [] | -| plugins | List of plugin labels created with swc_plugin. | [] | -| output_dir | Whether to produce a directory output rather than individual files.

If out_dir is set, then that is used as the name of the output directory. Otherwise, the output directory is named the same as the target. | False | -| swcrc | Label of a .swcrc configuration file for the SWC cli, see https://swc.rs/docs/configuration/swcrc Instead of a label, you can pass a dictionary matching the JSON schema. If this attribute isn't specified, and a file .swcrc exists in the same folder as this rule, it is used.

Note that some settings in .swcrc also appear in tsconfig.json. See the notes in [/docs/tsconfig.md]. | None | -| source_maps | If set, the --source-maps argument is passed to the SWC cli with the value. See https://swc.rs/docs/usage/cli#--source-maps--s. True/False are automaticaly converted to "true"/"false" string values the cli expects. | False | -| out_dir | The base directory for output files relative to the output directory for this package.

If output_dir is True, then this is used as the name of the output directory. | None | -| root_dir | A subdirectory under the input package which should be considered the root directory of all the input files | None | -| kwargs | additional keyword arguments passed through to underlying [swc_compile](#swc_compile), eg. visibility, tags | none | +| args | Additional options to pass to `swcx` cli, see https://github.com/swc-project/swc/discussions/3859 Note: we do **not** run the [NodeJS wrapper `@swc/cli`](https://swc.rs/docs/usage/cli) | `[]` | +| data | Files needed at runtime by binaries or tests that transitively depend on this target. See https://bazel.build/reference/be/common-definitions#typical-attributes | `[]` | +| plugins | List of plugin labels created with `swc_plugin`. | `[]` | +| output_dir | Whether to produce a directory output rather than individual files.

If `out_dir` is set, then that is used as the name of the output directory. Otherwise, the output directory is named the same as the target. | `False` | +| swcrc | Label of a .swcrc configuration file for the SWC cli, see https://swc.rs/docs/configuration/swcrc Instead of a label, you can pass a dictionary matching the JSON schema. If this attribute isn't specified, and a file `.swcrc` exists in the same folder as this rule, it is used.

Note that some settings in `.swcrc` also appear in `tsconfig.json`. See the notes in [/docs/tsconfig.md]. | `None` | +| source_maps | If set, the --source-maps argument is passed to the SWC cli with the value. See https://swc.rs/docs/usage/cli#--source-maps--s. True/False are automaticaly converted to "true"/"false" string values the cli expects. | `False` | +| out_dir | The base directory for output files relative to the output directory for this package.

If output_dir is True, then this is used as the name of the output directory. | `None` | +| root_dir | A subdirectory under the input package which should be considered the root directory of all the input files | `None` | +| kwargs | additional keyword arguments passed through to underlying [`swc_compile`](#swc_compile), eg. `visibility`, `tags` | none | @@ -96,8 +94,8 @@ Configure an SWC plugin | Name | Description | Default Value | | :------------- | :------------- | :------------- | | name | A name for this target | none | -| src | Label for the plugin, either a directory containing a package.json pointing at a wasm file as the main entrypoint, or a wasm file. Usually a linked npm package target via rules_js. | None | -| config | Optional configuration dict for the plugin. This is passed as a JSON object into the jsc.experimental.plugins entry for the plugin. | {} | -| kwargs | additional keyword arguments passed through to underlying rule, eg. visibility, tags | none | +| src | Label for the plugin, either a directory containing a package.json pointing at a wasm file as the main entrypoint, or a wasm file. Usually a linked npm package target via rules_js. | `None` | +| config | Optional configuration dict for the plugin. This is passed as a JSON object into the `jsc.experimental.plugins` entry for the plugin. | `{}` | +| kwargs | additional keyword arguments passed through to underlying rule, eg. `visibility`, `tags` | none | diff --git a/internal_deps.bzl b/internal_deps.bzl index 9219fab..9f16145 100644 --- a/internal_deps.bzl +++ b/internal_deps.bzl @@ -15,8 +15,8 @@ def rules_swc_internal_deps(): http_archive( name = "io_bazel_stardoc", - sha256 = "3fd8fec4ddec3c670bd810904e2e33170bedfe12f90adf943508184be458c8bb", - urls = ["https://github.com/bazelbuild/stardoc/releases/download/0.5.3/stardoc-0.5.3.tar.gz"], + sha256 = "62bd2e60216b7a6fec3ac79341aa201e0956477e7c8f6ccc286f279ad1d96432", + urls = ["https://github.com/bazelbuild/stardoc/releases/download/0.6.2/stardoc-0.6.2.tar.gz"], ) http_archive(