fix(gatsby): Improve discoverPluginsWithoutNodes performance (#19594)
fix(gatsby): Improve discoverPluginsWithoutNodes performance (#19594)

* Improve discoverPluginsWithoutNodes perf

Prevent some object creation, prevent using lodash methods in favor of using `Set`s directly, prevent an `Array.from` call on `getNodes()` which always returns an array.

Combined the filter for `flattenedPlugins` (there were two filters, now there is one)

Creating the `nodeOwnerSet` set on the fly, preventing the temporary array that was used before

Prevent using lodash and internal lodash machinery for this.

* chore(gatsby): refactor source-nodes.js

gatsbyjs/gatsby,gatsbyjs/gatsby,gatsbyjs/gatsby,gatsbyjs/gatsby,gatsbyjs/gatsby,gatsbyjs/gatsby