function resolveNodule({ nodule, instrumentation, esmResolver }) {
  if (instrumentation.isEsm === true || !esmResolver) {
    return nodule
  }

  // We have a CJS module wrapped by import-in-the-middle having been
  // imported through ESM syntax. Due to the way CJS modules are parsed by
  // ESM's import, we can have the same "export" attached to the `default`
  // export and as a top-level named export. In order to shim things such
  // that our users don't need to know to access `something.default.foo`
  // when they have done `import * as something from 'something'`, we need
  // to proxy the proxy in order to set our wrappers on both instances.
  const noduleDefault = nodule.default
  const origNodule = nodule
  return new Proxy(
    { origNodule, noduleDefault },
    {
      get(target, name) {
        if (name === nrEsmProxy) {
          return true
        }
        if (target.noduleDefault[name]) {
          return target.noduleDefault[name]
        }
        return target.origNodule[name]
      },
      set(target, name, value) {
        if (target.origNodule[name]) {
          target.origNodule[name] = value
        }
        if (target.noduleDefault[name]) {
          target.noduleDefault[name] = value
        }
        return true
      }
    }
  )
}
If a module that is being shimmed was loaded via a typical `require` then
we can use it as normal. If was loaded via an ESM import, then we need to
handle it with some extra care. This function inspects the module,
the conditions around its loading, and returns an appropriate object for
subsequent shimming methods.

@param {object} params Input parameters.
@param {object} params.nodule The nodule being instrumented.
@param {object} params.instrumentation The configuration for the nodule
to be instrumented.
@param {boolean|null} params.esmResolver Indicates if the nodule was loaded
via an ESM import.
@returns {object} The nodule or a Proxy.