medusa
medusa copied to clipboard
Preserve node flags in develop command
What
I have added the node --preserve-symlinks flag to the child process that gets created when running the Medusa develop command.
Why
To help streamline the process of creating a new plugin - as I found this was a noticeable stumbling block for me. Otherwise, it is not possible to run a Medusa server with the develop command while testing a plugin locally.
How
Converted the "cross-spawn" package usage to Node's standard lib "child_process" fork method. This provides the child process with sensible defaults (current directory, current environment, standard i/o...) and passes node flags from its parent, as well as adding the --preserve-symlinks as one of the default flags to Node.
Testing
I tested this by building the medusa package and copying the newly built develop.js file to my node_modules/@medusajs/medusa/dist/commands directory in my Medusa project. Certainly not the best workflow, but I was finding that when I linked a local version of the medusa package to my Medusa project the symlinks for my plugin would still get resolved whether or not the --preserve-symlinks flag was passed... probably a knowledge issue with dependencies that I couldn't get my head around.
This aims to fix issue #1859.
Also, with this PR, perhaps cross-spawn is no longer needed as a dependency?
🦋 Changeset detected
Latest commit: 440a9a81b52f26f209573672c748de1ae7d37460
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 11 packages
| Name | Type |
|---|---|
| @medusajs/medusa | Patch |
| @medusajs/admin-ui | Patch |
| @medusajs/admin | Patch |
| @medusajs/medusa-js | Patch |
| medusa-payment-paypal | Patch |
| medusa-payment-stripe | Patch |
| medusa-plugin-mailchimp | Patch |
| medusa-plugin-restock-notification | Patch |
| medusa-react | Patch |
| @medusajs/medusa-oas-cli | Patch |
| @medusajs/oas-github-ci | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
I think it's now possible to remove the cross-spawn dependency from the project now that we fork the new process with Nodes child_process from stdlib. I did a codebase search and couldn't find more references, but interested in your opinion.
@srindom do you think that this could get a review at some point. It would avoid a user to have to remove the node modules from the peers in the plugin as explain in the documentation and instead use the preserve flag. wdyt?
@olivermrbl is attempting to deploy a commit to the medusajs Team on Vercel.
A member of the Team first needs to authorize it.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| medusa-docs | ⬜️ Ignored (Inspect) | Jun 14, 2023 11:38am |