Use --prefer-offline over plain --offline for installing JS deps.

This commit is contained in:
Sebastian Jeltsch
2025-06-04 10:31:31 +02:00
parent ffbe4dca3f
commit 385a9ecceb
3 changed files with 19 additions and 1964 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -9,8 +9,11 @@ packages:
- 'trailbase-assets/js/auth'
- 'trailbase-assets/js/client'
- 'trailbase-js/assets/runtime'
options:
link-workspace-packages: true
prefer-workspace-packages: true
strict-peer-dependencies: true
# shared-workspace-lockfile: false
sharedWorkspaceLockfile: true
linkWorkspacePackages: true
preferWorkspacePackages: true
preferOffline: true
preferFrozenLockfile: true
# strictPeerDependencies: false
disallowWorkspaceCycles: true

View File

@@ -91,10 +91,17 @@ pub fn build_js(path: impl AsRef<Path>) -> Result<()> {
// When we build cargo packages, we cannot rely on the workspace and prior installs.
pnpm_run(&["--dir", &path, "install", "--ignore-workspace"])
} else {
// `trailbase-asstes` and `trailbase-js` both build JS packages. We've seen issues with
// parallel installs in the past. We thus require all JS depdencies to be installed once
// upfront centrally into the workspace, i.e. `<trailbase>/node_modules`.
let args = ["--dir", &path, "install", "--frozen-lockfile", "--offline"];
// `trailbase-assets` and `trailbase-js` both build JS packages. We've seen issues with
// parallel installs in the past. Our current approach is to recommend installing workspace
// JS deps upfront in combination with `--prefer-offline`. We used to use plain `--offline`,
// however this adds an extra mandatory step when vendoring trailbase for framework use-cases.
let args = [
"--dir",
&path,
"install",
"--prefer-frozen-lockfile",
"--prefer-offline",
];
let build_result = pnpm_run(&args);
if build_result.is_err() {
error!(