refactor: Switch to Typescript project references to better watch/VSCode refactor support#562
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
🦋 Changeset detectedLatest commit: 2ff6790 The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the WalkthroughThis update introduces TypeScript project references across the monorepo, adding and updating Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer
participant WorkspaceMeta as workspace-meta Config
participant Package as Package (e.g., core-generators)
participant TsConfig as tsconfig.build.json
Dev->>WorkspaceMeta: Run workspace-meta plugins
WorkspaceMeta->>Package: For each package, check dependencies
WorkspaceMeta->>TsConfig: Read current tsconfig.build.json
WorkspaceMeta->>TsConfig: Generate/Update project references based on workspace dependencies
TsConfig-->>WorkspaceMeta: Write updated tsconfig.build.json if changed
sequenceDiagram
participant Dev as Developer
participant CLI as CLI Entry Script
participant Main as CLI Main Logic
Dev->>CLI: Run CLI (e.g., baseplate.js)
CLI->>Main: Import and execute main CLI function
Main->>Main: Run CLI logic
Main-->>CLI: Return or throw error
CLI->>Dev: Exit with code 0 or 1 based on result
Possibly related PRs
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
.workspace-meta/config.ts (2)
22-25: Clarify the reasoning for ignored packages.The comment mentions "False positives" but it would be helpful to document why these specific packages need to be excluded from TypeScript project references.
-// False positives for the Typescript project references +// Packages excluded from TypeScript project references due to special build configurations const IGNORED_PACKAGES = new Set([ '@baseplate-dev/project-builder-web', '@baseplate-dev/root', ]);
89-115: Complex dependency resolution logic could benefit from refactoring.While the logic is correct, this complex chain of operations for building inter-project dependencies could be broken down into smaller, more readable functions for better maintainability.
Consider extracting this into a separate function:
function buildProjectReferences( projectDependencyNames: string[], ctx: WorkspaceContext ): string[] { return projectDependencyNames .filter((name) => !IGNORED_PACKAGES.has(name)) .map((name) => { const packageInfo = ctx.workspacePackages.find((p) => p.name === name); if (!packageInfo) return undefined; const hasTypeScript = getProjectJsonDependencyKeys(packageInfo.packageJson) .includes('typescript'); const hasBuildScript = Object.keys(packageInfo.packageJson.scripts ?? {}) .includes('build'); if (hasTypeScript && hasBuildScript) { const relativePath = path.join( path.relative(ctx.packagePath, packageInfo.path), 'tsconfig.build.json' ); return relativePath.startsWith('.') ? relativePath : `./${relativePath}`; } }) .filter((name) => name !== undefined) .toSorted(); }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (36)
.workspace-meta/config.ts(3 hunks)package.json(4 hunks)packages/core-generators/package.json(1 hunks)packages/core-generators/tsconfig.build.json(1 hunks)packages/create-project/tsconfig.build.json(1 hunks)packages/fastify-generators/package.json(1 hunks)packages/fastify-generators/tsconfig.build.json(1 hunks)packages/project-builder-cli/tsconfig.build.json(1 hunks)packages/project-builder-lib/package.json(1 hunks)packages/project-builder-lib/src/definition/index.ts(1 hunks)packages/project-builder-lib/src/tools/model-merger/model-merger.unit.test.ts(1 hunks)packages/project-builder-lib/tsconfig.build.json(1 hunks)packages/project-builder-server/package.json(1 hunks)packages/project-builder-server/src/api/plugins.ts(1 hunks)packages/project-builder-server/tsconfig.build.json(1 hunks)packages/react-generators/package.json(1 hunks)packages/react-generators/tsconfig.build.json(1 hunks)packages/sync/package.json(1 hunks)packages/sync/src/output/prepare-generator-files/prepare-generator-file.unit.test.ts(1 hunks)packages/sync/src/output/prepare-generator-files/prepare-generator-files.unit.test.ts(1 hunks)packages/sync/src/output/write-generator-output.unit.test.ts(1 hunks)packages/sync/src/templates/extractor/run-template-file-extractors.unit.test.ts(1 hunks)packages/sync/src/tests/index.ts(1 hunks)packages/sync/tsconfig.build.json(1 hunks)packages/ui-components/package.json(1 hunks)packages/ui-components/tsconfig.build.json(1 hunks)packages/utils/package.json(1 hunks)packages/utils/tsconfig.build.json(1 hunks)plugins/plugin-auth/package.json(1 hunks)plugins/plugin-auth/tsconfig.build.json(1 hunks)plugins/plugin-storage/package.json(1 hunks)plugins/plugin-storage/tsconfig.build.json(1 hunks)tsconfig.build.json(1 hunks)tsconfig.json(1 hunks)tsconfig.scripts.json(1 hunks)turbo.json(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
packages/sync/src/output/write-generator-output.unit.test.ts (3)
Learnt from: kingston
PR: halfdomelabs/baseplate#510
File: packages/project-builder-server/src/sync/conflict-file-monitor.test.ts:19-24
Timestamp: 2025-04-23T06:44:30.952Z
Learning: When testing file operations in this codebase, the pattern is to use Vitest automocks for 'node:fs' and 'node:fs/promises' (without explicit implementation replacement) while populating a virtual filesystem with vol.fromJSON() from memfs. File operations in tests are performed directly via vol.promises methods.
Learnt from: kingston
PR: halfdomelabs/baseplate#510
File: packages/project-builder-server/src/sync/conflict-file-monitor.test.ts:19-24
Timestamp: 2025-04-23T06:44:30.952Z
Learning: In this codebase, when testing file operations, Vitest's automocks for 'node:fs' and 'node:fs/promises' are used in conjunction with memfs, but without replacing the mock implementation explicitly in each test file. The virtual filesystem is populated using vol.fromJSON or similar methods, which works seamlessly with the automocks.
Learnt from: kingston
PR: halfdomelabs/baseplate#510
File: packages/project-builder-server/src/sync/conflict-file-monitor.test.ts:19-24
Timestamp: 2025-04-23T06:44:30.952Z
Learning: In the project-builder-server test suite, Vitest automocks for 'node:fs' and 'node:fs/promises' are already configured to use memfs without needing explicit implementation replacement in each test file.
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Test E2E
- GitHub Check: Lint
- GitHub Check: test
🔇 Additional comments (56)
packages/project-builder-lib/package.json (1)
38-39: Standardize script naming for TypeScript watch and typecheck
Renaming"watch"to"tsc:watch"and reordering"typecheck"aligns with the repository-wide conventions. No change to the underlying commands.packages/project-builder-server/src/api/plugins.ts (1)
5-5: Expose PluginMetadataWithPaths type for shared type safety
Re-exportingPluginMetadataWithPathsfrom theproject-builder-libpackage supports the new composite project references and improves type sharing.tsconfig.scripts.json (1)
1-7: Add dedicated TS config for CLI scripts
The newtsconfig.scripts.jsoncorrectly extends the base Node CLI config, disables emit, and scopes the compilation to thescriptsand.workspace-metadirectories.packages/utils/package.json (1)
35-36: Align script naming with TypeScript project conventions
Renamed"watch"to"tsc:watch"and moved"typecheck"below it to maintain consistency with other packages. Commands remain unchanged.packages/sync/src/output/prepare-generator-files/prepare-generator-files.unit.test.ts (1)
3-3: Update import path for test logger utility
Changed import fromlogger.test-helper.jstologger.test-utils.jsto match the renamed file. Confirm there are no lingering references to the old path.packages/sync/src/output/prepare-generator-files/prepare-generator-file.unit.test.ts (1)
3-3: Update Test Logger import path
The import ofcreateTestLoggernow referenceslogger.test-utils.js, matching the consolidated test utilities export.packages/sync/src/templates/extractor/run-template-file-extractors.unit.test.ts (1)
5-5: Align Test Logger import with updated utility
This change updates the path tologger.test-utils.js, ensuring consistency with the new test helper module naming.packages/sync/src/tests/index.ts (1)
1-1: Re-export renamed test utils module
Switching the re-export tologger.test-utils.jsaligns the package’s test utilities with the updated filename.packages/project-builder-lib/src/tools/model-merger/model-merger.unit.test.ts (1)
9-9: Update ProjectDefinitionContainer test util import
The import now points toproject-definition-container.test-utils.js, matching the renamed test helper export indefinition/index.ts.packages/sync/src/output/write-generator-output.unit.test.ts (1)
4-4: Correct Test Logger import for writeGeneratorOutput tests
ImportingcreateTestLoggerfromlogger.test-utils.jsmaintains consistency with the updated test utilities.packages/project-builder-lib/src/definition/index.ts (2)
1-8: Consistent ESM re-exports with .js extensions
The file maintains uniform.jsextension references for ESM exports, aligning with the runtime resolution strategy in the monorepo.
9-9:Details
❓ Verification inconclusive
Verify the existence of the renamed test-utils module
Please confirm thatproject-definition-container.test-utils.jsactually exists underpackages/project-builder-lib/src/definitionand exports the expected utilities in place of the former test-helper file.Shell script to verify:
🏁 Script executed:
#!/bin/bash # Verify that the renamed test-utils file exists fd --type f project-definition-container.test-utils.js packages/project-builder-lib/src/definitionLength of output: 100
Verify the existence of the renamed test-utils module
I wasn’t able to locateproject-definition-container.test-utils.jsunderpackages/project-builder-lib/src/definition. Please confirm that:
- A file named
project-definition-container.test-utils.jsactually exists in that directory (or update the export path if it’s.tsor has a different name).- The module exports all the utilities previously provided by the old test-helper.
packages/fastify-generators/tsconfig.build.json (1)
16-27: Add TypeScript project references
The newreferencessection is correctly placed afterexclude, enabling incremental builds by declaring dependencies oncore-generators,sync, andutils. JSON syntax is valid.packages/project-builder-cli/tsconfig.build.json (1)
11-22: Enable composite builds with project references
Theexcludefield is properly defined, and thereferencessection listsproject-builder-lib,project-builder-server, andutils, correctly reflecting the package dependency graph for incremental compilation.tsconfig.build.json (2)
1-42: New root TypeScript build configuration
The roottsconfig.build.jsonaccurately aggregates references to every package and plugin, orchestrating a workspace-wide composite build with no direct includes. This aligns with the monorepo’s incremental build strategy.
1-42:Details
✅ Verification successful
Verify existence of all referenced tsconfig files
Please ensure eachpathunderreferencesexists and is typo-free.Shell script to confirm:
🏁 Script executed:
#!/bin/bash # Verify all referenced tsconfig.build.json files exist mapfile -t refs < <(jq -r '.references[].path' tsconfig.build.json) for ref in "${refs[@]}"; do if [ ! -f "$ref" ]; then echo "Missing: $ref" exit 1 fi done echo "All references are present."Length of output: 241
I’ll use a simpler loop to reliably check each path without relying on
/dev/fd:This will clearly report any missing files.
🏁 Script executed:
#!/bin/bash # Verify all referenced tsconfig.build.json files exist refs=$(jq -r '.references[].path' tsconfig.build.json) missing=false for ref in $refs; do if [ ! -f "$ref" ]; then echo "Missing: $ref" missing=true fi done if [ "$missing" = true ]; then exit 1 fi echo "All references exist."Length of output: 1686
All tsconfig.build.json references verified
All entries under"references"intsconfig.build.jsonhave been checked and each file exists—no typos or missing paths detected. No further action required.packages/core-generators/tsconfig.build.json (1)
16-23: Project references added for composite builds.The new
referencesarray correctly declares dependencies on../sync/tsconfig.build.jsonand../utils/tsconfig.build.json, enabling coordinated, incremental builds across packages. This aligns with the PR objective to adopt TypeScript project references.packages/sync/package.json (1)
38-39: Standardize watch script naming.Renaming the
"watch"script to"tsc:watch"and moving"typecheck"immediately after ensures consistency with other packages and aligns with the updated TypeScript project reference workflow.packages/project-builder-server/package.json (1)
35-36: Consistent TypeScript watch and typecheck scripts.The renaming of
"watch"to"tsc:watch"and reordering"typecheck"directly below maintains uniform script names across packages and supports incremental builds.packages/utils/tsconfig.build.json (2)
4-9: Enable composite and incremental compiler options.Adding
"tsBuildInfoFile","composite": true,"incremental": true, along with explicit"rootDir"and"outDir", correctly configures this package for incremental, composite builds. This matches the conventions applied elsewhere in the monorepo.
16-17: Placeholderreferencesarray added.Introducing an empty
referencesarray prepares this config for automated population by your.workspace-meta/config.tsplugin. This meets the requirement for project references even if there are currently no direct dependencies.packages/ui-components/package.json (1)
40-41: Standardize TypeScript watch & typecheck scripts
Renaming the watch script totsc:watchand positioningtypecheckimmediately after ensures consistency with other workspace packages.plugins/plugin-storage/package.json (1)
31-31: Align TypeScript watch script naming
Replacingwatch:tscwithtsc:watchmatches the naming convention used across the monorepo for TypeScript watch commands.tsconfig.json (1)
2-6: Introduce project references for root config
Defining an emptyfilesarray and adding references to bothtsconfig.scripts.jsonandtsconfig.build.jsoncorrectly enables composite project builds and delegates compilation scope.packages/sync/tsconfig.build.json (3)
4-9: Enable composite, incremental builds with build info file
Addingcomposite,incremental, and a customtsBuildInfoFilealongside explicitrootDir/outDiris the recommended setup for TypeScript project references.
14-16: Refine test exclusion patterns
Excluding tests understring-merge-algorithmsavoids inadvertently compiling legacy test fixtures while retaining global test file exclusions.
17-21: Link to utils project reference
Pointing to../utils/tsconfig.build.jsonensures the sync package correctly declares its dependency for incremental compilation.packages/create-project/tsconfig.build.json (2)
16-16: Adjust trailing comma in exclude list
Adding the trailing comma maintains JSON syntax consistency and allows easy addition of future exclude entries.
17-21: Add project reference to utils
Including a reference to../utils/tsconfig.build.jsonaligns this package with the incremental build graph and ensures proper dependency ordering.packages/fastify-generators/package.json (1)
34-38: Rename TypeScript watch script and simplifywatchtask
Renaming"watch:tsc"→"tsc:watch"and paring down the top-levelwatchto only run template builds standardizes this package with the monorepo convention.Please verify that your root-level orchestrator (e.g.,
turbo.json, CI workflows, README docs) has been updated to reference the newtsc:watchandwatch:templatesscripts.plugins/plugin-storage/tsconfig.build.json (3)
4-9: Enable composite and incremental builds
Adding"composite","incremental", and an explicittsBuildInfoFilewithrootDir/outDiraligns this config for TypeScript project references and speeds up rebuilds.
16-16: Ensure exclude array closure
The trailing comma after the last exclude entry was closed properly—this avoids JSON parsing issues.
17-38: Add project references
The seven referenced build configs (core-generators through utils) match this plugin’s dependencies, enabling coordinated composite builds.packages/ui-components/tsconfig.build.json (3)
5-8: Activate incremental mode and metadata output
IntroducingrootDir,tsBuildInfoFile,composite, andincrementalprepares this lib for fast, linked builds.
11-11: Exclude test and stories files
Excluding*.test.ts,*.stories.ts, and*.stories.tsxensures only source code goes into the build, keeping outputs clean.
12-16: Reference dependent utils project
Pointing to../utils/tsconfig.build.jsoncorrectly wires up the dependency for composite builds.plugins/plugin-auth/tsconfig.build.json (3)
4-9: Enable composite/incremental flags and build info
SettingnoEmit: false,tsBuildInfoFile,composite,incremental,rootDir, andoutDiraligns this plugin with TS project reference requirements.
16-16: Close exclude array properly
The exclude list now ends with a comma-terminated closing bracket, preventing JSON syntax errors.
17-36: Define project references
Referencing six upstream builds (core-generators through ui-components) matches this plugin’s imports and enables incremental, cross-package compilation.packages/project-builder-server/tsconfig.build.json (3)
4-9: Configure composite build settings
AddingtsBuildInfoFile,composite,incremental,rootDir, andoutDirmakes this server package compatible with TypeScript project references and speeds up rebuilds.
15-15: Ensure exclude closure
The trailing bracket after the exclude array is properly closed, avoiding malformed JSON.
16-35: Add references to sibling packages
Including references to core-generators, fastify-generators, project-builder-lib, react-generators, sync, and utils ensures coordinated composite compilation across the monorepo.packages/project-builder-lib/tsconfig.build.json (2)
4-9: Enable composite and incremental builds
Addscomposite,incremental,tsBuildInfoFile,rootDir, andoutDirto support project references and incremental build caching.
16-26: Add project references to dependent packages
Thereferencesarray correctly includessync,ui-components, andutilsprojects for coordinated builds across the workspace.packages/react-generators/tsconfig.build.json (3)
4-9: Enable composite and incremental builds
Introducescomposite,incremental,tsBuildInfoFile,rootDir, andoutDirsettings to leverage TypeScript project references with incremental build information.
16-16: Exclude template directories from TS compilation
Adding**/generators/*/*/templates/**toexcludeensures template assets aren’t processed as TypeScript sources.
17-26: Add project references for generators dependencies
Referencescore-generators,sync, andutilsbuild configs to ensure ordered builds and type-checking across packages.packages/react-generators/package.json (1)
33-36: Standardize watch scripts
Introduces a dedicated"tsc:watch"for TypeScript compilation and simplifies"watch"to only watch template builds, aligning with other generator packages.packages/core-generators/package.json (1)
46-46: Standardize watch and TypeScript watch scripts
Adds"tsc:watch"for persistent TS watch output and simplifies"watch"to only track template changes, matching the new project-wide convention.Also applies to: 48-48
package.json (3)
4-5: Add homepage and update license
Sets the root package"homepage"to the official site and standardizes the license toMPL-2.0.
43-44: Introduce root-level TypeScript watch script
Adds"watch:tsc:root"and updates the top-level"watch"to include it alongside other watchers with controlled concurrency.
57-57: Update devDependencies for build tooling
Bumpses-toolkitto1.31.0andworkspace-metato0.1.4to align with the new TypeScript project references plugin updates.Also applies to: 66-66
.workspace-meta/config.ts (4)
3-4: Good choice of utility libraries for configuration management.The import of
isEqual,merge, andisMatchfrom es-toolkit provides robust utilities for deep object comparison and merging, which are essential for the configuration comparison logic used later.
14-19: Clean helper function for dependency extraction.The function correctly extracts both regular and dev dependencies from package.json, which is appropriate for determining TypeScript project references.
27-42: Well-defined TypeScript interface for configuration structure.The
TsconfigBuildinterface provides good type safety for the tsconfig.build.json structure and correctly makes properties optional to handle various configuration scenarios.
75-160: Comprehensive TypeScript project references automation.This plugin effectively automates the generation and maintenance of TypeScript project references based on workspace dependencies. The logic correctly:
- Handles both root and non-root packages differently
- Filters dependencies appropriately
- Builds correct relative paths for references
- Compares existing configuration to avoid unnecessary updates
- Merges compiler options appropriately
The implementation aligns well with the PR objective of enabling better TypeScript project references for improved watch/VSCode support.
| "tsc:watch": "tsc -p tsconfig.build.json --preserveWatchOutput -w", | ||
| "typecheck": "tsc --noEmit", | ||
| "watch": "concurrently pnpm:watch:*", | ||
| "watch:static": "pnpm build:static --watch", | ||
| "watch:tsc": "tsc -p tsconfig.build.json --preserveWatchOutput -w", | ||
| "watch:vite": "vite build --watch" |
There was a problem hiding this comment.
Breaking change: tsc:watch not included in watch task
You’ve renamed watch:tsc to tsc:watch, but the watch script still runs pnpm:watch:*, which no longer matches tsc:watch. This causes pnpm watch to skip the TypeScript compiler watch.
To fix, update the watch script to include tsc:watch. For example:
- "watch": "concurrently pnpm:watch:*",
+ "watch": "concurrently \"pnpm run tsc:watch\" pnpm:watch:*",This ensures the TypeScript watch runs alongside other watchers.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "tsc:watch": "tsc -p tsconfig.build.json --preserveWatchOutput -w", | |
| "typecheck": "tsc --noEmit", | |
| "watch": "concurrently pnpm:watch:*", | |
| "watch:static": "pnpm build:static --watch", | |
| "watch:tsc": "tsc -p tsconfig.build.json --preserveWatchOutput -w", | |
| "watch:vite": "vite build --watch" | |
| "tsc:watch": "tsc -p tsconfig.build.json --preserveWatchOutput -w", | |
| "typecheck": "tsc --noEmit", | |
| "watch": "concurrently \"pnpm run tsc:watch\" pnpm:watch:*", | |
| "watch:static": "pnpm build:static --watch", | |
| "watch:vite": "vite build --watch" |
🤖 Prompt for AI Agents
In plugins/plugin-auth/package.json around lines 30 to 34, the "watch" script
uses the pattern "pnpm:watch:*" which no longer matches the renamed "tsc:watch"
script, causing the TypeScript compiler watch to be skipped. Update the "watch"
script to explicitly include "tsc:watch" alongside other watch scripts so that
running "pnpm watch" triggers the TypeScript watch process as intended.
There was a problem hiding this comment.
That's deliberate. We are now watching typescript from the root with project references.
There was a problem hiding this comment.
@kingston Thank you for the clarification! I understand now - with the TypeScript project references setup, you're centralizing the TypeScript watch at the root level rather than having each package run its own TypeScript watcher. This makes perfect sense for the new architecture.
✏️ Learnings added
Learnt from: kingston
PR: halfdomelabs/baseplate#562
File: plugins/plugin-auth/package.json:32-36
Timestamp: 2025-06-03T09:11:29.633Z
Learning: With TypeScript project references, TypeScript compilation is watched from the root level using "watch:tsc:root" script, so individual packages no longer need to include their "tsc:watch" scripts in their local "watch" commands. The local "tsc:watch" scripts are renamed from "watch:tsc" but are not meant to be run as part of the package's watch command since TypeScript watching is handled centrally at the workspace root.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
| }, | ||
| "//#watch:tsc:root": { | ||
| "persistent": true, | ||
| "cache": false |
There was a problem hiding this comment.
Fix task key format in turbo.json.
The new task key is defined as "//#watch:tsc:root", but the leading // will be treated literally and may not map to the "watch:tsc:root" script in package.json. Rename this key to "watch:tsc:root" (without the //) or document why the prefix is required to avoid misconfiguration.
🤖 Prompt for AI Agents
In turbo.json around lines 45 to 48, the task key is incorrectly prefixed with
"//" as "//#watch:tsc:root", which will be treated literally and may not match
the corresponding script in package.json. Remove the leading "//" from the key
so it reads "watch:tsc:root" to ensure proper mapping, or add documentation
explaining why the prefix is necessary if it must be kept.
| return; | ||
| } | ||
|
|
||
| const parsedTsconfig = JSON.parse(tsconfigBuild) as TsconfigBuild; |
There was a problem hiding this comment.
Add error handling for JSON parsing.
The JSON.parse operation could throw an error if the tsconfig.build.json file contains malformed JSON, which would cause the plugin to fail.
- const parsedTsconfig = JSON.parse(tsconfigBuild) as TsconfigBuild;
+ let parsedTsconfig: TsconfigBuild;
+ try {
+ parsedTsconfig = JSON.parse(tsconfigBuild) as TsconfigBuild;
+ } catch (error) {
+ console.warn(`Failed to parse tsconfig.build.json in ${ctx.packagePath}:`, error);
+ return;
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const parsedTsconfig = JSON.parse(tsconfigBuild) as TsconfigBuild; | |
| let parsedTsconfig: TsconfigBuild; | |
| try { | |
| parsedTsconfig = JSON.parse(tsconfigBuild) as TsconfigBuild; | |
| } catch (error) { | |
| console.warn(`Failed to parse tsconfig.build.json in ${ctx.packagePath}:`, error); | |
| return; | |
| } |
🤖 Prompt for AI Agents
In .workspace-meta/config.ts at line 126, the JSON.parse call on tsconfigBuild
can throw an error if the JSON is malformed. Wrap the JSON.parse operation in a
try-catch block to catch any parsing errors. In the catch block, handle the
error gracefully by logging an appropriate error message or taking corrective
action to prevent the plugin from failing unexpectedly.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
.workspace-meta/config.ts (1)
156-156: Add error handling for JSON parsing.The JSON.parse operation could throw an error if the tsconfig.build.json file contains malformed JSON, which would cause the plugin to fail.
🧹 Nitpick comments (2)
.workspace-meta/config.ts (1)
25-29: Clarify the reasoning for ignoring these packages.The comment mentions "False positives for the Typescript project references" but could be more specific about why these packages need to be excluded.
Consider adding more detailed comments explaining why each package is ignored:
-// False positives for the Typescript project references +// Packages excluded from TypeScript project references: +// - project-builder-web: Uses different build system (Vite) +// - root: Special workspace root package const IGNORED_PACKAGES = new Set([ '@baseplate-dev/project-builder-web', '@baseplate-dev/root', ]);packages/ui-components/package.json (1)
22-27: Verify files inclusion/exclusion patterns
Explicitly includingREADME.mdanddist/**/*while excluding.d.ts.mapand.tsbuildinfois correct to keep the package lean.Please double-check that the actual changelog file is named
CHANGELOG(no extension) in the repo. If it’sCHANGELOG.md, update the entry accordingly.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (26)
.changeset/ten-ducks-scream.md(1 hunks).workspace-meta/config.ts(3 hunks)package.json(5 hunks)packages/core-generators/package.json(3 hunks)packages/create-project/bin/create-baseplate-project.js(1 hunks)packages/create-project/package.json(1 hunks)packages/fastify-generators/package.json(3 hunks)packages/project-builder-cli/bin/baseplate.js(1 hunks)packages/project-builder-cli/package.json(1 hunks)packages/project-builder-cli/scripts/baseplate.js(0 hunks)packages/project-builder-cli/src/cli.ts(1 hunks)packages/project-builder-cli/src/index.ts(1 hunks)packages/project-builder-lib/package.json(2 hunks)packages/project-builder-server/package.json(2 hunks)packages/project-builder-server/src/api/index.ts(1 hunks)packages/project-builder-web/package.json(1 hunks)packages/react-generators/package.json(3 hunks)packages/sync/package.json(2 hunks)packages/ui-components/README.md(1 hunks)packages/ui-components/package.json(2 hunks)packages/ui-components/turbo.json(1 hunks)packages/utils/package.json(2 hunks)plugins/plugin-auth/package.json(3 hunks)plugins/plugin-storage/package.json(3 hunks)pnpm-workspace.yaml(1 hunks)turbo.json(2 hunks)
💤 Files with no reviewable changes (1)
- packages/project-builder-cli/scripts/baseplate.js
✅ Files skipped from review due to trivial changes (6)
- packages/project-builder-server/src/api/index.ts
- packages/create-project/bin/create-baseplate-project.js
- pnpm-workspace.yaml
- .changeset/ten-ducks-scream.md
- packages/project-builder-cli/bin/baseplate.js
- packages/ui-components/README.md
🚧 Files skipped from review as they are similar to previous changes (11)
- packages/project-builder-server/package.json
- turbo.json
- packages/project-builder-lib/package.json
- packages/utils/package.json
- packages/sync/package.json
- plugins/plugin-auth/package.json
- plugins/plugin-storage/package.json
- packages/fastify-generators/package.json
- packages/react-generators/package.json
- packages/core-generators/package.json
- package.json
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: kingston
PR: halfdomelabs/baseplate#562
File: plugins/plugin-auth/package.json:32-36
Timestamp: 2025-06-03T09:11:29.633Z
Learning: With TypeScript project references, TypeScript compilation is watched from the root level using "watch:tsc:root" script, so individual packages no longer need to include their "tsc:watch" scripts in their local "watch" commands. The local "tsc:watch" scripts are renamed from "watch:tsc" but are not meant to be run as part of the package's watch command since TypeScript watching is handled centrally at the workspace root.
🧬 Code Graph Analysis (1)
packages/project-builder-cli/src/cli.ts (1)
packages/project-builder-cli/src/index.ts (1)
runCli(14-29)
🪛 GitHub Actions: Test
packages/ui-components/package.json
[error] 1-1: pnpm install failed with frozen-lockfile because pnpm-lock.yaml is not up to date with package.json dependencies. The lockfile and package.json dependency specifiers do not match.
🪛 GitHub Actions: Lint
packages/ui-components/package.json
[error] 1-1: pnpm install failed with frozen-lockfile because pnpm-lock.yaml is not up to date with package.json dependencies. Lockfile and package.json specs do not match.
🪛 GitHub Actions: Test E2E
packages/ui-components/package.json
[error] 1-1: pnpm install failed with frozen-lockfile because pnpm-lock.yaml is not up to date with package.json dependencies. The lockfile and package.json specs do not match, causing ERR_PNPM_OUTDATED_LOCKFILE.
🔇 Additional comments (20)
packages/project-builder-cli/src/cli.ts (1)
1-11: LGTM! Clean CLI entry point implementation.The new CLI entry script follows excellent separation of concerns:
- Proper shebang for direct execution
- Correct ESM import syntax with .js extensions
- Appropriate top-level await usage (supported by Node.js ^22.0.0 requirement)
- Clean error handling with logging and proper exit codes
This structure nicely separates the executable entry point from the main CLI logic in
index.ts.packages/project-builder-cli/src/index.ts (1)
10-14: Excellent refactoring for better separation of concerns.The changes improve the code structure:
- Function is now properly exported for reusability and testing
- Clear JSDoc documentation describes the function's purpose
- Removal of execution concerns (shebang, error handling) allows this module to focus purely on CLI logic
This refactoring aligns perfectly with the TypeScript project references migration goals.
packages/project-builder-cli/package.json (3)
25-31: LGTM! Files list properly updated for the CLI restructuring.The files list changes are well-structured:
- ✅ Added
README.mdfor better package documentation- ✅ Excluded TypeScript build artifacts (
*.d.ts.map,*.tsbuildinfo) for cleaner packages- ✅ Included
bin/**/*to ship the new CLI launcherThese changes align perfectly with the monorepo standardization efforts.
36-42: Scripts correctly updated for the new CLI entry point.The
devandstartscripts now properly target./src/cli.tsinstead of the entire./srcdirectory, which:
- ✅ Aligns with the new CLI entry point structure
- ✅ Provides more precise execution targeting
- ✅ Supports the separation of concerns between
cli.ts(entry) andindex.ts(logic)This change is consistent with the retrieved learning about TypeScript project references where compilation watching is handled centrally at the workspace root.
22-22:Details
✅ Verification successful
Verify the new bin path works correctly.
The change from
./scripts/baseplate.jsto./bin/baseplate.jslooks correct for the CLI restructuring. Ensure that the newbin/baseplate.jsfile exists and properly invokes the compiled CLI code.
🏁 Script executed:
#!/bin/bash # Description: Verify the new bin/baseplate.js file exists and has correct content # Expected: File should exist and contain logic to run the compiled CLI # Check if the new bin file exists fd "baseplate.js" packages/project-builder-cli/bin/ # Show the content of the bin file to verify it's set up correctly cat packages/project-builder-cli/bin/baseplate.js 2>/dev/null || echo "File not found"Length of output: 195
Bin path verified
The new
packages/project-builder-cli/bin/baseplate.jsfile exists and correctly invokes the compiled CLI viaimport '../dist/cli.js'. All changes are approved..workspace-meta/config.ts (6)
14-19: LGTM: Clean utility function for dependency extraction.The function correctly extracts dependency keys from both
dependenciesanddevDependenciesfields.
21-23: LGTM: Simple and effective plugin package detection.The function correctly identifies plugin packages by their naming convention.
31-46: LGTM: Well-defined TypeScript configuration interface.The interface properly types the structure of
tsconfig.build.jsonfiles with appropriate optional properties.
49-49: LGTM: Enables root package inclusion for project references.This change aligns with the TypeScript project references setup that needs to manage the root configuration.
76-100: LGTM: Comprehensive file standardization logic.The logic correctly handles different package types and ensures proper file inclusion for build artifacts, templates, bin directories, and plugin manifests.
105-190:Details
✅ Verification successful
Verify the TypeScript project references plugin logic.
The plugin implements a comprehensive system for managing TypeScript project references. The logic appears sound, but let me verify the dependency resolution and path calculation logic.
🏁 Script executed:
#!/bin/bash # Description: Verify that TypeScript project references are correctly set up across packages. # Expected: All packages with TypeScript dependencies and build scripts should have proper tsconfig.build.json files. echo "=== Checking packages with TypeScript dependencies and build scripts ===" fd -t f "package.json" --exec jq -r 'select(.dependencies.typescript or .devDependencies.typescript) | select(.scripts.build) | .name' {} \; echo -e "\n=== Checking tsconfig.build.json files ===" fd -t f "tsconfig.build.json" --exec echo "Found: {}" \; echo -e "\n=== Verifying project references structure ===" fd -t f "tsconfig.build.json" --exec jq -r 'if .references then "\(.references | length) references in " + input_filename else "No references in " + input_filename end' {} \;Length of output: 2723
TypeScript project references plugin logic verified
All 13
tsconfig.build.jsonfiles were located and theirreferencesarrays match the expected inter-project dependencies:
- Root: 12 references
- plugin-auth: 6 references
- plugin-storage: 7 references
- project-builder-server: 6 references
- sync: 1 reference
- ui-components: 1 reference
- react-generators: 3 references
- utils: 0 references (no internal deps, as expected)
- project-builder-cli: 3 references
- fastify-generators: 3 references
- create-project: 1 reference
- project-builder-lib: 3 references
- core-generators: 2 references
The zero references in
utilsalign with its lack of internal dependencies. The parse errors seen when usingjqare due to its strict JSON rules and don’t reflect any runtime issue in the plugin. No changes are required.packages/project-builder-web/package.json (1)
14-20: LGTM: Proper package file standardization.The changes correctly add documentation files and exclude TypeScript build artifacts from the published package, aligning with the workspace meta configuration standards.
packages/create-project/package.json (2)
17-26: LGTM: Comprehensive file standardization.The files array properly includes documentation, excludes build artifacts, and adds the necessary templates and bin directories for CLI distribution.
16-16:Details
✅ Verification successful
Verify the new bin launcher script exists.
The executable entry point changed from
./dist/create-baseplate-project.jsto./bin/create-baseplate-project.js. Ensure the new launcher script is properly implemented.
🏁 Script executed:
#!/bin/bash # Description: Verify the new bin launcher script exists and is properly configured. # Expected: The bin/create-baseplate-project.js file should exist and be executable. echo "=== Checking for bin launcher script ===" if [ -f "packages/create-project/bin/create-baseplate-project.js" ]; then echo "✓ Bin launcher script exists" echo "Content preview:" head -10 "packages/create-project/bin/create-baseplate-project.js" else echo "✗ Bin launcher script missing" fi echo -e "\n=== Checking if the script references the built dist file ===" if [ -f "packages/create-project/bin/create-baseplate-project.js" ]; then rg -A 5 "dist.*create-baseplate-project" "packages/create-project/bin/create-baseplate-project.js" || echo "No dist reference found" fiLength of output: 756
Bin launcher script verified and correct
- The file
packages/create-project/bin/create-baseplate-project.jsexists and is executable.- It correctly references the compiled entry point in
../dist/create-baseplate-project.js.No further changes needed.
packages/ui-components/turbo.json (2)
6-6: LGTM: Cleaned up build outputs.Removing
tailwind.config.jsfrom outputs is appropriate since it's a configuration file, not a build artifact.
8-10:Details
✅ Verification successful
LGTM: Consistent task naming convention.
The rename from
build:storybooktostorybook:buildfollows a consistentaction:targetpattern. Ensure this aligns with the corresponding package.json script changes.
🏁 Script executed:
#!/bin/bash # Description: Verify that the turbo task rename aligns with package.json scripts. # Expected: The package.json should have a corresponding "storybook:build" script. echo "=== Checking ui-components package.json for storybook scripts ===" jq -r '.scripts | to_entries[] | select(.key | contains("storybook")) | "\(.key): \(.value)"' packages/ui-components/package.json echo -e "\n=== Checking root package.json for storybook scripts ===" jq -r '.scripts | to_entries[] | select(.key | contains("storybook")) | "\(.key): \(.value)"' package.jsonLength of output: 661
Verified: Task rename aligns with package.json scripts
The
storybook:buildtask in packages/ui-components/turbo.json now correctly matches thestorybook:buildscript defined in bothpackages/ui-components/package.jsonand the rootpackage.json. Everything is consistent—approving the change.packages/ui-components/package.json (4)
16-18: Confirm CSS export paths
The new entries expose CSS files at the package boundary ("./base-styles.css","./theme.css","./utilities.css"). This aligns with the move from source todist.
30-32: Approve new build orchestration scripts
Switchingbuildto runtscthen copy CSS (build:css) is a clean separation of concerns.
37-38: Approve Storybook script renames
Renaming to"storybook:build"and"storybook:dev"tightens consistency; removal ofdev:storybookis expected given the updated task config.
41-43: Approve watch script adjustments
Isolating CSS watching inwatchand adding a standalonetsc:watchaligns with root-level project references and central watch orchestration.
| "@testing-library/user-event": "14.6.1", | ||
| "@types/node": "catalog:", | ||
| "@vitejs/plugin-react": "catalog:", | ||
| "cpx2": "catalog:", |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Sync lockfile & verify CSS copier CLI
You’ve added cpx2 as a devDependency, which updates the lockfile. CI is currently failing due to ERR_PNPM_OUTDATED_LOCKFILE. Please run pnpm install and commit the updated pnpm-lock.yaml to resolve this. Also confirm whether the binary provided by cpx2 is invoked via cpx or cpx2; adjust the build:css script if needed.
🏁 Script executed:
#!/bin/bash
set -e
echo "🕵️♂️ Inspecting `cpx2` entry in package.json"
grep -n '"cpx2"' -n packages/ui-components/package.json
echo -e "\n🕵️♂️ Inspecting `build:css` script"
grep -n '"build:css"' -n packages/ui-components/package.json -A2Length of output: 675
🏁 Script executed:
#!/bin/bash
set -e
echo "🕵️♂️ Showing devDependencies block:"
grep -n '"devDependencies"' -n packages/ui-components/package.json -A20
echo -e "\n🕵️♂️ Searching for all occurrences of 'cpx' in package.json:"
grep -n '"cpx' -n packages/ui-components/package.jsonLength of output: 1305
Sync lockfile & correct CSS copier CLI
It looks like you added "cpx2": "catalog:" (packages/ui-components/package.json:108) but the build:css script still invokes cpx (line 31). This will fail if the new package only provides a cpx2 binary. Please:
- Run
pnpm installand commit the updatedpnpm-lock.yamlto resolveERR_PNPM_OUTDATED_LOCKFILE. - Verify which binary name
cpx2exposes (for example vianpm view cpx2 bin). - Update the
build:cssscript inpackages/ui-components/package.jsonto use the correct CLI (e.g.)."build:css": "cpx2 \"src/**/*.css\" dist --clean"
🤖 Prompt for AI Agents
In packages/ui-components/package.json at line 108, you added the devDependency
"cpx2" but did not update the build:css script at line 31, which still calls
"cpx". First, run "pnpm install" to update and commit the pnpm-lock.yaml file to
fix the outdated lockfile error. Then, verify the binary name provided by the
"cpx2" package (e.g., using "npm view cpx2 bin"). Finally, update the build:css
script to invoke the correct binary name, replacing "cpx" with "cpx2" if that is
the binary exposed by the package.
Summary by CodeRabbit