feat: enable ts support by process.env.EGG_TS_ENABLE = true#43
feat: enable ts support by process.env.EGG_TS_ENABLE = true#43
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Function as isSupportTypeScript()
Caller->>Function: Call isSupportTypeScript()
Function->>Function: Check for ".ts" extension or process.env.VITEST=='true'
alt Condition satisfied
Function->>Caller: Return true
else Not satisfied
Function->>Function: Check process.env.EGG_TS_ENABLE=='true'
alt Condition satisfied
Function->>Caller: Return true
else Condition not satisfied
Function->>Caller: Return false
end
end
Possibly related PRs
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
src/import.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-eggache". (The package "eslint-plugin-eggache" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following: The plugin "eslint-plugin-eggache" was referenced from the config file in ".eslintrc » eslint-config-egg/typescript » ./index.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. ✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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 (
|
commit: |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #43 +/- ##
==========================================
+ Coverage 88.14% 88.16% +0.01%
==========================================
Files 8 8
Lines 751 752 +1
Branches 133 133
==========================================
+ Hits 662 663 +1
Misses 89 89 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/import.ts (1)
43-46: Consider documenting this new flag.This new environment variable provides a useful way to enable TypeScript support. Consider documenting this feature in the project's README or documentation to ensure users are aware of this option.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/import.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (15)
- GitHub Check: Node.js / Test (windows-latest, 23)
- GitHub Check: Node.js / Test (windows-latest, 22)
- GitHub Check: Node.js / Test (windows-latest, 20)
- GitHub Check: Node.js / Test (windows-latest, 18)
- GitHub Check: Node.js / Test (windows-latest, 18.19.0)
- GitHub Check: Node.js / Test (ubuntu-latest, 23)
- GitHub Check: Node.js / Test (ubuntu-latest, 22)
- GitHub Check: Node.js / Test (ubuntu-latest, 20)
- GitHub Check: Node.js / Test (ubuntu-latest, 18.19.0)
- GitHub Check: Node.js / Test (ubuntu-latest, 18)
- GitHub Check: Node.js / Test (macos-latest, 23)
- GitHub Check: Node.js / Test (macos-latest, 22)
- GitHub Check: Node.js / Test (macos-latest, 20)
- GitHub Check: Node.js / Test (macos-latest, 18.19.0)
- GitHub Check: Node.js / Test (macos-latest, 18)
🔇 Additional comments (3)
src/import.ts (3)
43-44: Environment variable addition looks good.The addition of
process.env.EGG_TS_ENABLEas an alternative way to enable TypeScript support is a good enhancement that provides more flexibility for users. The implementation correctly maintains the existing behavior while adding this new option.
45-46: Good debugging enhancement.The updated debug logging now includes the value of
process.env.EGG_TS_ENABLE, which improves observability when troubleshooting TypeScript support issues. This change is well-aligned with the functional changes made above.
43-46:Details
❓ Verification inconclusive
Verify TypeScript support behavior with the new environment variable.
The changes look good functionally. It would be beneficial to ensure that TypeScript support works correctly when enabled via
EGG_TS_ENABLE=truewhile the other conditions are false.
🏁 Script executed:
#!/bin/bash # Check if there are any tests verifying the TypeScript support behavior # when only EGG_TS_ENABLE=true is set rg -p "EGG_TS_ENABLE.*true" --type ts rg -p "isSupportTypeScript" --type testLength of output: 256
Action: Confirm explicit test coverage for enabling TypeScript solely via
EGG_TS_ENABLEThe logic in
src/import.ts(lines 43–46) clearly checks for TypeScript support using the new environment variable. However, while our search confirmed that the environment variable is processed (see line 44), we did not locate any tests explicitly verifying the scenario where onlyEGG_TS_ENABLE=trueis set. Please ensure this behavior is covered in your test suite—either by adding a dedicated test case or by manually verifying that TypeScript support activates correctly when other conditions are false.
There was a problem hiding this comment.
PR Overview
This PR expands support for TypeScript by additionally checking process.env.EGG_TS_ENABLE, and it updates the logging details to give a more comprehensive status.
- Added a condition to enable TS support via process.env.EGG_TS_ENABLE.
- Enhanced the debug log to include the new environment variable.
Reviewed Changes
| File | Description |
|---|---|
| src/import.ts | Updated TypeScript support detection logic and debug log to include process.env.EGG_TS_ENABLE. |
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
src/import.ts:43
- [nitpick] Consider clarifying this comment to explicitly mention that TypeScript is enabled when either '.ts' exists, process.env.VITEST or process.env.EGG_TS_ENABLE is 'true'.
// enable ts by process.env.EGG_TS_ENABLE or process.env.VITEST
src/import.ts:45
- Verify that the additional '%j' placeholder for process.env.EGG_TS_ENABLE is correctly handled by the debug logger to maintain the intended log output format.
debug('[isSupportTypeScript] %o, extensions: %j, process.env.VITEST: %j, process.env.EGG_TS_ENABLE: %j',
[skip ci] ## [4.4.0](v4.3.0...v4.4.0) (2025-03-04) ### Features * enable ts support by process.env.EGG_TS_ENABLE = true ([#43](#43)) ([4908ffc](4908ffc))
eggjs/utils#43 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new diagnostic script for capturing and logging framework configuration details, including plugins and performance metrics. - Enhanced compatibility with ECMAScript module environments for smoother diagnostic operations. - Added new classes and methods to improve application structure and functionality. - Introduced new plugin configurations and context management features. - **Bug Fixes** - Updated import statements to ensure correct file references for JavaScript files. - **Refactor** - Updated package configuration with additional resources and dependency version updates. - Improved internal parameter handling to better encapsulate support utilities. - Modified import statement generation for TypeScript files to ensure correct JavaScript file references. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit