-
Notifications
You must be signed in to change notification settings - Fork 16
feat: full ESM config support using Jiti (build #1041) #1048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
""" WalkthroughThis pull request updates dependency management and refines configuration file loading across several projects. In multiple package manifests, TypeScript-related dependencies ( Changes
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (2)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (4)
examples/boilerplate-project/package.json (1)
2-2
: Typo in package nameThere's a typo in the package name: "boilerlate-project" should be "boilerplate-project".
- "name": "boilerlate-project", + "name": "boilerplate-project",packages/cli/src/playwright/playwright-config-loader.ts (1)
15-16
: Consider logging if no config file was found.While returning
undefined
clearly indicates that a config file was not found, providing a small log or debug message here could be beneficial to inform users why the config is missing. This is just a minor improvement for debugging.Also applies to: 19-20, 22-22
packages/cli/src/services/checkly-config-loader.ts (1)
112-114
: Early file existence check is convenient.Skipping non-existent files before attempting to load them prevents unnecessary errors. Consider logging or warning if multiple config files could be found concurrently, to guide users on potential configuration conflicts.
packages/create-cli/src/utils/fileloader.ts (1)
36-37
: Use optional chaining for safer property access.As hinted by static analysis, consider using
err.message?.includes('Unable to compile TypeScript')
to avoid potential runtime errors whenerr.message
is undefined.- if (err.message && err.message.contains('Unable to compile TypeScript')) { + if (err.message?.includes('Unable to compile TypeScript')) {🧰 Tools
🪛 Biome (1.9.4)
[error] 36-36: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (16)
examples/advanced-project/package.json
(1 hunks)examples/boilerplate-project/package.json
(1 hunks)packages/cli/package.json
(1 hunks)packages/cli/src/playwright/playwright-config-loader.ts
(1 hunks)packages/cli/src/services/__tests__/checkly-config-loader.spec.ts
(1 hunks)packages/cli/src/services/checkly-config-loader.ts
(3 hunks)packages/cli/src/services/project-parser.ts
(2 hunks)packages/cli/src/services/util.ts
(3 hunks)packages/create-cli/e2e/__tests__/fixtures/initiated-project/package.json
(1 hunks)packages/create-cli/e2e/__tests__/fixtures/playwright-project/package.json
(1 hunks)packages/create-cli/package.json
(1 hunks)packages/create-cli/src/actions/dependencies.ts
(1 hunks)packages/create-cli/src/actions/playwright.ts
(1 hunks)packages/create-cli/src/utils/__tests__/fixtures/checkly-project/package.json
(1 hunks)packages/create-cli/src/utils/directory.ts
(1 hunks)packages/create-cli/src/utils/fileloader.ts
(3 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
packages/create-cli/src/utils/fileloader.ts (1)
packages/cli/src/services/util.ts (1)
loadFile
(53-68)
packages/cli/src/services/util.ts (1)
packages/create-cli/src/utils/fileloader.ts (1)
loadFile
(3-18)
🪛 Biome (1.9.4)
packages/create-cli/src/utils/fileloader.ts
[error] 36-36: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
packages/cli/src/services/util.ts
[error] 86-86: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: test - windows-latest
- GitHub Check: test - ubuntu-latest
🔇 Additional comments (30)
examples/advanced-project/package.json (1)
14-14
: Good dependency update to support ESM modulesReplacing TypeScript tools (ts-node and typescript) with jiti is a good approach for enabling better ESM module support. Jiti acts as a runtime that can handle both TypeScript and ESM modules, which aligns well with the PR's goal of providing full ESM config support.
examples/boilerplate-project/package.json (1)
14-14
: Good dependency update to support ESM modulesThe addition of jiti as a replacement for ts-node and typescript follows the same pattern as other package.json files in this PR. This change will enable better ESM module support across example projects.
packages/cli/src/services/__tests__/checkly-config-loader.spec.ts (1)
26-26
: Good expansion of supported config file extensionsThe error message now includes additional file extensions (.mts, .cts, .cjs) that are now supported. This properly reflects the expanded config file format capabilities and is an important part of providing full ESM support. The .mts extension in particular is crucial for TypeScript ESM modules.
packages/create-cli/e2e/__tests__/fixtures/initiated-project/package.json (1)
13-13
: Good dependency update for test fixturesReplacing ts-node and typescript with jiti in test fixtures ensures that the test environment mirrors the expected real-world project structure. This change maintains consistency with the other package.json updates in this PR and properly tests the new dependency arrangement for ESM support.
packages/create-cli/src/actions/dependencies.ts (1)
15-18
: LGTM: Dependency update aligns with project-wide changesThe change from TypeScript-related tools (
ts-node
,typescript
) to usingjiti
is consistent with the broader project strategy. The version constraint^2
follows semantic versioning standards.packages/create-cli/src/utils/__tests__/fixtures/checkly-project/package.json (1)
12-15
: LGTM: Test fixture updated to match new dependency strategyThe fixture now correctly reflects the project's move from TypeScript-specific dependencies to using
jiti
as a runtime loader, maintaining consistency with the changes in the main code.packages/create-cli/e2e/__tests__/fixtures/playwright-project/package.json (1)
11-14
: LGTM: Playwright test fixture updated correctlyThis change properly aligns the Playwright project test fixture with the project's new dependency approach, consistently using
jiti ^2
instead of TypeScript-specific dependencies.packages/create-cli/src/actions/playwright.ts (1)
47-55
: LGTM: Enhanced configuration file supportGood enhancement to support additional module system file extensions. The function now properly handles
.mts
,.cts
, and.cjs
configuration files, increasing flexibility for users with different module preferences.packages/create-cli/src/utils/directory.ts (1)
27-35
: Improved error handling and file extension supportThis change enhances the
loadPlaywrightConfig
function with proper existence checks and expanded file extension support. The regex/\.[mc]?(js|ts)$/
now handles ESM and CommonJS variants, supporting.js
,.ts
,.mjs
,.cjs
,.mts
, and.cts
files.packages/create-cli/package.json (2)
83-83
: LGTM - Adding jiti as a dev dependencyAdding jiti aligns with the PR's goals to support ESM configs.
89-96
: Good approach making jiti an optional peer dependencyMaking jiti an optional peer dependency with
>=2
version constraint provides flexibility while ensuring compatibility when it's present.packages/cli/package.json (2)
116-116
: LGTM - Adding jiti as a dev dependencyAdding jiti aligns with the PR's goals to support ESM configs.
124-131
: Good approach making jiti an optional peer dependencyMaking jiti an optional peer dependency with
>=2
version constraint provides flexibility while ensuring compatibility when it's present.packages/cli/src/services/project-parser.ts (2)
3-3
: LGTM - Updated import to use consolidated file loaderImporting the unified
loadFile
function instead of separate loaders simplifies the code.
88-93
: Improved code with unified file loading approachThe updated implementation:
- Simplifies logic by using a single regex for all supported file types
- Uses a unified
loadFile
function instead of separate functions for JS and TS- Adds support for additional file extensions (
.mjs
,.cjs
,.mts
,.cts
)This change improves maintainability while expanding format support.
packages/cli/src/playwright/playwright-config-loader.ts (2)
2-3
: Good import consolidation.Consolidating filesystem and utility imports at the top helps keep the code more organized.
6-13
: Support for multiple config file extensions is a robust addition.Including
.mts
,.cts
,.mjs
, and.cjs
offers extra flexibility for Playwright configuration.packages/cli/src/services/checkly-config-loader.ts (3)
3-3
: Centralized file loading is a good refactor.Using
loadFile
from./util
ensures consistent file-loading logic across the codebase and removes duplicated code.
80-88
: Expanding configuration file extensions increases compatibility.Adding
.mts
,.cts
, and.cjs
provides more ways for users to structure their Checkly config.
107-107
: Defaults maintain clarity and ease-of-use.Introducing new default filenames in the
loadChecklyConfig
parameters is straightforward and meshes well with the broader multi-extension support.packages/create-cli/src/utils/fileloader.ts (6)
3-11
: Refined file loading logic enhances modularity.Using a single
loadFile
function that dynamically branches for TS or JS simplifies future maintenance and reduces duplicated code.
20-26
:loadTsFileDefault
is a clean abstraction.Centralizing the TypeScript-specific loading path via
jiti
or fallback options is a great approach to handle different TS setups.
28-40
: Fallback tots-node
ensures backward compatibility.This logic rightly handles scenarios where
jiti
is not installed, usingts-node
as a graceful fallback.🧰 Tools
🪛 Biome (1.9.4)
[error] 36-36: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
48-53
: Type alias for Jiti usage is well structured.Storing the
Jiti
type here is clear for future reference if more Jiti-based functionality is added.
55-67
:getJiti
on demand is performance-friendly.Lazily importing and caching Jiti avoids overhead for users who are not using TypeScript. This design is sensible.
71-90
:getTsNodeService
gracefully accommodates TS projects without jiti.The fallback logic is robust, and the code re-enables then disables the TS compiler as needed, minimizing side effects.
packages/cli/src/services/util.ts (4)
53-61
: Streamlined file loader logic.This updated
loadFile
function neatly distinguishes between TypeScript and other file extensions, and the fallback to call the default export if it's a function is well-handled. No issues detected here.
98-103
: Advanced TypeScript pattern forJiti
type.Using a dynamically inferred return type here is acceptable given the complexity of the
jiti
import. This helps avoid direct type imports that cause issues in certain test environments.
105-118
: Robust lazy loading of thejiti
module.This approach avoids introducing an explicit dependency for all users, and the error handling for missing
jiti
is well-managed.
120-141
: Selectivets-node
dynamic import for backward compatibility.This gated logic effectively avoids forcing
ts-node
on all users. The error handling for the module not found scenario is correct and returnsundefined
gracefully.
This comment has been minimized.
This comment has been minimized.
207cdd4
to
314a3b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
packages/cli/src/services/util.ts (1)
71-97
: Useincludes
instead of non-standardcontains
.This is a repeat of a past comment.
String.prototype.contains
is not supported in many environments. Switch tomessage.includes(...)
for reliability.- if (err.message && err.message.contains('Unable to compile TypeScript')) { + if (err.message && err.message.includes('Unable to compile TypeScript')) {🧰 Tools
🪛 Biome (1.9.4)
[error] 87-87: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
🧹 Nitpick comments (8)
packages/create-cli/src/utils/fileloader.ts (4)
3-11
: Improve cross-platform consistency for imports.Currently, the code directly calls
import(filepath)
. In other files,pathToPosix(filepath)
is used to normalize paths across platforms. Consider aligning this approach here to avoid potential path separator issues on Windows.- exported = (await import(filepath)).default + exported = (await import(pathToPosix(filepath))).default
20-26
: Add tests to ensure fallback logic is functioning correctly.The introduction of
loadTsFileDefault
is a good step toward handling TypeScript files. However, consider adding unit tests that confirm Jiti-based loading works as intended and properly falls back tots-node
if Jiti is not found.
55-68
: Ensure caching logic is robust.
getJiti()
caches the imported Jiti instance in a module-level variable. Ensure that the rest of the codebase never inadvertently re-initializes or overrides this variable. Also confirm that partial module reloads won't cause any unexpected re-import logic.
71-91
: Check fallback synergy with custom TS config.When using
ts-node
fallback, any custom TypeScript configurations (tsconfig.json) might not be fully respected unless explicitly passed in. Consider clarifying or documenting how overrides are handled, if at all.packages/cli/src/playwright/playwright-config-loader.ts (1)
2-22
: Consider returning null or throwing if no config is found.Returning
undefined
at line 22 can be slightly ambiguous. Consider returningnull
or throwing an explicit error to better indicate a missing config. This can help prevent silent failures when no config file exists.packages/cli/src/services/util.ts (3)
54-69
: Ensure consistent import normalization.This loading logic mirrors other files. If there's any Windows path normalization concern, consider using
pathToPosix(filepath)
consistently to reduce unexpected path separator issues.
106-119
: Validate fallback logic for Jiti import errors.If the user has installed an incompatible Jiti version, the code rethrows the error, which is good. Consider adding an additional message or logs to highlight potential version mismatches.
122-141
: Checkts-node
usage for advanced TS features.
tsNodeService
is re-enabled and disabled around the load, which is a neat approach. However, be mindful that more advanced TS features (like project references) may require an extended configuration.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (17)
.github/workflows/test.yml
(1 hunks)examples/advanced-project/package.json
(1 hunks)examples/boilerplate-project/package.json
(1 hunks)packages/cli/package.json
(1 hunks)packages/cli/src/playwright/playwright-config-loader.ts
(1 hunks)packages/cli/src/services/__tests__/checkly-config-loader.spec.ts
(1 hunks)packages/cli/src/services/checkly-config-loader.ts
(3 hunks)packages/cli/src/services/project-parser.ts
(2 hunks)packages/cli/src/services/util.ts
(3 hunks)packages/create-cli/e2e/__tests__/fixtures/initiated-project/package.json
(1 hunks)packages/create-cli/e2e/__tests__/fixtures/playwright-project/package.json
(1 hunks)packages/create-cli/package.json
(1 hunks)packages/create-cli/src/actions/dependencies.ts
(1 hunks)packages/create-cli/src/actions/playwright.ts
(1 hunks)packages/create-cli/src/utils/__tests__/fixtures/checkly-project/package.json
(1 hunks)packages/create-cli/src/utils/directory.ts
(1 hunks)packages/create-cli/src/utils/fileloader.ts
(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (13)
- .github/workflows/test.yml
- packages/create-cli/src/actions/dependencies.ts
- packages/cli/src/services/tests/checkly-config-loader.spec.ts
- packages/create-cli/src/utils/directory.ts
- packages/create-cli/e2e/tests/fixtures/playwright-project/package.json
- examples/advanced-project/package.json
- packages/create-cli/e2e/tests/fixtures/initiated-project/package.json
- packages/create-cli/package.json
- examples/boilerplate-project/package.json
- packages/create-cli/src/utils/tests/fixtures/checkly-project/package.json
- packages/cli/package.json
- packages/create-cli/src/actions/playwright.ts
- packages/cli/src/services/project-parser.ts
🧰 Additional context used
🧬 Code Graph Analysis (3)
packages/cli/src/playwright/playwright-config-loader.ts (3)
packages/create-cli/src/utils/directory.ts (1)
loadPlaywrightConfig
(26-36)packages/cli/src/services/util.ts (1)
loadFile
(54-69)packages/create-cli/src/utils/fileloader.ts (1)
loadFile
(3-18)
packages/cli/src/services/util.ts (1)
packages/create-cli/src/utils/fileloader.ts (1)
loadFile
(3-18)
packages/create-cli/src/utils/fileloader.ts (1)
packages/cli/src/services/util.ts (1)
loadFile
(54-69)
🪛 Biome (1.9.4)
packages/cli/src/services/util.ts
[error] 87-87: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
packages/create-cli/src/utils/fileloader.ts
[error] 36-36: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: test - windows-latest
- GitHub Check: test - ubuntu-latest
🔇 Additional comments (4)
packages/create-cli/src/utils/fileloader.ts (1)
48-53
: No immediate concerns.Defining the
Jiti
type inline is acceptable. Just ensure that if further expansions are needed, it might be clearer to place it in a dedicated.d.ts
file.packages/cli/src/services/util.ts (1)
99-105
: Jiti type definition looks fine.No issues noted with the approach. It's a succinct way to handle dynamic import types.
packages/cli/src/services/checkly-config-loader.ts (2)
3-3
: Expanded list of supported config extensions is helpful.Adding
.mts
,.cts
, and.cjs
broadens compatibility for ESM configs. The approach here is consistent with the rest of the PR, so no major concerns.Also applies to: 81-88
107-107
: Validate partial configuration loading.When a config file is found and loaded, ensure that partial or incomplete user-defined fields throw the desired errors. The rest of the logic correctly handles missing required fields. Looks good overall.
Would you like a script to search for references to
loadChecklyConfig
to ensure partial config usage is tested properly?Also applies to: 112-114
314a3b8
to
e88b6c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
packages/create-cli/src/utils/fileloader.ts (1)
37-37
: Prefer optional chaining to check for the error message.Using optional chaining can simplify the null check logic and improve readability:
- if (err.message && err.message.includes('Unable to compile TypeScript')) { + if (err.message?.includes('Unable to compile TypeScript')) {🧰 Tools
🪛 Biome (1.9.4)
[error] 37-37: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
packages/cli/src/services/util.ts (1)
88-88
: Use optional chaining for safer error message checks.Replacing the
&&
condition with the optional chain can streamline this check:- if (err.message && err.message.includes('Unable to compile TypeScript')) { + if (err.message?.includes('Unable to compile TypeScript')) {🧰 Tools
🪛 Biome (1.9.4)
[error] 88-88: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (17)
.github/workflows/test.yml
(1 hunks)examples/advanced-project/package.json
(1 hunks)examples/boilerplate-project/package.json
(1 hunks)packages/cli/package.json
(2 hunks)packages/cli/src/playwright/playwright-config-loader.ts
(1 hunks)packages/cli/src/services/__tests__/checkly-config-loader.spec.ts
(1 hunks)packages/cli/src/services/checkly-config-loader.ts
(3 hunks)packages/cli/src/services/project-parser.ts
(2 hunks)packages/cli/src/services/util.ts
(3 hunks)packages/create-cli/e2e/__tests__/fixtures/initiated-project/package.json
(1 hunks)packages/create-cli/e2e/__tests__/fixtures/playwright-project/package.json
(1 hunks)packages/create-cli/package.json
(1 hunks)packages/create-cli/src/actions/dependencies.ts
(1 hunks)packages/create-cli/src/actions/playwright.ts
(1 hunks)packages/create-cli/src/utils/__tests__/fixtures/checkly-project/package.json
(1 hunks)packages/create-cli/src/utils/directory.ts
(1 hunks)packages/create-cli/src/utils/fileloader.ts
(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (15)
- packages/create-cli/src/actions/dependencies.ts
- examples/advanced-project/package.json
- .github/workflows/test.yml
- packages/create-cli/src/actions/playwright.ts
- packages/cli/src/playwright/playwright-config-loader.ts
- packages/cli/src/services/tests/checkly-config-loader.spec.ts
- packages/create-cli/e2e/tests/fixtures/playwright-project/package.json
- packages/create-cli/package.json
- packages/cli/src/services/project-parser.ts
- packages/create-cli/e2e/tests/fixtures/initiated-project/package.json
- packages/cli/package.json
- packages/create-cli/src/utils/directory.ts
- packages/cli/src/services/checkly-config-loader.ts
- packages/create-cli/src/utils/tests/fixtures/checkly-project/package.json
- examples/boilerplate-project/package.json
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/cli/src/services/util.ts (1)
packages/create-cli/src/utils/fileloader.ts (1)
loadFile
(4-19)
🪛 Biome (1.9.4)
packages/create-cli/src/utils/fileloader.ts
[error] 37-37: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
packages/cli/src/services/util.ts
[error] 88-88: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
🔇 Additional comments (2)
packages/create-cli/src/utils/fileloader.ts (1)
4-19
: Unified file loading approach looks good.This refactor consolidates JavaScript and TypeScript loading into a single function, improving maintainability and reducing code duplication. Nicely done!
packages/cli/src/services/util.ts (1)
55-66
: Consistent loader pattern is well-structured.Loading
.ts
or.mts
files vialoadTsFileDefault
and.js
files via native import is a neat solution for unified file handling.
🎉 Experimental release successfully published on npm
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
packages/create-cli/src/utils/fileloader.ts (3)
10-10
: Consider normalizing file paths for Windows compatibilityUnlike the similar function in
packages/cli/src/services/util.ts
which usespathToPosix(filepath)
, this implementation might have issues on Windows systems when using direct file paths with backslashes.- exported = (await import(filepath)).default + exported = (await import(filepath.replace(/\\/g, '/'))).default
37-37
: Use optional chaining for cleaner codeThe current error message check can be simplified using optional chaining.
- if (err.message && err.message.includes('Unable to compile TypeScript')) { + if (err.message?.includes('Unable to compile TypeScript')) {🧰 Tools
🪛 Biome (1.9.4)
[error] 37-37: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
4-19
: Consider DRYing up code across packagesThis
loadFile
function is similar to the one inpackages/cli/src/services/util.ts
. Consider extracting these utilities to a shared package to avoid duplication and ensure consistent behavior.Also applies to: 55-70
packages/cli/src/services/util.ts (2)
55-63
: Consider returning a more precise type thanany
.Relying on
any
can make it harder to detect type errors at compile-time. If feasible, consider using a more specific type or a generic parameter for improved type safety.
72-99
: Use optional chaining for concise error checks.At line 89, replace the
err.message && err.message.includes(...)
check with optional chaining for brevity:- if (err.message && err.message.includes('Unable to compile TypeScript')) { + if (err.message?.includes('Unable to compile TypeScript')) {🧰 Tools
🪛 Biome (1.9.4)
[error] 88-88: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (4)
packages/cli/package.json
(3 hunks)packages/cli/src/services/util.ts
(3 hunks)packages/create-cli/package.json
(2 hunks)packages/create-cli/src/utils/fileloader.ts
(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/cli/package.json
- packages/create-cli/package.json
🧰 Additional context used
🧬 Code Graph Analysis (2)
packages/cli/src/services/util.ts (1)
packages/create-cli/src/utils/fileloader.ts (1)
loadFile
(4-19)
packages/create-cli/src/utils/fileloader.ts (1)
packages/cli/src/services/util.ts (1)
loadFile
(55-70)
🪛 Biome (1.9.4)
packages/cli/src/services/util.ts
[error] 88-88: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
packages/create-cli/src/utils/fileloader.ts
[error] 37-37: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
🔇 Additional comments (6)
packages/create-cli/src/utils/fileloader.ts (4)
4-19
: LGTM: File loading functionality has been generalizedThe renamed function now properly handles both JavaScript and TypeScript files, with a clear separation of concerns. The regex pattern
/\.[mc]?ts$/
appropriately matches all TypeScript file extensions (.ts
,.mts
,.cts
).
21-48
: LGTM: Robust TypeScript file loading with progressive enhancementWell-structured approach that prioritizes
jiti
while maintaining backward compatibility withts-node
. The error messages are informative and guide users toward the recommended approach.🧰 Tools
🪛 Biome (1.9.4)
[error] 37-37: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
41-43
: LGTM: Proper compiler state managementExcellent use of the
finally
block to ensure the TypeScript compiler is disabled even when errors occur. This addresses the previous review comment and prevents potential side effects.
50-70
: LGTM: Clean implementation of dynamic Jiti loadingThe dynamic import approach with caching is a good strategy to avoid requiring dependencies that users might not have installed. The type definition is also well handled.
packages/cli/src/services/util.ts (2)
101-119
: Dynamic import forjiti
looks good.The lazy, cached approach for loading
jiti
is well-structured. No further issues noted here.
125-143
: Fallback logic forts-node
is well-handled.Your usage of a cached service and a return to disabled state after errors avoids resources remaining enabled. Looks good.
This PR merges #1041.
Temporarily disables testing on Windows due to (presumably) ts-jest and jiti fighting over the module cache. A different test setup is needed to make this work.