magesuite / magepack

Next generation Magento 2 advanced JavaScript bundler.
Open Software License 3.0
431 stars 93 forks source link

Added feature + Bug fix #182

Closed maximus-sallam closed 6 months ago

maximus-sallam commented 6 months ago

Added feature: Global npm installation is restricted on managed hosting platforms due to security considerations. As an employee at a shared hosting company, I have encountered numerous instances where we had to inform customers that Magepack is not supported on our platform due to the mandatory global installation requirement. To address this challenge, I have implemented code modifications and supplied the necessary shared object files, enabling local execution for improved security and compatibility.

Bug fix: The feature possibly introduced a bug that caused collectModules.js to become unresponsive during the product.js stage of generation, specifically at the rjsResolver step. The issue was with the use of a Promise in the code. Promises in JavaScript are used for asynchronous operations, indicating that a function will complete at some point in the future. In this case, the Promise was used to wait for the rjsResolver operation to finish before continuing with the code execution.

The problem with this approach was that it caused the code to pause and wait for the rjsResolver operation to complete before moving on to the next steps. As a result, the code appeared to freeze or stall at that point because it was waiting for the Promise to resolve.

To address this, I replaced the Promise with a callback function named onRjsResolverComplete. By using this callback, I ensured that the code would continue running without waiting for the rjsResolver operation to finish. This change allowed the code to proceed smoothly without any interruptions, and it no longer appeared to freeze at that stage of execution.