Closed (duplicate)
Project:
Drupal core
Version:
8.2.x-dev
Component:
file system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
15 Dec 2014 at 16:49 UTC
Updated:
15 Nov 2016 at 21:42 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
joelpittetInterested in providing a patch for this?
Comment #2
kolier commentedSure, have a try.
Comment #3
joelpittetThanks @kolier, this seems like a good idea for folders you mentioned in the issue summary:) I currently don't have the use-case but I'll give it a try when I do. Heads up, it may get bumped to D8 before it gets in D7, though I'm going to keep the version here and let someone else bump it if they see it fitting.
Comment #4
rballou commentedAnother option is to change the default "nomask" option to include node_modules and other folders that do not need to be scanned by default.
Comment #5
tim.plunkettNothing goes into D7 without going into D8 first.
Comment #6
rballou commentedLooks like my fix won't work for D8 as the nomask option/default mask does not exist. I haven't had time to test if file_scan_directory descends into node_modules (and others) by default, but I'd guess they would.
(Here is the D7 version)
Comment #7
tim.plunkettThe nomask option still exists, there is just no default for it as of #1165694: Remove default nomask from file_scan_directory()
https://github.com/drupal/drupal/blob/8.0.x/core/includes/file.inc#L1052 now just checks first.
Comment #8
rballou commentedYeah, adding "node_modules" and "bower_components" (others?) as a default would need to happen where Drupal does it default file scanning (which I haven't tracked down for D8). In my opinion, Drupal does not need to search those directories by default if they are present and in D7 it can significantly affect performance when they are present in the Drupal root. I think this will become more common as Node, Bower, Grunt, Gulp, etc. become more common tools for Drupal developers. In the case on a recent project, this affects our dev environments but not production because we're not installing these things there. @kolier patch would also work for ignoring these directories but requires adding the
.scanignorefile in all these locations.I'll try to test this with D8 soon. For [my] reference, here's things calling file_scan_directory in D8.
Comment #9
rballou commentedFrom my initial testing I strongly feel this is only a D7 thing and may only affect D8 if these directories are in a theme. Out of the box, D7 is much more aggressive with scanning the filesystem than D8 (at least with
file_scan_directory, not sure about other things). One thing to double check in D7: I think node_modules (and others) may be ignored if they are at the Drupal root, but are not when they are in the theme or in a module.Comment #10
joelpittetFYI I put this in my node_modules and bower_components with
On cache flush:
Before:
After:
Comment #11
zhawkins commentedThis bit me pretty hard. I've added the following to my package.json to generate the .scanignore file when 'npm install' is run.
I've added the link inside the file so others have some way to figure out why it's there.
Comment #12
joelpittet@ZHawkins awesome idea! Especially because node_modules and bower packages are not usually committed to the repo! Brilliant!
Comment #13
joelpittetAdding related issue #2329453: Ignore front end vendor folders to improve directory search performance
Comment #14
marcvangendI like this idea as a solution to #2329453: Ignore front end vendor folders to improve directory search performance, but I'm not sure about the filename
.scanignore. Even though Google doesn't return any results for that filename at the moment, I think we should choose a name that is unlikely to cause collisions with other software that happens to use the same name. I would prefer something namespaced like.drupalignore.Comment #15
dddbbb commented.drupal_scan_ignore? Theoretically, other scenarios may arise where Drupal is required to ignore other things but for a different reason. This would namepsace both the software and the purpose/context.Comment #16
corbacho commentedThis hit me hard.. https://twitter.com/dcorbacho/status/632132568587051008
Not only me https://twitter.com/crizzirc/status/632138118695682049
This solution proposed sounds very good idea and clean. ONCE that you know this problem.
+1 to marcvangend idea to use
".drupalignore"But somehow, I must agree with mark carver on #2329453: Ignore front end vendor folders to improve directory search performance where he thinks this would be "another drupalism".
If someone new to Drupal runs
npm installon a Drupal folder, and starts to slow down the site.. and he's not aware of this issue, he will just blame Drupal for being slow. Front end developers shouldn't need to be aware of how Drupal core works internally. (by default)Comment #17
donquixote commentedComment #20
joelpittetThis is a duplicate of #2329453: Ignore front end vendor folders to improve directory search performance which is committed to 8.x. Closing so people aren't confused.
Comment #21
damienmckennaFor anyone looking for the D7 backport of the other issue, it was moved to #2482549: Ignore node_module folder in core to use Drupal with npm/grunt/nodejs.