Skip to content

Logging for badly behaved modules #1

@i-like-robots

Description

@i-like-robots

Firstly, thank you very much for creating this plugin - it's been really useful for me. However, (in the nicest possible way) I'd like to work towards a position where I don't need to use it anymore!

Some of the codebases I work on are spawling and I can't migrate everything myself - either to require().default or to use ESM - so I want to encourage others to help.

Do you think it would be possible (or sensible) to be able to use this plugin in order to provide warnings in development which can inform developers where changes are required?

As a a quick and dirty example perhaps the embedded interop function could look something like this:

function __require_default_func__(module, name) { 
  if (module && module.__esModule && typeof module["default"] !== "undefined") {
    function hack() {
      console.warn(`You need to fix ${name}!`)
    }

    hack.default = module["default"]

    return hack;
  }

  return module; 
}

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions