Skip to content

Commit

Permalink
Sets up pnpm workspaces.
Browse files Browse the repository at this point in the history
This creates a new `pnpm-workspace.yaml` which makes it install `node_modules/` in all the `packages/*` directories. This wasn't necessary before because `rules_prerender` and `@rules_prerender/declarative_shadow_dom` don't have any external dependencies, but it is necessary to install package-specific dependencies.

Also updates `tsconfig.json` to work for any `@rules_prerender/*` packages instead of just `@rules_prerender/declarative_shadow_dom`.

`.bazelignore` needs to be updated as well, but doesn't support globs unfortunately (see bazelbuild/bazel#7093). `node_modules/` verification was also incorrectly being done on the user `.bazelignore` file, rather than `@rules_prerender`'s `.bazelignore` when loaded as an external workspace. Used a `Label()` constructor to fix that.
  • Loading branch information
dgp1130 committed Mar 11, 2023
1 parent a995d75 commit 2d10506
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Ignore deeply nested `node_modules/` directories.
node_modules
packages/declarative_shadow_dom/node_modules
packages/rules_prerender/node_modules

# Ignore generated files.
dist
bazel-out

# Ignore external workspaces in the repository.
examples/external/
2 changes: 2 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
- "packages/*"
2 changes: 1 addition & 1 deletion repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def rules_prerender_repositories():
name = "rules_prerender_npm",
pnpm_lock = Label("//:pnpm-lock.yaml"),
npmrc = Label("//:.npmrc"),
verify_node_modules_ignored = "//:.bazelignore",
verify_node_modules_ignored = Label("//:.bazelignore"),
)

rules_ts_dependencies(ts_version_from = Label("//:package.json"))
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"baseUrl": "./", /* Base directory to resolve non-absolute module names. */
"paths": { /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
"rules_prerender": ["packages/rules_prerender"], // Map `rules_prerender` module to its implementation.
"@rules_prerender/declarative_shadow_dom": ["packages/declarative_shadow_dom"]
"@rules_prerender/*": ["packages/*"],
},
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
Expand Down

0 comments on commit 2d10506

Please sign in to comment.