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

Allow specifying location of pnpmfile.js in the package.json. #910

Closed
vjpr opened this issue Oct 9, 2017 · 13 comments · Fixed by #1106
Closed

Allow specifying location of pnpmfile.js in the package.json. #910

vjpr opened this issue Oct 9, 2017 · 13 comments · Fixed by #1106

Comments

@vjpr
Copy link
Contributor

vjpr commented Oct 9, 2017

There are already so many files cluttering the project root.

Would be cool if the location of pnpmfile.js could be configured in the package.json.

Use case: I want to put it in tools/pnpmfile.js, so I can easily copy the tools folder to other projects as a kind of project boilerplate.

@zkochan
Copy link
Member

zkochan commented Oct 9, 2017

what would be the package.json field name? I guess pnpmConfig?

@zkochan
Copy link
Member

zkochan commented Oct 9, 2017

actually, my suggestion would be to use npm's config-system instead of the field in package.json.

If this will be a npm config, it will be a lot more powerful. It will allow specifying globally one pnpmfile.js for every project on the computer.

@vjpr
Copy link
Contributor Author

vjpr commented Oct 9, 2017

It will allow specifying one pnpmfile.js for every project on the computer.

I prefer a package.json key because when you clone the project from github and run pnpm i you want things to work without having to setup additional configuration.

@zkochan
Copy link
Member

zkochan commented Oct 9, 2017

sure, but you can have a .npmrc file in the root of the project. Like we have for pnpm: https://github.com/pnpm/pnpm/blob/master/.npmrc

@vjpr
Copy link
Contributor Author

vjpr commented Oct 9, 2017

Ah, didn't know about .npmrc. This feels like the right way to do it then.

@andreineculau
Copy link
Contributor

I find this an overkill and a feature creep, at least for the reasons mentioned.

Firstly, who does that? As in where did you see this pattern?

Secondly, why is it so much harder to cp .eslintrc.js .babelrc pnpmfile.json new_repo/ then cp tools new_repo/ ?

Thirdly, just like I was mentioning in another pnpm thread that it is a bad idea to pollute package.json with new configuration keys, it si also a bad idea to pollute .npmrc . AFAIC both are owned by npm and npm alone.

@vjpr
Copy link
Contributor Author

vjpr commented Dec 7, 2017

@andreineculau

Secondly

Why use folders to organize your source code...why not keep everything flat file ;)

Monorepos. Cleaner github.com/foo/bar homepage. Less vertical space in tree view in IDE/text editor. Many reasons.

Thirdly

I create tons of packages in monorepos so I prefer having as few files as possible per package. I would rather have all config in one file, but am forced not to because of every tool maker defining a different naming standard and hard-coded location.

  • package.json reduces the number of files, but doesn't support .js config.
  • tools is a good compromise because everything is in one place.

If you were creating config for your project, you would not use 10 different file naming standards, and keep everything in the root folder. But you are forced to atm.

@zkochan
Copy link
Member

zkochan commented Apr 2, 2018

Regarding configs in package.json, @wmertens has requested it as well in #820

@jsumners
Copy link

jsumners commented Apr 2, 2018

I vote for npmrc. Additionally, it would be great if resolution worked in the same method as traditional Unix configuration files: local > user > system (see https://www.npmjs.com/package/nixconfig).

Consider this situation as a reason for supporting the feature:

  1. pre-commit is not working correctly when installed into a fresh project via pnpm -- Make pre-commit compatible with pnpm observing/pre-commit#121
  2. A PR to fix the situation is lying dormant -- Set root to initial package manager process cwd (fix #121) observing/pre-commit#122
  3. I have the fix published to @jsumners/pre-commit
  4. I need this fork installed in any project that uses pre-commit (of which I have numerous) until such time as upstream fixes the issue

In this situation it is:

  1. Too much work to add a pnpmfile.js to every project dependent upon pre-commit
  2. Too much to ask collaborators to put up with just to satisfy my desire to use pnpm instead of npm

Having a global file will alleviate the whole situation.

@zkochan
Copy link
Member

zkochan commented Apr 2, 2018

  1. only via npmrc. The config can be called pnpmfile
  2. for backwad compatibility, if there is a pnpmfile.js in the root of the project, the config is ignored
  3. I would also update reporting. It should print the location of the pnpmfile.js at the beginning of installation

So it will be possible to do npm set pnpmfile ~/pnpmfile.js

@jsumners
Copy link

jsumners commented Apr 2, 2018

That will be fantastic, but are you saying this will not be supported:

  1. <project>/pnpmfile.js
  2. ~/pnpmfile.js
  3. ~/pnpmfile.js is loaded and then <project>/pnpmfile.js is loaded, potentially overriding settings from ~/pnpmfile.js

@zkochan
Copy link
Member

zkochan commented Apr 2, 2018

Only one pnpmfile.js will be loaded. At least for now. It is a js file after all, so you can load other pnpmfiles from it.

zkochan added a commit to pnpm/config that referenced this issue Apr 7, 2018
@zkochan zkochan self-assigned this Apr 7, 2018
zkochan added a commit that referenced this issue Apr 7, 2018
zkochan added a commit that referenced this issue Apr 7, 2018
zkochan added a commit that referenced this issue Apr 8, 2018
A global pnpmfile can be used by setting the `global-pnpmfile`.
The global pnpmfile is composed with any local pnpmfile.

ref #1106
ref #910
zkochan added a commit that referenced this issue Apr 8, 2018
A global pnpmfile can be used by setting the `global-pnpmfile`.
The global pnpmfile is composed with any local pnpmfile.

ref #1106
ref #910
@zkochan
Copy link
Member

zkochan commented Apr 8, 2018

🚢 1.39.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants