Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed inconsistency for unlinking of pre-symlinked deps, and added option to toggle it #13

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Venryx
Copy link
Contributor

@Venryx Venryx commented Oct 15, 2020

  • Fixed that pre-symlinked dependencies were only unlinked (prior to npm install), if there was no ".nsi.json" file. (unexpected inconsistency)
  • Added new option "keep-prelinked". This option tells nsi to disable the "unlink any pre-symlinked dependencies before npm install" protection feature. (restoring functionality prior to my first pull-request)

Benefits of using the new option:

  1. Increases the speed of nsi. (since the "npm install" command doesn't need to freshly-install those libraries)
  2. Avoids the need for some IDEs to reload. (some IDEs only notice the file deletions, not their re-adding through new symlinks at the end)

However, the option also has this major negative:

  1. Because the pre-symlinked folders are not unlinked prior to "npm install", the npm-install process can (and will -- at least in some cases) tunnel into those symlinked folders and modify them (since it doesn't fully account for their being in external folders). Depending on the dependency-trees between the user project, and the symlinked folders, this can cause a number of subtle errors later on. (as I've experienced multiple times)

Because of that one major negative, I currently have "keep-prelinked" disabled by default.

@UD-UD If you'd like this option enabled by default, let me know, and I'll make the change. However, in that case I think the Readme should at least contain mention of the potential drawbacks of it. (I just got bit by it this morning, hence my making the changes, and putting it into a pull-request)

… folders get unlinked -- otherwise the npm install command deletes subdependencies in the symlinked folders that are shared by the root project.

* Fixed that SymlinkCollector would keep tunneling deeper into all subfolders, when the root folder's path contains the "@" character. (now it only tunnels deeper when the folder name itself starts with "@" -- intended for packages hosted under an "@"-prefixed organization folder, apparently)
* Fixed bug regarding the async/await in SymlinkCollector.execute, whereby the processing of subfolders would not be "awaited" for by the root execute call -- thus their results were being ignored.
…k/") were not getting restored properly. (it would try to restore "package-name" by itself, instead of "@org-name/package-name")

* Made so that if command fails, it logs the actual reason/error!
* Made so that if there are no packages to relink after the "npm install" command, the "npm link" command is not even run. (else, the "npm link X Y Z" is just "npm link", which has a different and unexpected behavior)
* Removed unused "cb" param from SymlinkCollector.execute. (each call has apparently just been using the attached-to-instance "this.callback")
…npm install), if there was no ".nsi.json" file.

* Added new option "keep-prelinked". This option tells nsi to not unlink any pre-symlinked dependencies found.

Benefits of using the new option:
1) Increases the speed of nsi. (since the "npm install" command doesn't need to freshly-install those libraries)
2) Avoids the need for some IDEs to reload. (some IDEs only notice the file deletions, not their re-adding through new symlinks at the end)

However, the option also has this major negative:
1) Because the pre-symlinked folders are not unlinked prior to "npm install", the npm-install process can (and will -- at least in some cases) tunnel into those symlinked folders and modify them (since it doesn't fully account for their being in external folders). Depending on the dependency-trees between the user project, and the symlinked folders, this can cause a number of subtle errors later on. (as I've experienced multiple times)

Because of that one major negative, I currently have "keep-prelinked" disabled by default. If the repo owner (@UD_UD) wants this option enabled by default, then I think the Readme should at least contain mention of the potential drawbacks of it. (I just got bit by it this morning, hence my making the changes, and putting it into a pull-request)
@UD-UD
Copy link
Owner

UD-UD commented Feb 22, 2021

Will review this.

@UD-UD UD-UD self-assigned this Feb 22, 2021
@UXnomaan
Copy link

UXnomaan commented May 11, 2021

@UD-UD - any news on this? new -k flag that @Venryx introduces will make this a great developer experience in a new repo. This helps with shorter environment setup.

@UD-UD
Copy link
Owner

UD-UD commented Sep 7, 2021

@UD-UD - any news on this? new -k flag that @Venryx introduces will make this a great developer experience in a new repo. This helps with shorter environment setup.

@UXnomaan Will merge this PR as soon possible.

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