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

Automatically load node modules in devshell #1066

Closed

Conversation

robbevp
Copy link
Member

@robbevp robbevp commented Nov 25, 2023

This PR makes sure that loading the devshell (using direnv or nix develop) automatically includes the node modules.

@robbevp robbevp added the chore Repository or build maintenance label Nov 25, 2023
@robbevp robbevp requested a review from chvp November 25, 2023 13:16
@robbevp robbevp self-assigned this Nov 25, 2023
@robbevp robbevp force-pushed the chore/automatically-load-node-modules-in-devshell branch from 500c221 to 25ed4cf Compare November 25, 2023 13:18
Copy link
Member

@chvp chvp left a comment

Choose a reason for hiding this comment

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

How does one add a dependency or manually change its version with this in place?

@robbevp
Copy link
Member Author

robbevp commented Nov 26, 2023

Ugh, forgot about that.
We could create a script (like we have for the api) to update both the yarn.lock and yarn.nix file.
I would need to be something like

yarn install --modules-location $PRJ_DATA_DIR/tmp_yarn
yarn2nix > yarn.nix
rm -rf $PRJ_DATA_DIR/tmp_yarn

We can't install to node_modules, since this would try to write to the nix store, but yarn v1 requires us to install the modules in order to update the lockfile (this isn't the case for the most recent version of npm or yarn).

There might also be a way to make this work by appending/prepending the NODE_PATH env var, but I haven't been able to try that.

@robbevp
Copy link
Member Author

robbevp commented Dec 2, 2023

Just realised that this would also break usage of yarn link, since that would also need to write to the node_modules folder. I guess the benefit of not having to run yarn install is not worth these downsides?

@chvp
Copy link
Member

chvp commented Dec 2, 2023

Ah yeah, that's also a big downside. I would say it's not worth it indeed.

@robbevp robbevp closed this Dec 2, 2023
@robbevp robbevp deleted the chore/automatically-load-node-modules-in-devshell branch December 2, 2023 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Repository or build maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants