{"size": 926, "ext": "js", "max_stars_repo_path": "core/dev-utils/WatchMissingNodeModulesPlugin.js", "max_stars_repo_name": "arpowers/poi", "max_stars_repo_stars_event_min_datetime": "2017-04-30T12:14:59.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T00:54:17.000Z", "max_issues_repo_path": "core/dev-utils/WatchMissingNodeModulesPlugin.js", "max_issues_repo_name": "arpowers/poi", "max_issues_repo_issues_event_min_datetime": "2017-04-30T12:34:15.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-15T21:55:19.000Z", "max_forks_repo_path": "core/dev-utils/WatchMissingNodeModulesPlugin.js", "max_forks_repo_name": "arpowers/poi", "max_forks_repo_forks_event_min_datetime": "2017-05-03T03:21:16.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-22T18:04:03.000Z"}
{"max_stars_count": 4796, "max_issues_count": 486, "max_forks_count": 376, "avg_line_length": 33.0714285714, "max_line_length": 80, "alphanum_fraction": 0.7267818575}
/* eslint-disable */
// This Webpack plugin ensures `npm install <library>` forces a project rebuild.
// We’re not sure why this isn't Webpack's default behavior.
// See https://github.com/facebook/create-react-app/issues/186.

'use strict'

class WatchMissingNodeModulesPlugin {
  constructor(nodeModulesPath) {
    this.nodeModulesPath = nodeModulesPath
  }

  apply(compiler) {
    compiler.hooks.emit.tap('WatchMissingNodeModulesPlugin', compilation => {
      const missingDeps = [...compilation.missingDependencies]
      const nodeModulesPath = this.nodeModulesPath

      // If any missing files are expected to appear in node_modules...
      if (missingDeps.some(file => file.includes(nodeModulesPath))) {
        // ...tell webpack to watch node_modules recursively until they appear.
        compilation.contextDependencies.add(nodeModulesPath)
      }
    })
  }
}

module.exports = WatchMissingNodeModulesPlugin
