Conversation
|
Warning Rate limit exceeded@justin808 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 45 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (43)
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. ✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 Code Review for TypeScript Migration (Phase 2)Thank you for this well-structured TypeScript migration PR! I've thoroughly reviewed the changes and here's my feedback: ✅ Strengths
🔴 Critical Issues Found
|
Code Review: TypeScript Migration Phase 2I've reviewed this PR thoroughly, and here's my comprehensive feedback on the TypeScript migration for the core modules. ✅ Strengths
🐛 Critical Issues
|
Code Review: TypeScript Migration Phase 2Thank you for this PR implementing Phase 2 of the TypeScript migration! I've reviewed the changes comprehensively and here's my feedback: ✅ Strengths
🔍 Code Quality Issues
🐛 Potential Bugs
🚀 Performance Considerations
🔒 Security Concerns
🧪 Test Coverage
📝 Recommendations
🎯 Next StepsThe PR is on the right track but needs the above issues addressed before merging. The trailing newlines and the Great work on maintaining backward compatibility and the thoughtful migration approach! Once the issues are addressed, this will be a solid foundation for the remaining TypeScript migration phases. 🤖 Generated with Claude Code |
There was a problem hiding this comment.
Pull Request Overview
This PR implements Phase 2 of the TypeScript migration for the NPM package, converting core modules to TypeScript while maintaining full backward compatibility with existing JavaScript code.
- Converts 9 core modules from JavaScript to TypeScript with proper type annotations
- Introduces comprehensive TypeScript interfaces for Config, Env, and DevServerConfig
- Maintains CommonJS export pattern using
export =for backward compatibility
Reviewed Changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| package/types.ts | Defines TypeScript interfaces for core configuration objects |
| package/config.ts | Configuration handling with type safety |
| package/env.ts | Environment variable processing with type annotations |
| package/index.ts | Main entry point with webpack configuration generation |
| package/dev_server.ts | Dev server configuration with type checking |
| package/environments/base.ts | Base webpack configuration with comprehensive typing |
| package/utils/helpers.ts | Core utility functions with type safety |
| package/utils/configPath.ts | Config path resolution with type annotations |
| package/utils/defaultConfigPath.ts | Default config path with type safety |
| package/utils/inliningCss.ts | CSS inlining logic with type checking |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| const match = packageFullVersion(packageName).match(/^\d+/) | ||
| return match ? match[0] : "0" |
There was a problem hiding this comment.
The function could throw an error if packageFullVersion fails, but the fallback return value '0' assumes success. Consider wrapping the call in a try-catch block to handle cases where the package doesn't exist or has an invalid version format.
| const match = packageFullVersion(packageName).match(/^\d+/) | |
| return match ? match[0] : "0" | |
| try { | |
| const match = packageFullVersion(packageName).match(/^\d+/) | |
| return match ? match[0] : "0" | |
| } catch (e) { | |
| return "0" | |
| } |
| const railsEnv = process.env.RAILS_ENV | ||
| const rawNodeEnv = process.env.NODE_ENV | ||
| const nodeEnv = | ||
| rawNodeEnv && NODE_ENVIRONMENTS.includes(rawNodeEnv as any) ? rawNodeEnv : DEFAULT |
There was a problem hiding this comment.
Using as any to bypass TypeScript checking defeats the purpose of type safety. Consider using a type predicate function: const isValidNodeEnv = (env: string): env is typeof NODE_ENVIRONMENTS[number] => NODE_ENVIRONMENTS.includes(env as any) and then use isValidNodeEnv(rawNodeEnv).
| const railsEnv = process.env.RAILS_ENV | |
| const rawNodeEnv = process.env.NODE_ENV | |
| const nodeEnv = | |
| rawNodeEnv && NODE_ENVIRONMENTS.includes(rawNodeEnv as any) ? rawNodeEnv : DEFAULT | |
| function isValidNodeEnv(env: string): env is typeof NODE_ENVIRONMENTS[number] { | |
| return NODE_ENVIRONMENTS.includes(env as typeof NODE_ENVIRONMENTS[number]); | |
| } | |
| const railsEnv = process.env.RAILS_ENV | |
| const rawNodeEnv = process.env.NODE_ENV | |
| const nodeEnv = | |
| rawNodeEnv && isValidNodeEnv(rawNodeEnv) ? rawNodeEnv : DEFAULT |
| Object.keys(devServerConfig).forEach((key) => { | ||
| const envValue = envFetch(`${envPrefix}_${key.toUpperCase()}`) | ||
| if (envValue !== undefined) { | ||
| ;(devServerConfig as any)[key] = envValue | ||
| } | ||
| }) |
There was a problem hiding this comment.
Using as any bypasses TypeScript's type checking. Consider using a more type-safe approach with index signature or Object.assign to maintain type safety while allowing dynamic property assignment.
| Object.keys(devServerConfig).forEach((key) => { | |
| const envValue = envFetch(`${envPrefix}_${key.toUpperCase()}`) | |
| if (envValue !== undefined) { | |
| ;(devServerConfig as any)[key] = envValue | |
| } | |
| }) | |
| const envOverrides: Partial<DevServerConfig> = {} | |
| Object.keys(devServerConfig).forEach((key) => { | |
| const envValue = envFetch(`${envPrefix}_${key.toUpperCase()}`) | |
| if (envValue !== undefined) { | |
| (envOverrides as any)[key] = envValue | |
| } | |
| }) | |
| Object.assign(devServerConfig, envOverrides) |
Code Review for PR #608: TypeScript Migration (Phase 2)Thank you for this comprehensive TypeScript migration PR! I've reviewed the changes and here's my feedback: ✅ Strengths
🚨 Critical Issues1. Missing JavaScript File DeletionThe PR creates TypeScript versions (
Required Actions:
2. Missing Build ConfigurationThe {
"scripts": {
"build": "tsc",
"prepare": "npm run build"
}
}3. Type Safety IssuesSeveral places use
🐛 Potential Bugs
⚡ Performance Considerations
🔒 Security Concerns
🧪 Test Coverage
📝 Additional Recommendations
🎯 Next StepsBefore this PR can be merged:
The foundation is solid, but the PR needs these critical issues resolved before it's ready for production. The phased approach is excellent, but each phase needs to be complete and functional. Great work on the migration strategy and documentation! With these changes, this will be a strong addition to v9. 🚀 |
Code Review: TypeScript Migration Phase 2 ✅Overall Assessment: EXCELLENT (9/10)This PR successfully implements Phase 2 of the TypeScript migration with zero breaking changes while adding significant value through improved type safety. ✅ Strengths1. Perfect CommonJS Compatibility
2. Comprehensive Type Definitions
3. Outstanding Documentation
4. Smart Migration Strategy
5. Proper File Structure
🔍 Code Quality ObservationsMinor Areas for Future Improvement
Critical Bugs Already Fixed ✅
🎯 Specific HighlightsExcellent Type Safety Example (
|
Code Review: TypeScript Migration Phase 2Overall AssessmentGreat work on Phase 2 of the TypeScript migration! The PR successfully converts core modules to TypeScript while maintaining backward compatibility. The implementation is solid with good type safety improvements. However, there are several areas that need attention before merging. ✅ Strengths
🔧 Issues & Recommendations1. TypeScript Configuration (
|
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 14 out of 17 changed files in this pull request and generated 4 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| const { runningWebpackDevServer } = require("../env") | ||
| const devServer = require("../dev_server") | ||
|
|
||
| // This logic is tied to lib/shakapacker/instance.rb | ||
| const inliningCss: boolean = | ||
| runningWebpackDevServer && !!devServer.hmr && devServer.inline_css !== false | ||
|
|
||
| export = inliningCss |
There was a problem hiding this comment.
[nitpick] Mixed import styles detected. Since this is a TypeScript file, consider using ES6 import syntax consistently instead of require() for better type safety and IDE support.
| const { runningWebpackDevServer } = require("../env") | |
| const devServer = require("../dev_server") | |
| // This logic is tied to lib/shakapacker/instance.rb | |
| const inliningCss: boolean = | |
| runningWebpackDevServer && !!devServer.hmr && devServer.inline_css !== false | |
| export = inliningCss | |
| import { runningWebpackDevServer } from "../env"; | |
| import devServer from "../dev_server"; | |
| // This logic is tied to lib/shakapacker/instance.rb | |
| const inliningCss: boolean = | |
| runningWebpackDevServer && !!devServer.hmr && devServer.inline_css !== false | |
| export default inliningCss; |
| } catch (e: any) { | ||
| if (e.code !== "MODULE_NOT_FOUND") { | ||
| throw e | ||
| } | ||
| return null |
There was a problem hiding this comment.
[nitpick] Using 'any' type defeats the purpose of TypeScript's type safety. Consider using a more specific type like 'Error' or 'unknown' with proper type narrowing.
| } catch (e: any) { | |
| if (e.code !== "MODULE_NOT_FOUND") { | |
| throw e | |
| } | |
| return null | |
| } catch (e: unknown) { | |
| if ( | |
| typeof e === "object" && | |
| e !== null && | |
| "code" in e && | |
| (e as { code?: unknown }).code === "MODULE_NOT_FOUND" | |
| ) { | |
| return null | |
| } | |
| throw e |
| /* eslint global-require: 0 */ | ||
| /* eslint import/no-dynamic-require: 0 */ |
There was a problem hiding this comment.
[nitpick] These ESLint disable comments suggest the use of dynamic requires. Consider refactoring to use static imports where possible for better TypeScript support and tree shaking.
| Object.keys(devServerConfig).forEach((key) => { | ||
| const envValue = envFetch(`${envPrefix}_${key.toUpperCase()}`) | ||
| if (envValue !== undefined) { | ||
| ;(devServerConfig as any)[key] = envValue |
There was a problem hiding this comment.
[nitpick] Using 'any' type assertion bypasses TypeScript's type checking. Consider using a more type-safe approach, such as defining a proper index signature or using Object.assign with proper typing.
| ;(devServerConfig as any)[key] = envValue | |
| devServerConfig[key] = envValue |
Code Review - TypeScript Migration Phase 2After thoroughly reviewing this PR, here is my comprehensive feedback: What Works Well
Critical Issues Requiring Attention
Best Practice Concerns
Performance & Security
Test Coverage Recommendations
Required Actions Before Merge
Future Enhancements
SummaryThis PR provides excellent groundwork for TypeScript adoption with a smart migration strategy and strong attention to backward compatibility. The main blocker is the missing build infrastructure - without it, the TypeScript files won't actually be used. Once the build setup is added and linting issues are fixed, this will be ready to merge. The phased approach is perfect for a library of this size. Verdict: Approve with changes - needs build infrastructure and linting fixes. Great work on the documentation and maintaining backward compatibility! |
Code Review for TypeScript Migration (Phase 2)Thank you for this comprehensive TypeScript migration PR! I've reviewed the changes and have the following feedback: ✅ Strengths
🔍 Issues & Concerns1. Critical: Duplicate JavaScript and TypeScript FilesI notice both .js and .ts files exist in the package directory (e.g., config.js and config.ts). This creates confusion:
Recommendation: Either:
2. Bug in config.ts (Line 13)In the original JS file: const defaultConfig = load(readFileSync(defaultConfigPath), "utf8")In the TS file: const defaultConfig = load(readFileSync(defaultConfigPath, "utf8")) as YamlConfigThe TypeScript version correctly fixes the argument order - good catch! The utf8 encoding should be passed to readFileSync, not load. 3. Mixed Import StylesFiles use both ES6 imports and CommonJS require: import { resolve } from "path"
const { ensureTrailingSlash } = require("./utils/helpers")Consider using consistent import style throughout, though this may be intentional for backward compatibility. 4. Loose TypeScript ConfigurationThe tsconfig.json has all strict checks disabled: "strict": false,
"noImplicitAny": false,
"strictNullChecks": falseWhile this aids migration, consider gradually enabling these checks in future phases. 5. Missing Type ExportsThe index.d.ts file was reduced from 150 lines to 3. Ensure all necessary types are properly re-exported for users who need them. 6. Circular Dependency Potentialconfig.ts requires env.ts, and env.ts loads config files. Verify this doesn't create circular dependencies at runtime. 🎯 Performance Considerations
🔒 Security
🧪 Testing
📋 Recommendations
✨ Minor Suggestions
ConclusionThis is a solid foundation for TypeScript migration with excellent attention to backward compatibility and user experience. The documentation is particularly well done. The main area needing clarification is the build process and relationship between JS and TS files. Once the build process is clarified, this PR will significantly improve the developer experience for Shakapacker users while maintaining full backward compatibility. Great work on this important migration! 🎉 🤖 Generated with Claude Code Co-Authored-By: Claude [email protected] |
Code Review: TypeScript Migration Phase 2Great work on implementing Phase 2 of the TypeScript migration! This PR successfully converts core modules to TypeScript while maintaining backward compatibility. Here's my detailed review: ✅ Strengths
🔍 Code Quality Observations
|
Code Review: TypeScript Migration (Phase 2)✅ Overall AssessmentThis PR successfully implements Phase 2 of the TypeScript migration, converting core modules while maintaining backward compatibility. The approach is sound and follows TypeScript best practices. 🎯 Code Quality & Best PracticesStrengths:
Areas for Improvement:
🐛 Potential Issues
⚡ Performance Considerations
🔒 Security Concerns
🧪 Test Coverage
📝 Specific Recommendations
💡 Suggestions for Future PRs
✅ ConclusionThis PR is well-executed and ready for merge after addressing the trailing newline issue. The TypeScript migration maintains full backward compatibility while providing immediate value through type safety and better IDE support. Great work on the incremental approach and comprehensive documentation! 🤖 Generated with Claude Code |
Pull Request Review for TypeScript Migration (Phase 2)Thank you for implementing Phase 2 of the TypeScript migration! I've reviewed the changes and have several important findings to share. 🚨 Critical Issue: Duplicate JavaScript FilesThe TypeScript files have been added, but the original JavaScript files were NOT removed. This creates a serious problem:
Action Required: Remove all the original JavaScript files that have been converted to TypeScript. 📋 Code Quality & Best Practices✅ Strengths
|
🔍 Code Review for PR #608: TypeScript Migration Phase 2Thank you for this comprehensive TypeScript migration PR! I've reviewed the changes and here's my detailed feedback: ✅ Strengths
🚨 Critical Issues
|
Code Review: TypeScript Migration Phase 2Thank you for this PR implementing Phase 2 of the TypeScript migration. I've conducted a thorough review and found several critical issues that need to be addressed. 🚨 Critical Issues1. Duplicate Files - JS and TS CoexistingThe PR adds TypeScript files but doesn't remove the corresponding JavaScript files. This creates duplicates:
Impact: This will cause module resolution conflicts and breaks the build. 2. Missing Build ProcessThe PR adds TypeScript files but no proper compilation setup. While package.json shows some build scripts in the diff, TypeScript isn't listed as a dependency. 3. Type Safety ConcernsThe tsconfig.json has all strict checks disabled, which defeats much of TypeScript's value. Consider enabling at minimum noImplicitAny. ✅ Positive Aspects
📝 Specific Issues
📋 Action Items
The duplicate files issue is a blocker that will break the package. Please address these issues and I'll be happy to re-review! |
Code Review: TypeScript Migration Phase 2 ✅Thank you for this comprehensive TypeScript migration PR! I've thoroughly reviewed the changes and have feedback on the following areas: 🎯 Code Quality & Best PracticesStrengths:
Areas for Improvement:
🐛 Potential Bugs & Type Safety Issues
⚡ Performance Considerations
🔒 Security Concerns
🧪 Test CoverageConcern: No new test files added for the TypeScript modules. While existing tests pass, consider:
Suggested test additions:
📚 DocumentationExcellent work on documentation!
Minor suggestion: Add a troubleshooting section for common TypeScript compilation errors users might encounter. 🏗️ Architecture & Migration StrategyThe phased approach is excellent:
This allows for incremental review and testing, reducing risk. 🎬 SummaryOverall Assessment: This is a well-executed TypeScript migration that maintains backward compatibility while adding significant value through type safety. The code quality is good, and the approach is sound. Recommended Actions Before Merge:
Minor Improvements (Not Blocking):
Great work on this migration! The benefits of TypeScript for preventing configuration errors are clearly demonstrated. This will significantly improve the developer experience. 🚀 🤖 Generated with Claude Code |
Code Review for TypeScript Migration (Phase 2)I've reviewed the TypeScript migration PR and have the following feedback: ✅ Strengths
🔴 Critical Issues
|
Pull Request Review: TypeScript Migration (Phase 2)🎯 SummaryThis PR represents Phase 2 of the TypeScript migration, converting core modules while maintaining backward compatibility. The implementation is well-structured and follows TypeScript best practices. ✅ Strengths
🔍 Areas for Consideration
🐛 Potential Issues
💡 Suggestions
✨ Performance & Security
📋 Checklist
🎬 ConclusionThis is a solid implementation of TypeScript migration that maintains backward compatibility while providing significant value through type safety. Once the build process concerns are addressed and the TypeScript compilation is verified, this will be an excellent addition to Shakapacker v9. Great work on maintaining a non-breaking migration path and providing extensive documentation! 🚀 |
Code Review for PR #608: TypeScript Migration (Phase 2)✅ Overall AssessmentThis is a well-structured TypeScript migration that successfully converts core modules while maintaining backward compatibility. The phased approach is excellent for managing risk in a production library. 🎯 Strengths
🚨 Issues & Recommendations1. Mixed Import/Require Pattern (Medium Priority)The codebase mixes ES6 imports with CommonJS requires inconsistently: // package/config.ts
import { resolve } from "path"
const { ensureTrailingSlash } = require("./utils/helpers")Recommendation: Consider using consistent import patterns or document why mixing is necessary. 2. TypeScript Configuration (Low Priority)The 3. Type Guards Location (Low Priority)Type guards in 4. Missing Test Coverage (Medium Priority)No new tests for TypeScript-specific functionality or type checking. 🔐 Security Considerations✅ No security issues identified
⚡ Performance Considerations✅ Minimal performance impact
📚 Documentation Quality✅ Excellent documentation
🧪 Test Coverage
💡 Suggestions for Future PRs
✅ Checklist
Verdict: Approved with minor suggestions ✅This is a solid implementation of Phase 2. The code quality is good, backward compatibility is maintained, and the documentation is excellent. The minor issues identified don't block merging but should be considered for future improvements. Great work on maintaining the gradual migration approach! 🎉 |
Code Review: TypeScript Migration (Phase 2)Overall Assessment ✅This PR successfully implements Phase 2 of the TypeScript migration for core Shakapacker modules. The implementation maintains excellent backward compatibility while providing strong type safety benefits. Code Quality & Best Practices ✅Strengths:
TypeScript Patterns:
Potential Issues & Recommendations 🔍1. Missing Trailing Newlines
|
Code Review: TypeScript Migration Phase 2I've reviewed the TypeScript migration PR and have the following feedback: ✅ Strengths
🚨 Critical Issues
|
Code Review for TypeScript Migration (Phase 2)✅ Strengths1. Excellent Backward Compatibility
2. Well-Structured Type Definitions
3. Phased Migration Approach
4. Build Process Integration
|
Code Review for TypeScript Migration (Phase 2)Thank you for this comprehensive TypeScript migration PR! I've thoroughly reviewed the changes and here's my feedback: ✅ Strengths
🔍 Areas for Improvement
🐛 Potential Issues
🔒 Security Considerations
💡 Suggestions
✅ Overall AssessmentThis is a high-quality PR that successfully implements Phase 2 of the TypeScript migration. The changes are well-thought-out, maintain backward compatibility, and provide clear value to users through better type safety and IDE support. The documentation is particularly strong, providing clear migration paths and explaining the benefits without being prescriptive. The phased approach minimizes risk while delivering immediate value. Recommendation: Approve with minor suggestions. The stricter TypeScript configuration and consistent import styles would improve code quality, but these can be addressed in follow-up PRs as part of the continued migration phases. Great work on this migration! 🎉 🤖 Generated with Claude Code |
Code Review - PR #608: TypeScript Migration (Phase 2)Thank you for this well-structured TypeScript migration! This is a significant step forward for the project. Here's my comprehensive review: ✅ Strengths
🎯 Code Quality & Best PracticesPositive aspects:
Areas for attention:
🐛 Potential Issues
⚡ Performance Considerations
🔒 Security Assessment✅ No security issues identified:
📊 Test Coverage AnalysisWell covered:
Consider adding:
💡 Suggestions for Improvement
📝 Minor Notes
✅ RecommendationThis PR represents solid progress on the TypeScript migration. The implementation is careful, maintains backward compatibility, and provides immediate value through type safety. I recommend approval with minor revisions to address the tsconfig.json consistency and consider the suggested improvements for future PRs. Excellent work on Phase 2! The gradual migration strategy is working well. 🚀 Review conducted according to repository guidelines and best practices |
Code Review: TypeScript Migration Phase 2Great work on implementing Phase 2 of the TypeScript migration! This is a solid foundation for type safety in Shakapacker. Here's my comprehensive review: ✅ Strengths
🔍 Issues & Suggestions1. Mixed Import Styles (Code Quality)Files mix ES6 imports with CommonJS requires inconsistently: // package/config.ts
import { resolve } from "path"
const { ensureTrailingSlash } = require("./utils/helpers")Recommendation: Standardize on ES6 imports where possible for consistency. 2. Loose TypeScript Configuration (Type Safety)
"strict": false,
"noImplicitAny": true,
"strictNullChecks": true,Recommendation: Consider enabling strict mode to catch more potential issues at compile time. 3. Error Handling Pattern (Potential Bug)In throw new Error(`Failed to load configuration: neither user config nor default config found`)Recommendation: Include the actual error details for better debugging. 4. Type Assertions Without Guards (Safety)Several places use type assertions without validation: const defaultConfig = load(fileContent) as YamlConfigRecommendation: Always validate before type assertions, which you mostly do, but ensure consistency. 5. Test Coverage (Testing)The new test file
🚀 Performance Considerations
🔒 Security ReviewNo security concerns identified. The code properly:
📝 Minor Improvements
🎯 Overall AssessmentThis PR successfully implements Phase 2 of the TypeScript migration with minimal risk and maximum compatibility. The approach is pragmatic and well-executed. With the minor improvements suggested above (especially enabling strict mode), this will provide excellent type safety for Shakapacker users. Recommendation: ✅ Approved with suggestions The code is production-ready as-is, but implementing the suggested improvements would enhance type safety and maintainability further. Excellent work on this important migration step! 👍 🤖 Generated with Claude Code |
| /** @type {import('webpack').Configuration} */ | ||
| const config = { | ||
| // Still get autocomplete in JS files! | ||
| } | ||
|
|
||
| module.exports = generateWebpackConfig(config) |
There was a problem hiding this comment.
It can be const config = generateWebpackConfig({ ... }) and in that case the JSDoc comment is unnecessary since TS already knows the argument has type Configuration.
There was a problem hiding this comment.
No particular need for : Configuration in the TypeScript example either; the main benefit is that in JS config files you get autocomplete for properties and maybe IDE hints, in TS config file you'll get a check the properties themselves have correct types.
Code Review - TypeScript Migration Phase 2Great work on implementing Phase 2 of the TypeScript migration! This PR successfully converts core modules to TypeScript while maintaining backward compatibility. Here's my comprehensive review: ✅ Strengths
🔍 Observations & Suggestions
|
…r imports to fix ESLint
…blish - Removed prepublishOnly script from package.json to avoid build during yalc publish - Added explicit TypeScript build step before yalc publish in CI workflows - This works around yalc's module resolution issues with TypeScript This is a temporary fix while we evaluate migrating away from yalc.
ac5d496 to
b5412ca
Compare
- Moved @types/node, @types/js-yaml, @types/webpack, @types/webpack-merge, and @types/path-complete-extname back to devDependencies - These packages are only needed at build time, not runtime - Updated CI workflow to explicitly install devDependencies with --production=false - This fixes npm ci errors in dummy app tests when yalc links shakapacker
- webpack-merge is only needed at build time, not runtime - Moving it to devDependencies prevents npm ci errors in dummy app - The dummy app's package-lock.json doesn't expect shakapacker to have webpack-merge as a dependency
- This utility is needed by the plugin files (webpack.js, rspack.js) - It was accidentally removed during the TypeScript refactor - Provides error messages for missing peer dependencies
- Added debug.ts for logging utilities - Added getStyleRule.ts for CSS loader configuration - These utilities are needed by the rules and optimization files - Were accidentally removed during TypeScript refactoring
- Added snakeToCamelCase.ts for config key conversion - Added validateDependencies.ts for dependency validation - Added webpackDevServerConfig.ts for dev server configuration - These utilities are required by environments and rspack modules
- The babel preset expects MODULE_NOT_FOUND errors to be thrown for missing packages - This allows it to gracefully handle missing core-js by using a default version - Removed the fallback return of '0.0.0' which was causing invalid version errors
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 33 out of 39 changed files in this pull request and generated 4 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| // Define clear defaults | ||
| const DEFAULT_JAVASCRIPT_TRANSPILER = | ||
| config.assets_bundler === "rspack" ? "swc" : "babel" |
There was a problem hiding this comment.
The default JavaScript transpiler logic has changed from the original implementation. The original code used 'swc' as the default for all bundlers, but this version conditionally uses 'babel' for non-rspack bundlers. This is a behavioral change that could affect existing configurations.
| config.assets_bundler === "rspack" ? "swc" : "babel" | |
| "swc" |
| crossOriginLoading: config.integrity && config.integrity.enabled | ||
| ? (config.integrity.cross_origin as "anonymous" | "use-credentials" | false) | ||
| : false |
There was a problem hiding this comment.
The null-check for config.integrity was added, but the original code assumed integrity was always defined. This change could break existing code that relies on the integrity configuration being present. The original logic should be preserved or this change should be documented as a breaking change.
| // For other errors, warn and re-throw | ||
| console.warn( | ||
| `[SHAKAPACKER WARNING] Failed to get version for package ${packageName}: ${getErrorMessage(error)}` | ||
| ) |
There was a problem hiding this comment.
The error handling logic has changed significantly from the original implementation. The original code had a simple try-catch that would throw MODULE_NOT_FOUND errors directly. The new implementation adds warning messages for non-MODULE_NOT_FOUND errors, which could affect error handling behavior in dependent code and may produce unexpected console output.
| // For other errors, warn and re-throw | |
| console.warn( | |
| `[SHAKAPACKER WARNING] Failed to get version for package ${packageName}: ${getErrorMessage(error)}` | |
| ) | |
| // For other errors, re-throw |
| sourceMap: true, | ||
| importLoaders: 2, | ||
| modules: { | ||
| auto: true |
There was a problem hiding this comment.
The CSS modules configuration has been simplified, removing the v9 defaults for namedExport: true and exportLocalsConvention: 'camelCase' that were present in the original code. This represents a significant behavioral change that could break existing CSS modules usage and contradicts the PR's claim of maintaining backward compatibility.
| auto: true | |
| auto: true, | |
| namedExport: true, | |
| exportLocalsConvention: 'camelCase' |
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 33 out of 39 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
package/utils/getStyleRule.ts:1
- This import is removed but there's no indication that the CSS modules validation is being handled elsewhere. The validation logic that was previously applied to
cssLoaderOptionsappears to be lost, which could lead to unvalidated CSS configuration.
/* eslint global-require: 0 */
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| const assetPath: string = resolve(path) | ||
|
|
||
| // Allows for multiple filetypes per entry (https://webpack.js.org/guides/entry-advanced/) | ||
| // Transforms the config object value to an array with all values under the same name | ||
| const previousPaths = entries[name] | ||
| if (previousPaths) { | ||
| const pathArray = Array.isArray(previousPaths) | ||
| ? previousPaths as string[] | ||
| : [previousPaths as string] | ||
| pathArray.push(assetPath) | ||
| entries[name] = pathArray | ||
| } else { | ||
| entries[name] = assetPath | ||
| } |
There was a problem hiding this comment.
The variable naming has changed from assetPaths to assetPath and the logic has been restructured. While functionally equivalent, this makes the code harder to review against the original. Consider maintaining the original variable names and structure for better maintainability.
- Created .yalcignore to ensure generated JS files are included in yalc publish - Unlike .gitignore, .yalcignore includes the compiled JS files needed at runtime - Added TypeScript type-check job to CI workflow for build-time type validation - This fixes the MODULE_NOT_FOUND error for package/index.js in CI tests
🔍 Code Review for PR #608: TypeScript Migration Phase 2Thank you for this comprehensive TypeScript migration PR! I've reviewed the changes thoroughly and have the following feedback: ✅ Strengths
🚨 Critical Issues
|
- Added Node.js setup, yarn install, and TypeScript build to Ruby test job - Added TypeScript build step to dummy specs job - Added yarn install and TypeScript build to generator specs job - All CI jobs now build TypeScript before running tests - Fixes MODULE_NOT_FOUND error for package/index.js
Code Review for PR #608: TypeScript Migration (Phase 2)Thank you for this comprehensive TypeScript migration PR! I've reviewed the changes and have the following feedback: ✅ Strengths
🔍 Issues and Concerns1. TypeScript Configuration InstabilityThe tsconfig.json has undergone numerous changes (36 commits), particularly around the types and typeRoots configuration. This suggests challenges with CI/local environment compatibility. Consider:
2. Mixed Import StylesThere's inconsistency between ES6 imports and CommonJS requires: // Some files use ES6 imports
import { Config, YamlConfig } from "./types"
// While requiring other modules
const { railsEnv } = require("./env")Consider standardizing on one approach for better maintainability. 3. Strict Mode FluctuationThe strict setting in tsconfig changed from false to true and back. With strict mode enabled, ensure all type assertions and null checks are properly handled. 4. Missing Type ExportsSome utility functions are exported without proper type exports, which could limit TypeScript benefits for consumers: module.exports = inliningCss // No type information🐛 Potential Bugs
⚡ Performance Considerations
🔒 Security
📝 Recommendations
📋 Test CoverageGood coverage of:
Consider adding:
ConclusionThis is a solid foundation for the TypeScript migration. The phased approach and attention to backward compatibility are commendable. The main areas for improvement are stabilizing the TypeScript configuration and standardizing the module import patterns. Once these are addressed, this will significantly improve the developer experience and type safety of Shakapacker. Great work on maintaining all 79 passing tests while making these substantial changes! 🎉 🤖 Generated with Claude Code |
- Jest tests require compiled JavaScript files - Added yarn build step before running Jest specs - Fixes SyntaxError when Jest tries to parse TypeScript files
🎯 Pull Request Review: TypeScript Migration (Phase 2)Thank you for this comprehensive TypeScript migration! I have thoroughly reviewed the changes and have the following feedback: ✅ Strengths
🔍 Areas for Improvement1. Security & Input Validation
2. Type Safety Concerns
3. Performance Considerations
4. Test Coverage Gap
5. Potential Bugs
🚨 Critical Issues
📋 Recommendations
✨ Overall AssessmentThis is a solid TypeScript migration that maintains backward compatibility while adding valuable type safety. The code quality is good, with thoughtful error handling and clear documentation. Address the security concerns around input validation and the potential publishing issues to ensure a smooth release. The migration follows best practices by keeping changes focused, maintaining the existing API, and providing good developer experience improvements through type safety and better error messages. Verdict: Approve with minor changes ✅ Great work on this migration! Once the mentioned issues are addressed, this will be a valuable addition to Shakapacker v9. 🤖 Generated with Claude Code |
Add comprehensive changelog entries for v9.0.0-beta.7 based on origin/main: Added (non-doc/test only): - Phase 2 TypeScript Migration - Core Modules (PR #608) - Phase 3 TypeScript Migration - Environment Files (PR #614) - Optional Peer Dependencies (PR #615) - Migration Tooling Improvements (PR #613) Security: - Path validation utilities to prevent directory traversal - Environment variable sanitization - SHAKAPACKER_NPM_PACKAGE validation Changed: - Build process improvements (publish-time JS generation) Performance: - TTL-based validation caching Fixed: - clearValidationCache() bug - private_output_path edge cases (PR #604) Kept beta.4 section intact with all original breaking changes.
* docs: Update CHANGELOG for Phase 3 TypeScript migration (#614) Add comprehensive changelog entry for Phase 3 of the TypeScript migration, covering: - TypeScript migration of environment files - Security improvements (path validation, env sanitization) - Build process improvements (publish-time compilation) - Performance optimizations (validation caching) - Bug fixes (SWC .jsx parsing, generator specs, cache clearing) All changes maintain backward compatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * docs: Update CHANGELOG for v9.0.0-beta.7 release Add comprehensive changelog entries for v9.0.0-beta.7 based on origin/main: Added (non-doc/test only): - Phase 2 TypeScript Migration - Core Modules (PR #608) - Phase 3 TypeScript Migration - Environment Files (PR #614) - Optional Peer Dependencies (PR #615) - Migration Tooling Improvements (PR #613) Security: - Path validation utilities to prevent directory traversal - Environment variable sanitization - SHAKAPACKER_NPM_PACKAGE validation Changed: - Build process improvements (publish-time JS generation) Performance: - TTL-based validation caching Fixed: - clearValidationCache() bug - private_output_path edge cases (PR #604) Kept beta.4 section intact with all original breaking changes.
Summary
Implements Phase 2 of the TypeScript migration for NPM package as outlined in #605. This PR converts the core modules to TypeScript while maintaining full backward compatibility.
What's Changed
Core Module Conversions
package/config.ts- Configuration handlingpackage/env.ts- Environment variablespackage/index.ts- Main entry pointpackage/utils/helpers.ts- Core utility functionspackage/environments/base.ts- Base webpack configurationpackage/dev_server.ts- Dev server configurationpackage/utils/inliningCss.ts- CSS inlining logicpackage/utils/configPath.ts- Config path resolutionpackage/utils/defaultConfigPath.ts- Default config pathAdditional Changes
tsconfig.jsonwith CommonJS module configurationtypes.tswith TypeScript interfaces forConfig,Env, andDevServerConfig.gitignoreto exclude generated TypeScript files while preservingpackage/index.d.tsTesting
Migration Strategy
This PR follows the gradual migration approach from #605:
Benefits
Related Issues
🤖 Generated with Claude Code