Skip to content

Conversation

@iamraihan
Copy link

@iamraihan iamraihan commented Jul 9, 2025

🚀 Fix npm build issues and implement robust makepot script

📋 Summary

Resolved critical npm installation and build issues in the WP Project Manager plugin, and implemented a reliable solution for generating translation (.pot) files.

Issues Fixed

1. npm install failures

  • Problem: node-sass dependency was failing to build due to Python dependency issues on modern systems
  • Solution: Replaced node-sass@^4.13.1 with sass@^1.32.0 and updated sass-loader to ^10.0.0
  • Impact: npm install now completes successfully without build errors

2. PHP memory limit errors in makepot

  • Problem: npm run makepot was failing with "Allowed memory size exhausted" errors
  • Solution: Created a dedicated shell script with configurable PHP memory limits
  • Impact: .pot file generation now works reliably across different environments

3. Build and watch mode issues

  • Problem: npm run build and npm run start were failing due to dependency conflicts
  • Solution: Updated package.json dependencies to compatible versions
  • Impact: Both build and watch modes now function correctly

🛠 Technical Changes

package.json updates

- "node-sass": "^4.13.1",
+ "sass": "^1.32.0",
- "sass-loader": "^6.0.6",
+ "sass-loader": "^10.0.0",
- "makepot": "wpvuei18n makepot"
+ "makepot": "./scripts/makepot.sh"

New script: scripts/makepot.sh

  • Efficient shell script for .pot file generation
  • Configurable PHP memory limits via environment variables
  • Basic prerequisite validation (package.json, wp-vue-i18n, PHP)
  • Clean error handling and output

Updated .gitignore

+ /languages/*.backup.*

Benefits

Environment Flexibility

  • Development: 512M memory limit (default)
  • Custom: PHP_MEMORY_LIMIT=1G npm run makepot
  • Production: NODE_ENV=production npm run makepot

Reliability

  • ✅ npm install works on all modern systems
  • ✅ Build process completes without errors
  • ✅ Watch mode functions correctly
  • ✅ .pot file generation handles large codebases

Maintainability

  • Clean, minimal script
  • Environment variable configuration
  • Proper error messages and validation

🧪 Testing

Verified Commands

npm install          # ✅ Success
npm run build        # ✅ Success  
npm run start        # ✅ Success (watch mode)
npm run makepot      # ✅ Success (.pot generation)

📝 Usage Examples

Basic usage

npm run makepot

Custom memory limit

PHP_MEMORY_LIMIT=1G npm run makepot

Production environment

NODE_ENV=production npm run makepot

Files Changed

  • package.json - Updated dependencies and scripts
  • scripts/makepot.sh - New reliable script
  • .gitignore - Added backup file exclusion

🔧 Node.js Compatibility

  • Recommended: Node.js 16.x (LTS)
  • Minimum: Node.js 8.x
  • Tested: Node.js 22.13.1 (works with deprecation warnings)

Summary by CodeRabbit

  • Chores
    • Updated the .gitignore file to exclude backup files in the /languages/ directory.
    • Replaced the node-sass package with sass and updated sass-loader to a newer version for improved Sass compilation.
    • Modified the makepot script to use a new shell script for generating translation files.
    • Added a shell script that checks environment requirements and manages translation file generation.

@coderabbitai
Copy link

coderabbitai bot commented Jul 9, 2025

Walkthrough

This update introduces a new shell script for generating POT files, modifies the package.json to use this script, and updates Sass-related dependencies. Additionally, the .gitignore file is updated to exclude backup files in the /languages/ directory.

Changes

File(s) Change Summary
.gitignore Added rule to ignore /languages/*.backup.* files.
package.json Switched makepot script to use a shell script; replaced node-sass with sass; upgraded sass-loader.
scripts/makepot.sh Added new shell script for POT file generation with environment checks and resource limit settings.

Poem

A bunny hops through code so neat,
With scripts and tools beneath its feet.
Sass gets a shiny, modern coat,
POT files now with bash to float.
Backups hidden out of sight—
The project’s future’s looking bright!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c6887d7 and 86e5bd1.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • views/assets/vendor/vue-fullscreen/vue-fullscreen.min.js is excluded by !**/*.min.js
📒 Files selected for processing (2)
  • package.json (2 hunks)
  • scripts/makepot.sh (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • scripts/makepot.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
.gitignore (1)

21-21: Pattern may miss nested backup files

/languages/*.backup.* only matches files directly inside /languages/.
If any tooling creates backups inside sub-directories (e.g. /languages/fr_FR/foo.backup.po) they’ll still be committed.

-/languages/*.backup.*
+/languages/**/*.backup.*

Not blocking, but worth tightening now to avoid future noise.

scripts/makepot.sh (1)

9-21: Allow the script to be executed from any directory

Current prerequisite checks require running the script from plugin root.
A tiny tweak lets callers execute it from any path while still validating against the root:

-# Check for prerequisites
-if [ ! -f "package.json" ]; then
+# Resolve project root (= parent of this script)
+ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+cd "$ROOT_DIR"
+
+# Check for prerequisites
+if [ ! -f "package.json" ]; then

Makes automation & CI a bit more tolerant.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b77a90 and c6887d7.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • views/assets/vendor/vue-fullscreen/vue-fullscreen.min.js is excluded by !**/*.min.js
📒 Files selected for processing (3)
  • .gitignore (1 hunks)
  • package.json (2 hunks)
  • scripts/makepot.sh (1 hunks)
🔇 Additional comments (2)
scripts/makepot.sh (1)

5-8: Default values look good

Using env-overrides for MEMORY_LIMIT and MAX_EXECUTION_TIME is spot-on.

package.json (1)

13-13: Ensure scripts/makepot.sh is executable & cross-platform friendly

npm run will fail on Windows if Git-Bash isn’t installed.
Consider adding a tiny Node wrapper (node scripts/makepot.js) or documenting that Windows users need a POSIX shell.

Also double-check the file has chmod +x.

… dependencies, and improve makepot script error handling.
@Rubaiyat-E-Mohammad Rubaiyat-E-Mohammad added the QA Approved This PR is approved by the QA team label Jul 22, 2025
@iftakharul-islam iftakharul-islam added QA in Progress and removed QA in Progress QA Approved This PR is approved by the QA team labels Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants