Problem/Motivation

When installing the core JS dependencies there is a core/node_modules folder, which is not covered by our .gitignore.

Steps to reproduce:

  1. Install yarn
  2. cd /core
  3. "yarn install"

Proposed resolution

An entry to example.gitignore for core/node_modules. This is equivalent to ignoring the vendor directory for dependencies managed by composer.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Members fund testing for the Drupal project. Drupal Association Learn more

Comments

dawehner created an issue. See original summary.

ritzz’s picture

Assigned: Unassigned » ritzz

I am working on this.

ritzz’s picture

Assigned: ritzz » Unassigned
marncz’s picture

marncz’s picture

Status: Active » Needs review
cilefen’s picture

marncz’s picture

@cilefen

thanks! updated the patch

cilefen’s picture

Let's see what @dawehner thinks about this. He doesn't do things for no reason, so usually there is a reason.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Fair point @cilefen it is similar to our composer.lock files.

I honestly don't know anymore what I have been thinking. I cannot agree more. Too bad we don't ship with one at the moment :)

dawehner’s picture

oh right, this is what annoyed me. I used yarn to install the dependencies and then ended up with a yarn.lock file laying around.

lauriii’s picture

Category: Bug report » Task
Status: Reviewed & tested by the community » Needs review

Drupal core has only development JavaScript dependencies. These are only installed in a core development setup. Therefore this setup is not needed in most environments. Should we just add this as a commented line and say that you can uncomment this if you need it?

We should at least improve the documentation about what is this actually needed for so that it is easier for people to see what is each of the ignores intended for.

dawehner’s picture

Drupal core has only development JavaScript dependencies. These are only installed in a core development setup. Therefore this setup is not needed in most environments. Should we just add this as a commented line and say that you can uncomment this if you need it?

For me there is not much difference to the core/phpcs.xml and core/phpunit.xml files

alexpott’s picture

Component: javascript » documentation
Issue tags: +JavaScript
FileSize
347 bytes

I agree with @dawehner we should add this to the example.gitignore If you are doing core javascript development then not having this is going to be a bugbear. If you are not doing core javascript development you are not going to notice.

To see what happens:
1. get npm or yarn
2. cd /core
3. "yarn install" or "npm install"

You'll end up with a core/node_modules directory that you do want to check in. These dependencies are going to be used to build Drupal's js.

I also agree with @lauriii that we can improve the comment.

Rather than this being like phpcs.xml this is most like the exclusion of the vendor directory - and we definitely don't want to have a repeat of committing something like that. Moving to the documentation component because this is only an example file and has no run-time effect.

alexpott’s picture

Wrapping...

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Thank you @alexpott!

I personally think that creating a follow up to simply group all the "development" related files together could be helpful.

alexpott’s picture

Issue summary: View changes

Updated the IS

alexpott’s picture

Created #2861497: Check in yarn.lock and recommend usage of yarn to discuss the yarn.lock issue.

alexpott’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
434 bytes

@lauriii pointed out that there is a line that says

# If you prefer to store your .gitignore file in the sites/ folder, comment
# or delete the previous settings and uncomment the following ones, instead.

So we need to be above that line. Putting it next to vendor cause it is about the same stuff.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

I believe if someone edits a .gitignore file they kinda know already how it works.

  • lauriii committed fa8889e on 8.4.x
    Issue #2859663 by alexpott, marncz, dawehner: Ignore core/node_modules
    
lauriii’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

Thanks everyone! I've committed fa8889e and pushed to 8.4.x.

As a documentation issue, this could be considered to be committed for 8.3.x as well.

xjm’s picture

Component: documentation » other
Status: Patch (to be ported) » Fixed

If the line were commented out, then I'd call it documentation, but in this case it is an actual uncommented line of the example gitignore. If people are merging this into their gitignores then it could change behaviors. I think it's fine to make this change in 8.4.x only; it does not prevent anyone from adding it to their gitignores if they need to.

Thanks @lauriii!

alexpott’s picture

There's another way of looking at this. We are explicit at telling people not to make changes to anything inside ./core but building the yet-to-be-used tools to make core's js we need to put the dependencies somewhere. We really don't want to put these things outside ./core so ./core/node_modules makes sense but it would never make sense to commit ./core/node_modules and someone doing that is in for quite a few difficulties. In my opinion, not having this in your .gitignore is a bug.

As we're yet to use ES6 and these build tools no one is running into this problem. All this said, we're probably not going to move to ES6 on the 8.3.x branch. However I would think that putting this in 8.3.x is sensible because we don't want people setting up a Drupal development environment in 8.3.0 and them not having this and then revisiting their gitingore in 8.4.x. If someone is at all affected by this then they are using Drupal in a completely unsupported way - and even so adding something to gitgnore won't remove their commits anyway.

Plus we really need to update https://www.drupal.org/documentation/git/configure#gitignore since that doesn't contain the necessary info about this or vendor for Drupal 8.

droplet’s picture

Or put a core/.gitignore?

alexpott’s picture

@droplet that's an excellent idea - let's file another issue to do that.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

alexpott’s picture

Created #2867290: Introduce a core/.gitignore as a followup based on #24